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

Unified Diff: base/profiler/tracked_time.cc

Issue 99343002: Disable timing from chrome://profiler on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compilation 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
Index: base/profiler/tracked_time.cc
diff --git a/base/profiler/tracked_time.cc b/base/profiler/tracked_time.cc
index 7791c3adc6b8580f09ccffd100bc6a2dd241c81f..6de9945cc21eecd29b592911e5d24d8db07ba7fa 100644
--- a/base/profiler/tracked_time.cc
+++ b/base/profiler/tracked_time.cc
@@ -4,12 +4,29 @@
#include "base/profiler/tracked_time.h"
+#include "base/base_switches.h"
+#include "base/command_line.h"
#include "build/build_config.h"
#if defined(OS_WIN)
#include <mmsystem.h> // Declare timeGetTime()... after including build_config.
#endif
+namespace {
+inline bool IsProfilerTimingDisabled() {
jar (doing other things) 2013/12/02 19:01:50 Nit: code is IMO always much more confusing when n
qsr 2013/12/03 11:33:44 Done. But I didn't change the static variable, as
+ // This initialization is not thread safe. In particular, some early calls
+ // might see |timing_disabled| being false, even if this is incorrect. This is
+ // OK, as the timing is only disabled for performance reasons, and having a
+ // few calls to TimeTicks::Now() is acceptable, while needing to use a lock or
+ // a memory barrier would be more costly.
+ static bool timing_disabled = CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableProfilerTiming) &&
+ !CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableProfilerTiming);
+ return timing_disabled;
+}
+} // namespace
+
namespace tracked_objects {
Duration::Duration() : ms_(0) {}
@@ -51,6 +68,8 @@ TrackedTime::TrackedTime(const base::TimeTicks& time)
// static
TrackedTime TrackedTime::Now() {
+ if (IsProfilerTimingDisabled())
+ return TrackedTime();
#if defined(OS_WIN)
// Use lock-free accessor to 32 bit time.
// Note that TimeTicks::Now() is built on this, so we have "compatible"

Powered by Google App Engine
This is Rietveld 408576698