Commit 2218a0f9 authored by Xi Cheng's avatar Xi Cheng Committed by Commit Bot

Call ScheduleShutdownIfIdle() from FinishCollection()

This Cl also corrects the indent in FinishCollection().

Bug: 851163
Change-Id: I77b255b2f9191979bca02f5453d54fc8bd1e36ee
Reviewed-on: https://chromium-review.googlesource.com/1101406Reviewed-by: default avatarMike Wittman <wittman@chromium.org>
Commit-Queue: Xi Cheng <chengx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567403}
parent 7c777876
......@@ -488,24 +488,26 @@ void StackSamplingProfiler::SamplingThread::FinishCollection(
DCHECK_EQ(GetThreadId(), PlatformThread::CurrentId());
DCHECK_EQ(0u, active_collections_.count(collection->collection_id));
collection->profile.profile_duration = Time::Now() -
collection->profile_start_time +
collection->params.sampling_interval;
collection->native_sampler->ProfileRecordingStopped();
collection->profile.profile_duration = Time::Now() -
collection->profile_start_time +
collection->params.sampling_interval;
collection->native_sampler->ProfileRecordingStopped();
// Extract some information so callback and event-signalling can still be
// done after the collection has been removed from the list of "active"
// ones. This allows the the controlling object (and tests using it) to be
// confident that collection is fully finished when those things occur.
const CompletedCallback callback = collection->callback;
CallStackProfile profile = std::move(collection->profile);
WaitableEvent* finished = collection->finished;
// Extract some information so callback and event-signalling can still be
// done after the collection has been removed from the list of "active"
// ones. This allows the the controlling object (and tests using it) to be
// confident that collection is fully finished when those things occur.
const CompletedCallback callback = collection->callback;
CallStackProfile profile = std::move(collection->profile);
WaitableEvent* finished = collection->finished;
// Run the associated callback, passing the collected profile.
callback.Run(std::move(profile));
// Run the associated callback, passing the collected profile.
callback.Run(std::move(profile));
// Signal that this collection is finished.
finished->Signal();
// Signal that this collection is finished.
finished->Signal();
ScheduleShutdownIfIdle();
}
void StackSamplingProfiler::SamplingThread::ScheduleShutdownIfIdle() {
......@@ -567,7 +569,6 @@ void StackSamplingProfiler::SamplingThread::RemoveCollectionTask(
DCHECK_EQ(1U, count);
FinishCollection(collection.get());
ScheduleShutdownIfIdle();
}
void StackSamplingProfiler::SamplingThread::RecordSampleTask(
......@@ -621,7 +622,6 @@ void StackSamplingProfiler::SamplingThread::RecordSampleTask(
// All capturing has completed so finish the collection.
FinishCollection(collection);
ScheduleShutdownIfIdle();
}
void StackSamplingProfiler::SamplingThread::ShutdownTask(int add_events) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment