• 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 <memory>
9 
10 #include "include/v8-platform.h"
11 #include "src/base/atomic-utils.h"
12 #include "src/base/macros.h"
13 #include "src/base/platform/mutex.h"
14 
15 namespace v8 {
16 namespace internal {
17 
18 class CpuProfiler;
19 class Isolate;
20 
21 class TracingCpuProfilerImpl final
22     : private v8::TracingController::TraceStateObserver {
23  public:
24   explicit TracingCpuProfilerImpl(Isolate*);
25   ~TracingCpuProfilerImpl() override;
26   TracingCpuProfilerImpl(const TracingCpuProfilerImpl&) = delete;
27   TracingCpuProfilerImpl& operator=(const TracingCpuProfilerImpl&) = delete;
28 
29   // v8::TracingController::TraceStateObserver
30   void OnTraceEnabled() final;
31   void OnTraceDisabled() final;
32 
33  private:
34   void StartProfiling();
35   void StopProfiling();
36 
37   Isolate* isolate_;
38   std::unique_ptr<CpuProfiler> profiler_;
39   bool profiling_enabled_;
40   base::Mutex mutex_;
41 };
42 
43 }  // namespace internal
44 }  // namespace v8
45 
46 #endif  // V8_PROFILER_TRACING_CPU_PROFILER_H_
47