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

Unified Diff: base/tracked_objects.cc

Issue 706203003: Update from https://crrev.com/303153 (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/tracked_objects.h ('k') | base/win/win_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/tracked_objects.cc
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc
index 4fe8851297254fd18228282d7ae8c4ff08592a87..c69fada531ca90dbcb730a441f287bba3548bced 100644
--- a/base/tracked_objects.cc
+++ b/base/tracked_objects.cc
@@ -54,18 +54,27 @@ const ThreadData::Status kInitialStartupState =
// problem with its presence).
static const bool kAllowAlternateTimeSourceHandling = true;
+// Possible states of the profiler timing enabledness.
+enum {
+ UNDEFINED_TIMING,
+ ENABLED_TIMING,
+ DISABLED_TIMING,
+};
+
+// State of the profiler timing enabledness.
+base::subtle::Atomic32 g_profiler_timing_enabled = UNDEFINED_TIMING;
+
+// Returns whether profiler timing is enabled. The default is true, but this may
+// be overridden by a command-line flag. Some platforms may programmatically set
+// this command-line flag to the "off" value if it's not specified.
+// This in turn can be overridden by explicitly calling
+// ThreadData::EnableProfilerTiming, say, based on a field trial.
inline bool IsProfilerTimingEnabled() {
- enum {
- UNDEFINED_TIMING,
- ENABLED_TIMING,
- DISABLED_TIMING,
- };
- static base::subtle::Atomic32 timing_enabled = UNDEFINED_TIMING;
- // Reading |timing_enabled| is done without barrier because multiple
- // initialization is not an issue while the barrier can be relatively costly
- // given that this method is sometimes called in a tight loop.
+ // Reading |g_profiler_timing_enabled| is done without barrier because
+ // multiple initialization is not an issue while the barrier can be relatively
+ // costly given that this method is sometimes called in a tight loop.
base::subtle::Atomic32 current_timing_enabled =
- base::subtle::NoBarrier_Load(&timing_enabled);
+ base::subtle::NoBarrier_Load(&g_profiler_timing_enabled);
if (current_timing_enabled == UNDEFINED_TIMING) {
if (!CommandLine::InitializedForCurrentProcess())
return true;
@@ -75,7 +84,8 @@ inline bool IsProfilerTimingEnabled() {
switches::kProfilerTimingDisabledValue)
? DISABLED_TIMING
: ENABLED_TIMING;
- base::subtle::NoBarrier_Store(&timing_enabled, current_timing_enabled);
+ base::subtle::NoBarrier_Store(&g_profiler_timing_enabled,
+ current_timing_enabled);
}
return current_timing_enabled == ENABLED_TIMING;
}
@@ -775,6 +785,11 @@ void ThreadData::SetAlternateTimeSource(NowFunction* now_function) {
}
// static
+void ThreadData::EnableProfilerTiming() {
+ base::subtle::NoBarrier_Store(&g_profiler_timing_enabled, ENABLED_TIMING);
+}
+
+// static
TrackedTime ThreadData::Now() {
if (kAllowAlternateTimeSourceHandling && now_function_)
return TrackedTime::FromMilliseconds((*now_function_)());
« no previous file with comments | « base/tracked_objects.h ('k') | base/win/win_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698