Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 BASE_PROFILER_NATIVE_STACK_SAMPLER_H_ | 5 #ifndef BASE_PROFILER_NATIVE_STACK_SAMPLER_H_ |
| 6 #define BASE_PROFILER_NATIVE_STACK_SAMPLER_H_ | 6 #define BASE_PROFILER_NATIVE_STACK_SAMPLER_H_ |
| 7 | 7 |
| 8 #include "base/base_export.h" | |
| 8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/profiler/stack_sampling_profiler.h" | 10 #include "base/profiler/stack_sampling_profiler.h" |
| 10 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
| 11 | 12 |
| 12 namespace base { | 13 namespace base { |
| 13 | 14 |
| 15 class NativeStackSamplerTestDelegate; | |
| 16 | |
| 14 // NativeStackSampler is an implementation detail of StackSamplingProfiler. It | 17 // NativeStackSampler is an implementation detail of StackSamplingProfiler. It |
| 15 // abstracts the native implementation required to record a stack sample for a | 18 // abstracts the native implementation required to record a stack sample for a |
| 16 // given thread. | 19 // given thread. |
| 17 class NativeStackSampler { | 20 class NativeStackSampler { |
| 18 public: | 21 public: |
| 19 virtual ~NativeStackSampler(); | 22 virtual ~NativeStackSampler(); |
| 20 | 23 |
| 21 // Creates a stack sampler that records samples for |thread_handle|. Returns | 24 // Creates a stack sampler that records samples for |thread_handle|. Returns |
| 22 // null if this platform does not support stack sampling. | 25 // null if this platform does not support stack sampling. |
| 23 static scoped_ptr<NativeStackSampler> Create(PlatformThreadId thread_id); | 26 static scoped_ptr<NativeStackSampler> Create( |
| 27 PlatformThreadId thread_id, | |
| 28 NativeStackSamplerTestDelegate* test_delegate); | |
| 24 | 29 |
| 25 // The following functions are all called on the SamplingThread (not the | 30 // The following functions are all called on the SamplingThread (not the |
| 26 // thread being sampled). | 31 // thread being sampled). |
| 27 | 32 |
| 28 // Notifies the sampler that we're starting to record a new profile. Modules | 33 // Notifies the sampler that we're starting to record a new profile. Modules |
| 29 // shared across samples in the profile should be recorded in |modules|. | 34 // shared across samples in the profile should be recorded in |modules|. |
| 30 virtual void ProfileRecordingStarting( | 35 virtual void ProfileRecordingStarting( |
| 31 std::vector<StackSamplingProfiler::Module>* modules) = 0; | 36 std::vector<StackSamplingProfiler::Module>* modules) = 0; |
| 32 | 37 |
| 33 // Records a stack sample to |sample|. | 38 // Records a stack sample to |sample|. |
| 34 virtual void RecordStackSample(StackSamplingProfiler::Sample* sample) = 0; | 39 virtual void RecordStackSample(StackSamplingProfiler::Sample* sample) = 0; |
| 35 | 40 |
| 36 // Notifies the sampler that we've stopped recording the current | 41 // Notifies the sampler that we've stopped recording the current |
| 37 // profile. | 42 // profile. |
| 38 virtual void ProfileRecordingStopped() = 0; | 43 virtual void ProfileRecordingStopped() = 0; |
| 39 | 44 |
| 40 protected: | 45 protected: |
| 41 NativeStackSampler(); | 46 NativeStackSampler(); |
| 42 | 47 |
| 43 private: | 48 private: |
| 44 DISALLOW_COPY_AND_ASSIGN(NativeStackSampler); | 49 DISALLOW_COPY_AND_ASSIGN(NativeStackSampler); |
| 45 }; | 50 }; |
| 46 | 51 |
| 52 // NativeStackSamplerTestDelegate provides seams for test code to execute during | |
|
brucedawson
2015/10/30 00:15:59
I'm not sure what you mean by 'seams' here, althou
Mike Wittman
2015/10/30 17:08:06
Yes, I believe it's originally from _Working Effec
| |
| 53 // stack collection. | |
| 54 class BASE_EXPORT NativeStackSamplerTestDelegate { | |
| 55 public: | |
| 56 virtual ~NativeStackSamplerTestDelegate(); | |
| 57 | |
| 58 // Called after copying the stack and resuming the target thread, but prior to | |
| 59 // walking the stack. Invoked on the SamplingThread. | |
| 60 virtual void OnPreStackWalk() = 0; | |
| 61 | |
| 62 protected: | |
| 63 NativeStackSamplerTestDelegate(); | |
| 64 | |
| 65 private: | |
| 66 DISALLOW_COPY_AND_ASSIGN(NativeStackSamplerTestDelegate); | |
| 67 }; | |
| 68 | |
| 47 } // namespace base | 69 } // namespace base |
| 48 | 70 |
| 49 #endif // BASE_PROFILER_NATIVE_STACK_SAMPLER_H_ | 71 #endif // BASE_PROFILER_NATIVE_STACK_SAMPLER_H_ |
| 50 | 72 |
| OLD | NEW |