summaryrefslogtreecommitdiffstats
path: root/base/profiler
diff options
context:
space:
mode:
authorvadimt <vadimt@chromium.org>2014-11-21 13:16:39 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-21 21:17:06 +0000
commit6452bca69783b5041329a88a012762ebc10f7a9c (patch)
treefdaeb600c5358e6c8c59acd4698671c3d064ca46 /base/profiler
parent4b9e0b4c46d1027361ec0dcbc81033dea7de3ce2 (diff)
downloadchromium_src-6452bca69783b5041329a88a012762ebc10f7a9c.zip
chromium_src-6452bca69783b5041329a88a012762ebc10f7a9c.tar.gz
chromium_src-6452bca69783b5041329a88a012762ebc10f7a9c.tar.bz2
Instrumenting callbacks to InFlightBackendIO.
Earlier instrumentations showed that the jank for this bug comes from one of completion callbacks. This code wraps passed callbacks with instrumentations, so that we know which operation's callback causes jank. This CL reimplements callback wrapping, which was originally implemented in a wrong way. BUG=422516 Review URL: https://codereview.chromium.org/745853002 Cr-Commit-Position: refs/heads/master@{#305281}
Diffstat (limited to 'base/profiler')
-rw-r--r--base/profiler/scoped_tracker.cc16
-rw-r--r--base/profiler/scoped_tracker.h19
2 files changed, 17 insertions, 18 deletions
diff --git a/base/profiler/scoped_tracker.cc b/base/profiler/scoped_tracker.cc
index 26b17c0..d15b7de 100644
--- a/base/profiler/scoped_tracker.cc
+++ b/base/profiler/scoped_tracker.cc
@@ -12,13 +12,6 @@ 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, ScopedProfile::ENABLED);
- callback.Run();
-}
-
} // namespace
// static
@@ -26,15 +19,6 @@ 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) {
}
diff --git a/base/profiler/scoped_tracker.h b/base/profiler/scoped_tracker.h
index f83654e..23e2f07 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);