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

Side by Side Diff: base/profiler/scoped_tracker.cc

Issue 723343002: Update from https://crrev.com/304121 (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 unified diff | Download patch
« no previous file with comments | « base/profiler/scoped_profile.cc ('k') | base/test/launcher/unit_test_launcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "base/profiler/scoped_tracker.h" 5 #include "base/profiler/scoped_tracker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 8
9 namespace tracked_objects { 9 namespace tracked_objects {
10 10
11 namespace { 11 namespace {
12 12
13 ScopedProfile::Mode g_scoped_profile_mode = ScopedProfile::DISABLED; 13 ScopedProfile::Mode g_scoped_profile_mode = ScopedProfile::DISABLED;
14 14
15 // Executes |callback|, augmenting it with provided |location|. 15 // Executes |callback|, augmenting it with provided |location|.
16 void ExecuteAndTrackCallback(const Location& location, 16 void ExecuteAndTrackCallback(const Location& location,
17 const base::Closure& callback) { 17 const base::Closure& callback) {
18 ScopedProfile tracking_profile(location); 18 ScopedProfile tracking_profile(location, ScopedProfile::ENABLED);
19 callback.Run(); 19 callback.Run();
20 } 20 }
21 21
22 } // namespace 22 } // namespace
23 23
24 // static 24 // static
25 void ScopedTracker::Enable() { 25 void ScopedTracker::Enable() {
26 g_scoped_profile_mode = ScopedProfile::ENABLED; 26 g_scoped_profile_mode = ScopedProfile::ENABLED;
27 } 27 }
28 28
29 // static 29 // static
30 base::Closure ScopedTracker::TrackCallback(const Location& location, 30 base::Closure ScopedTracker::TrackCallback(const Location& location,
31 const base::Closure& callback) { 31 const base::Closure& callback) {
32 if (g_scoped_profile_mode != ScopedProfile::ENABLED) 32 if (g_scoped_profile_mode != ScopedProfile::ENABLED)
33 return callback; 33 return callback;
34 34
35 return base::Bind(ExecuteAndTrackCallback, location, callback); 35 return base::Bind(ExecuteAndTrackCallback, location, callback);
36 } 36 }
37 37
38 ScopedTracker::ScopedTracker(const Location& location) 38 ScopedTracker::ScopedTracker(const Location& location)
39 : scoped_profile_(location, g_scoped_profile_mode) { 39 : scoped_profile_(location, g_scoped_profile_mode) {
40 } 40 }
41 41
42 } // namespace tracked_objects 42 } // namespace tracked_objects
OLDNEW
« no previous file with comments | « base/profiler/scoped_profile.cc ('k') | base/test/launcher/unit_test_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698