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 "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/trace_event/trace_event_impl.h" | 10 #include "base/trace_event/trace_event_impl.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 class Sampler; | 15 class Sampler; |
16 class V8SamplingThread; | 16 class V8SamplingThread; |
17 | 17 |
18 // The class monitors enablement of V8 CPU profiler and | 18 // The class monitors enablement of V8 CPU profiler and |
19 // spawns a sampling thread when needed. | 19 // spawns a sampling thread when needed. |
20 class CONTENT_EXPORT V8SamplingProfiler final | 20 class CONTENT_EXPORT V8SamplingProfiler final |
21 : public base::trace_event::TraceLog::EnabledStateObserver { | 21 : public base::trace_event::TraceLog::EnabledStateObserver { |
22 public: | 22 public: |
23 explicit V8SamplingProfiler(bool underTest = false); | 23 explicit V8SamplingProfiler(bool underTest = false); |
24 ~V8SamplingProfiler(); | 24 ~V8SamplingProfiler() override; |
25 | 25 |
26 // Implementation of TraceLog::EnabledStateObserver | 26 // Implementation of TraceLog::EnabledStateObserver |
27 void OnTraceLogEnabled() override; | 27 void OnTraceLogEnabled() override; |
28 void OnTraceLogDisabled() override; | 28 void OnTraceLogDisabled() override; |
29 | 29 |
30 void EnableSamplingEventForTesting(int code_added_events, int sample_events); | 30 void EnableSamplingEventForTesting(int code_added_events, int sample_events); |
31 void WaitSamplingEventForTesting(); | 31 void WaitSamplingEventForTesting(); |
32 | 32 |
33 private: | 33 private: |
34 void StartSamplingThread(); | 34 void StartSamplingThread(); |
35 void StopSamplingThread(); | 35 void StopSamplingThread(); |
36 | 36 |
37 scoped_ptr<base::WaitableEvent> waitable_event_for_testing_; | 37 scoped_ptr<base::WaitableEvent> waitable_event_for_testing_; |
38 scoped_ptr<V8SamplingThread> sampling_thread_; | 38 scoped_ptr<V8SamplingThread> sampling_thread_; |
39 scoped_ptr<Sampler> render_thread_sampler_; | 39 scoped_ptr<Sampler> render_thread_sampler_; |
40 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 40 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
41 | 41 |
42 DISALLOW_COPY_AND_ASSIGN(V8SamplingProfiler); | 42 DISALLOW_COPY_AND_ASSIGN(V8SamplingProfiler); |
43 }; | 43 }; |
44 | 44 |
45 } // namespace content | 45 } // namespace content |
46 | 46 |
47 #endif // CONTENT_RENDERER_DEVTOOLS_V8_SAMPLING_PROFILER_H_ | 47 #endif // CONTENT_RENDERER_DEVTOOLS_V8_SAMPLING_PROFILER_H_ |
OLD | NEW |