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

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: Follow review 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..def7f2ebdf8b2d56e109b29a8f0e1a216ee4040e 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,27 @@ const ThreadData::Status kInitialStartupState =
// problem with its presence).
static const bool kAllowAlternateTimeSourceHandling = true;
+// Control whether to collect timing information.
+enum ProfilerTimingState {
Mark Mentovai 2013/12/09 14:18:32 You can move this whole enum definition and variab
qsr 2013/12/09 14:48:32 Done.
+ UNDEFINED_TIMING,
+ ENABLED_TIMING,
+ DISABLED_TIMING,
+} g_timing_enabled = UNDEFINED_TIMING;
+
+inline bool IsProfilerTimingEnabled() {
+ // This initialization is not thread-safe, so the value of |g_timing_enabled|
+ // can be computed multiple time. This is not an issue, as the computed value
Mark Mentovai 2013/12/09 14:18:32 time→times
qsr 2013/12/09 14:48:32 Done.
+ // will always be the same, and is side-effect free.
+ if (g_timing_enabled == UNDEFINED_TIMING) {
+ g_timing_enabled = (CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kProfilerTiming) ==
+ switches::kProfilerTimingDisabledValue)
+ ? DISABLED_TIMING
+ : ENABLED_TIMING;
+ }
+ return g_timing_enabled == ENABLED_TIMING;
+}
+
} // namespace
//------------------------------------------------------------------------------
@@ -754,7 +777,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