| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_DEVTOOLS_V8_SAMPLING_PROFILER_H_ | 5 #ifndef CONTENT_RENDERER_DEVTOOLS_V8_SAMPLING_PROFILER_H_ |
| 6 #define CONTENT_RENDERER_DEVTOOLS_V8_SAMPLING_PROFILER_H_ | 6 #define CONTENT_RENDERER_DEVTOOLS_V8_SAMPLING_PROFILER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 11 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 12 #include "base/trace_event/trace_log.h" | 13 #include "base/trace_event/trace_log.h" |
| 13 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 | 17 |
| 17 class Sampler; | 18 class Sampler; |
| 18 class V8SamplingThread; | 19 class V8SamplingThread; |
| 19 | 20 |
| 20 // The class monitors enablement of V8 CPU profiler and | 21 // The class monitors enablement of V8 CPU profiler and |
| 21 // spawns a sampling thread when needed. | 22 // spawns a sampling thread when needed. |
| 22 class CONTENT_EXPORT V8SamplingProfiler final | 23 class CONTENT_EXPORT V8SamplingProfiler final |
| 23 : public base::trace_event::TraceLog::EnabledStateObserver { | 24 : public base::trace_event::TraceLog::EnabledStateObserver { |
| 24 public: | 25 public: |
| 25 explicit V8SamplingProfiler(bool underTest = false); | 26 explicit V8SamplingProfiler(bool underTest = false); |
| 26 ~V8SamplingProfiler() override; | 27 ~V8SamplingProfiler() override; |
| 27 | 28 |
| 28 // Implementation of TraceLog::EnabledStateObserver | 29 // Implementation of TraceLog::EnabledStateObserver |
| 29 void OnTraceLogEnabled() override; | 30 void OnTraceLogEnabled() override; |
| 30 void OnTraceLogDisabled() override; | 31 void OnTraceLogDisabled() override; |
| 31 | 32 |
| 32 void EnableSamplingEventForTesting(int code_added_events, int sample_events); | 33 void EnableSamplingEventForTesting(int code_added_events, int sample_events); |
| 33 void WaitSamplingEventForTesting(); | 34 void WaitSamplingEventForTesting(); |
| 34 | 35 |
| 35 private: | 36 private: |
| 36 void StartSamplingThread(); | 37 void StartSamplingThread(); |
| 37 void StopSamplingThread(); | 38 void StopSamplingThread(); |
| 38 | 39 |
| 39 scoped_ptr<base::WaitableEvent> waitable_event_for_testing_; | 40 std::unique_ptr<base::WaitableEvent> waitable_event_for_testing_; |
| 40 scoped_ptr<V8SamplingThread> sampling_thread_; | 41 std::unique_ptr<V8SamplingThread> sampling_thread_; |
| 41 scoped_ptr<Sampler> render_thread_sampler_; | 42 std::unique_ptr<Sampler> render_thread_sampler_; |
| 42 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 43 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 43 | 44 |
| 44 DISALLOW_COPY_AND_ASSIGN(V8SamplingProfiler); | 45 DISALLOW_COPY_AND_ASSIGN(V8SamplingProfiler); |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 } // namespace content | 48 } // namespace content |
| 48 | 49 |
| 49 #endif // CONTENT_RENDERER_DEVTOOLS_V8_SAMPLING_PROFILER_H_ | 50 #endif // CONTENT_RENDERER_DEVTOOLS_V8_SAMPLING_PROFILER_H_ |
| OLD | NEW |