Chromium Code Reviews| Index: base/profiler/stack_sampling_profiler.cc |
| diff --git a/base/profiler/stack_sampling_profiler.cc b/base/profiler/stack_sampling_profiler.cc |
| index 0263a9f81af95b8d605e09c685d9fd21e9489bcb..3515d7732970d4eb20bf5e8447e0d469aca6113d 100644 |
| --- a/base/profiler/stack_sampling_profiler.cc |
| +++ b/base/profiler/stack_sampling_profiler.cc |
| @@ -250,6 +250,9 @@ class StackSamplingProfiler::SamplingThread : public Thread { |
| // Thread: |
| void CleanUp() override; |
| + // A stack-buffer used by the native sampler for its work. |
|
Mike Wittman
2017/05/01 20:28:04
Mention that this is shared across all active samp
bcwhite
2017/05/08 14:00:59
Done.
|
| + std::unique_ptr<NativeStackSampler::StackBuffer> native_buffer_; |
|
Mike Wittman
2017/05/01 20:28:03
stack_buffer_ is probably a better name.
bcwhite
2017/05/08 14:00:59
Done.
|
| + |
| // A map of IDs to collection contexts. Because this class is a singleton |
| // that is never destroyed, context objects will never be destructed except |
| // by explicit action. Thus, it's acceptable to pass unretained pointers |
| @@ -421,6 +424,9 @@ StackSamplingProfiler::SamplingThread::GetOrCreateTaskRunnerForAdd() { |
| Stop(); |
| } |
| + DCHECK(!native_buffer_); |
| + native_buffer_ = NativeStackSampler::CreateStackBuffer(); |
| + |
| // The thread is not running. Start it and get associated runner. The task- |
| // runner has to be saved for future use because though it can be used from |
| // any thread, it can be acquired via task_runner() only on the created |
| @@ -517,12 +523,13 @@ void StackSamplingProfiler::SamplingThread::RecordSample( |
| // Record a single sample. |
| profile.samples.push_back(Sample()); |
| - collection->native_sampler->RecordStackSample(&profile.samples.back()); |
| + collection->native_sampler->RecordStackSample(native_buffer_.get(), |
| + &profile.samples.back()); |
| // If this is the last sample of a burst, record the total time. |
| if (collection->sample == collection->params.samples_per_burst - 1) { |
| profile.profile_duration = Time::Now() - collection->profile_start_time; |
| - collection->native_sampler->ProfileRecordingStopped(); |
| + collection->native_sampler->ProfileRecordingStopped(native_buffer_.get()); |
| } |
| } |
| @@ -647,6 +654,7 @@ void StackSamplingProfiler::SamplingThread::ShutdownTask(int add_events) { |
| // confusion. |
| thread_execution_state_ = EXITING; |
| thread_execution_state_task_runner_ = nullptr; |
| + native_buffer_.reset(); |
| } |
| bool StackSamplingProfiler::SamplingThread::UpdateNextSampleTime( |