• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_PROFILER_TRACING_CPU_PROFILER_H_
6 #define V8_PROFILER_TRACING_CPU_PROFILER_H_
7 
8 #include "include/v8-platform.h"
9 #include "src/base/atomic-utils.h"
10 #include "src/base/macros.h"
11 #include "src/base/platform/mutex.h"
12 
13 namespace v8 {
14 namespace internal {
15 
16 class CpuProfiler;
17 class Isolate;
18 
19 class TracingCpuProfilerImpl final
20     : private v8::TracingController::TraceStateObserver {
21  public:
22   explicit TracingCpuProfilerImpl(Isolate*);
23   ~TracingCpuProfilerImpl();
24 
25   // v8::TracingController::TraceStateObserver
26   void OnTraceEnabled() final;
27   void OnTraceDisabled() final;
28 
29  private:
30   void StartProfiling();
31   void StopProfiling();
32 
33   Isolate* isolate_;
34   std::unique_ptr<CpuProfiler> profiler_;
35   bool profiling_enabled_;
36   base::Mutex mutex_;
37 
38   DISALLOW_COPY_AND_ASSIGN(TracingCpuProfilerImpl);
39 };
40 
41 }  // namespace internal
42 }  // namespace v8
43 
44 #endif  // V8_PROFILER_TRACING_CPU_PROFILER_H_
45