| Index: base/profiler/scoped_tracker.cc
|
| diff --git a/base/profiler/scoped_tracker.cc b/base/profiler/scoped_tracker.cc
|
| index 5cd0bcae34984d1d99017ccb699d7dbe48409439..1d4f0bfcafd33bf9e3af19644655bded3ad2fef4 100644
|
| --- a/base/profiler/scoped_tracker.cc
|
| +++ b/base/profiler/scoped_tracker.cc
|
| @@ -4,12 +4,21 @@
|
|
|
| #include "base/profiler/scoped_tracker.h"
|
|
|
| +#include "base/bind.h"
|
| +
|
| namespace tracked_objects {
|
|
|
| namespace {
|
|
|
| ScopedProfile::Mode g_scoped_profile_mode = ScopedProfile::DISABLED;
|
|
|
| +// Executes |callback|, augmenting it with provided |location|.
|
| +void ExecuteAndTrackCallback(const Location& location,
|
| + const base::Closure& callback) {
|
| + ScopedProfile tracking_profile(location);
|
| + callback.Run();
|
| +}
|
| +
|
| } // namespace
|
|
|
| // static
|
| @@ -17,6 +26,15 @@ void ScopedTracker::Enable() {
|
| g_scoped_profile_mode = ScopedProfile::ENABLED;
|
| }
|
|
|
| +// static
|
| +base::Closure ScopedTracker::TrackCallback(const Location& location,
|
| + const base::Closure& callback) {
|
| + if (g_scoped_profile_mode != ScopedProfile::ENABLED)
|
| + return callback;
|
| +
|
| + return base::Bind(ExecuteAndTrackCallback, location, callback);
|
| +}
|
| +
|
| ScopedTracker::ScopedTracker(const Location& location)
|
| : scoped_profile_(location, g_scoped_profile_mode) {
|
| }
|
|
|