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_STACK_SAMPLING_PROFILER_H_ | 5 #ifndef BASE_PROFILER_STACK_SAMPLING_PROFILER_H_ |
6 #define BASE_PROFILER_STACK_SAMPLING_PROFILER_H_ | 6 #define BASE_PROFILER_STACK_SAMPLING_PROFILER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 // was started between when the idle-shutdown was initiated and when it | 208 // was started between when the idle-shutdown was initiated and when it |
209 // runs. | 209 // runs. |
210 static void PerformSamplingThreadIdleShutdown( | 210 static void PerformSamplingThreadIdleShutdown( |
211 bool simulate_intervening_start); | 211 bool simulate_intervening_start); |
212 }; | 212 }; |
213 | 213 |
214 // The callback type used to collect completed profiles. The passed |profiles| | 214 // The callback type used to collect completed profiles. The passed |profiles| |
215 // are move-only. Other threads, including the UI thread, may block on | 215 // are move-only. Other threads, including the UI thread, may block on |
216 // callback completion so this should run as quickly as possible. | 216 // callback completion so this should run as quickly as possible. |
217 // | 217 // |
| 218 // After collection completion, the callback may instruct the profiler to do |
| 219 // additional collection(s) by modifying the SamplingParams argument and |
| 220 // returning true to indicate collection should be started again. |
| 221 // |
218 // IMPORTANT NOTE: The callback is invoked on a thread the profiler | 222 // IMPORTANT NOTE: The callback is invoked on a thread the profiler |
219 // constructs, rather than on the thread used to construct the profiler and | 223 // constructs, rather than on the thread used to construct the profiler and |
220 // set the callback, and thus the callback must be callable on any thread. For | 224 // set the callback, and thus the callback must be callable on any thread. For |
221 // threads with message loops that create StackSamplingProfilers, posting a | 225 // threads with message loops that create StackSamplingProfilers, posting a |
222 // task to the message loop with the moved (i.e. std::move) profiles is the | 226 // task to the message loop with the moved (i.e. std::move) profiles is the |
223 // thread-safe callback implementation. | 227 // thread-safe callback implementation. |
224 using CompletedCallback = Callback<void(CallStackProfiles)>; | 228 using CompletedCallback = Callback<bool(CallStackProfiles, SamplingParams*)>; |
225 | 229 |
226 // Creates a profiler for the CURRENT thread that sends completed profiles | 230 // Creates a profiler for the CURRENT thread that sends completed profiles |
227 // to |callback|. An optional |test_delegate| can be supplied by tests. | 231 // to |callback|. An optional |test_delegate| can be supplied by tests. |
228 // The caller must ensure that this object gets destroyed before the current | 232 // The caller must ensure that this object gets destroyed before the current |
229 // thread exits. | 233 // thread exits. |
230 StackSamplingProfiler( | 234 StackSamplingProfiler( |
231 const SamplingParams& params, | 235 const SamplingParams& params, |
232 const CompletedCallback& callback, | 236 const CompletedCallback& callback, |
233 NativeStackSamplerTestDelegate* test_delegate = nullptr); | 237 NativeStackSamplerTestDelegate* test_delegate = nullptr); |
234 | 238 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 BASE_EXPORT bool operator<(const StackSamplingProfiler::Sample& a, | 324 BASE_EXPORT bool operator<(const StackSamplingProfiler::Sample& a, |
321 const StackSamplingProfiler::Sample& b); | 325 const StackSamplingProfiler::Sample& b); |
322 BASE_EXPORT bool operator==(const StackSamplingProfiler::Frame& a, | 326 BASE_EXPORT bool operator==(const StackSamplingProfiler::Frame& a, |
323 const StackSamplingProfiler::Frame& b); | 327 const StackSamplingProfiler::Frame& b); |
324 BASE_EXPORT bool operator<(const StackSamplingProfiler::Frame& a, | 328 BASE_EXPORT bool operator<(const StackSamplingProfiler::Frame& a, |
325 const StackSamplingProfiler::Frame& b); | 329 const StackSamplingProfiler::Frame& b); |
326 | 330 |
327 } // namespace base | 331 } // namespace base |
328 | 332 |
329 #endif // BASE_PROFILER_STACK_SAMPLING_PROFILER_H_ | 333 #endif // BASE_PROFILER_STACK_SAMPLING_PROFILER_H_ |
OLD | NEW |