tracing-cpu-profiler.h 1.12 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_PROFILER_TRACING_CPU_PROFILER_H
#define V8_PROFILER_TRACING_CPU_PROFILER_H

8
#include "include/v8-platform.h"
9
#include "include/v8-profiler.h"
10
#include "src/base/atomic-utils.h"
11
#include "src/base/macros.h"
12
#include "src/base/platform/mutex.h"
13 14 15 16

namespace v8 {
namespace internal {

17 18 19 20 21
class CpuProfiler;
class Isolate;

class TracingCpuProfilerImpl final : public TracingCpuProfiler,
                                     private v8::Platform::TraceStateObserver {
22 23 24 25
 public:
  explicit TracingCpuProfilerImpl(Isolate*);
  ~TracingCpuProfilerImpl();

26 27 28 29
  // v8::Platform::TraceStateObserver
  void OnTraceEnabled() final;
  void OnTraceDisabled() final;

30
 private:
31 32 33 34 35 36 37 38
  void StartProfiling();
  void StopProfiling();

  Isolate* isolate_;
  std::unique_ptr<CpuProfiler> profiler_;
  bool profiling_enabled_;
  base::Mutex mutex_;

39 40 41 42 43 44 45
  DISALLOW_COPY_AND_ASSIGN(TracingCpuProfilerImpl);
};

}  // namespace internal
}  // namespace v8

#endif  // V8_PROFILER_TRACING_CPU_PROFILER_H