Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1088)

Unified Diff: base/profiler/stack_sampling_profiler.h

Issue 2680703004: Wait for sampling to complete before destructing. (Closed)
Patch Set: cleanup, comments, and fixes Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/profiler/stack_sampling_profiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/profiler/stack_sampling_profiler.h
diff --git a/base/profiler/stack_sampling_profiler.h b/base/profiler/stack_sampling_profiler.h
index 9489fd0bc128a16cd93707228f72c82b1c462a77..d33ee2525ce0472f7442d908526a086656947ee2 100644
--- a/base/profiler/stack_sampling_profiler.h
+++ b/base/profiler/stack_sampling_profiler.h
@@ -25,12 +25,19 @@ namespace base {
class NativeStackSampler;
class NativeStackSamplerTestDelegate;
+class WaitableEvent;
// StackSamplingProfiler periodically stops a thread to sample its stack, for
// the purpose of collecting information about which code paths are
// executing. This information is used in aggregate by UMA to identify hot
// and/or janky code paths.
//
+// IMPORTANT: Only threads guaranteed to live beyond the lifetime of the
+// profiler object can be safely sampled. Sampling the activity of the current
+// thread within the scope of this object is safe, but sampling any other
+// thread could cause Bad Things(tm) to occur should that thread exit before
+// sampling is complete. USE WITH CAUTION!
+//
// Sample StackSamplingProfiler usage:
//
// // Create and customize params as desired.
@@ -205,21 +212,15 @@ class BASE_EXPORT StackSamplingProfiler {
// Stops any profiling currently taking place before destroying the profiler.
~StackSamplingProfiler();
- // The fire-and-forget interface: starts a profiler and allows it to complete
- // without the caller needing to manage the profiler lifetime. May be invoked
- // from any thread, but requires that the calling thread has a message loop.
- static void StartAndRunAsync(PlatformThreadId thread_id,
- const SamplingParams& params,
- const CompletedCallback& callback);
-
// Initializes the profiler and starts sampling.
void Start();
// Stops the profiler and any ongoing sampling. Calling this function is
// optional; if not invoked profiling terminates when all the profiling bursts
// specified in the SamplingParams are completed or the profiler is destroyed,
- // whichever occurs first.
- void Stop();
+ // whichever occurs first. If |done| is not null, a signal will be sent to it
+ // once the sampling has stopped and the callback completed.
+ void Stop(WaitableEvent* done);
// Stops all active profiles and cleans up any resources in anticipation of
// a shutdown of the current process.
« no previous file with comments | « no previous file | base/profiler/stack_sampling_profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698