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

Unified Diff: base/profiler/scoped_tracker.h

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « base/process/process_metrics.h ('k') | base/profiler/scoped_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/profiler/scoped_tracker.h
diff --git a/base/profiler/scoped_tracker.h b/base/profiler/scoped_tracker.h
index f83654e1bd48e55fa7ddd3f88837871dd4eff2c7..23e2f07b61f750897b366dad780f837e2d7cbfdd 100644
--- a/base/profiler/scoped_tracker.h
+++ b/base/profiler/scoped_tracker.h
@@ -10,6 +10,7 @@
// found using profiler data.
#include "base/base_export.h"
+#include "base/bind.h"
#include "base/callback_forward.h"
#include "base/location.h"
#include "base/profiler/scoped_profile.h"
@@ -47,10 +48,24 @@ class BASE_EXPORT ScopedTracker {
// many possible callbacks, but they come from a relatively small number of
// places. We can instrument these few places and at least know which one
// passes the janky callback.
- static base::Closure TrackCallback(const Location& location,
- const base::Closure& callback);
+ template <typename P1>
+ static base::Callback<void(P1)> TrackCallback(
+ const Location& location,
+ const base::Callback<void(P1)>& callback) {
+ return base::Bind(&ScopedTracker::ExecuteAndTrackCallback<P1>, location,
+ callback);
+ }
private:
+ // Executes |callback|, augmenting it with provided |location|.
+ template <typename P1>
+ static void ExecuteAndTrackCallback(const Location& location,
+ const base::Callback<void(P1)>& callback,
+ P1 p1) {
+ ScopedTracker tracking_profile(location);
+ callback.Run(p1);
+ }
+
const ScopedProfile scoped_profile_;
DISALLOW_COPY_AND_ASSIGN(ScopedTracker);
« no previous file with comments | « base/process/process_metrics.h ('k') | base/profiler/scoped_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698