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

Unified Diff: base/tracked_objects.cc

Issue 99343002: Disable timing from chrome://profiler on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix uninitialized command line/ Created 7 years 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/base_switches.cc ('k') | content/browser/android/content_startup_flags.cc » ('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 0847d5f9163622cd65449707775fe7594de9a2b1..72049e4b66a49341ce23751455f98472c9fa1f2a 100644
--- a/base/tracked_objects.cc
+++ b/base/tracked_objects.cc
@@ -7,6 +7,8 @@
#include <limits.h>
#include <stdlib.h>
+#include "base/base_switches.h"
+#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/debug/leak_annotations.h"
#include "base/logging.h"
@@ -51,6 +53,28 @@ const ThreadData::Status kInitialStartupState =
// problem with its presence).
static const bool kAllowAlternateTimeSourceHandling = true;
+inline bool IsProfilerTimingEnabled() {
+ static enum {
+ UNDEFINED_TIMING,
+ ENABLED_TIMING,
+ DISABLED_TIMING,
+ } timing_enabled = UNDEFINED_TIMING;
+ // This initialization is not thread-safe, so the value of |timing_enabled|
+ // can be computed multiple times. This is not an issue, as the computed value
+ // will always be the same, and is side-effect free, while needing to use a
+ // lock or a memory barrier would be more costly.
+ if (timing_enabled == UNDEFINED_TIMING) {
+ if (!CommandLine::InitializedForCurrentProcess())
+ return true;
+ timing_enabled = (CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kProfilerTiming) ==
+ switches::kProfilerTimingDisabledValue)
+ ? DISABLED_TIMING
+ : ENABLED_TIMING;
+ }
+ return timing_enabled == ENABLED_TIMING;
+}
+
} // namespace
//------------------------------------------------------------------------------
@@ -754,7 +778,7 @@ void ThreadData::SetAlternateTimeSource(NowFunction* now_function) {
TrackedTime ThreadData::Now() {
if (kAllowAlternateTimeSourceHandling && now_function_)
return TrackedTime::FromMilliseconds((*now_function_)());
- if (kTrackAllTaskObjects && TrackingStatus())
+ if (kTrackAllTaskObjects && IsProfilerTimingEnabled() && TrackingStatus())
return TrackedTime::Now();
return TrackedTime(); // Super fast when disabled, or not compiled.
}
« no previous file with comments | « base/base_switches.cc ('k') | content/browser/android/content_startup_flags.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698