Home | History | Annotate | Download | only in profiler
      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 "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 namespace v8 {
     15 namespace internal {
     16 
     17 class CpuProfiler;
     18 class Isolate;
     19 
     20 class TracingCpuProfilerImpl final : public TracingCpuProfiler,
     21                                      private v8::Platform::TraceStateObserver {
     22  public:
     23   explicit TracingCpuProfilerImpl(Isolate*);
     24   ~TracingCpuProfilerImpl();
     25 
     26   // v8::Platform::TraceStateObserver
     27   void OnTraceEnabled() final;
     28   void OnTraceDisabled() final;
     29 
     30  private:
     31   void StartProfiling();
     32   void StopProfiling();
     33 
     34   Isolate* isolate_;
     35   std::unique_ptr<CpuProfiler> profiler_;
     36   bool profiling_enabled_;
     37   base::Mutex mutex_;
     38 
     39   DISALLOW_COPY_AND_ASSIGN(TracingCpuProfilerImpl);
     40 };
     41 
     42 }  // namespace internal
     43 }  // namespace v8
     44 
     45 #endif  // V8_PROFILER_TRACING_CPU_PROFILER_H
     46