diff options
-rw-r--r-- | base/base_switches.cc | 8 | ||||
-rw-r--r-- | base/base_switches.h | 4 | ||||
-rw-r--r-- | base/tracked_objects.cc | 26 | ||||
-rw-r--r-- | content/browser/android/content_startup_flags.cc | 7 | ||||
-rw-r--r-- | content/browser/renderer_host/render_process_host_impl.cc | 1 |
5 files changed, 44 insertions, 2 deletions
diff --git a/base/base_switches.cc b/base/base_switches.cc index 526633c..91e401c 100644 --- a/base/base_switches.cc +++ b/base/base_switches.cc @@ -54,6 +54,14 @@ const char kWaitForDebugger[] = "wait-for-debugger"; // Sends a pretty-printed version of tracing info to the console. const char kTraceToConsole[] = "trace-to-console"; +// Configure whether chrome://profiler will contain timing information. This +// option is enabled by default. A value of "0" will disable profiler timing, +// while all other values will enable it. +const char kProfilerTiming[] = "profiler-timing"; +// Value of the --profiler-timing flag that will disable timing information for +// chrome://profiler. +const char kProfilerTimingDisabledValue[] = "0"; + #if defined(OS_POSIX) // Used for turning on Breakpad crash reporting in a debug environment where // crash reporting is typically compiled but disabled. diff --git a/base/base_switches.h b/base/base_switches.h index b2bf7ab..b679e6d 100644 --- a/base/base_switches.h +++ b/base/base_switches.h @@ -17,11 +17,13 @@ extern const char kEnableCrashReporter[]; extern const char kEnableDCHECK[]; extern const char kFullMemoryCrashReport[]; extern const char kNoErrorDialogs[]; +extern const char kProfilerTiming[]; +extern const char kProfilerTimingDisabledValue[]; extern const char kTestChildProcess[]; +extern const char kTraceToConsole[]; extern const char kV[]; extern const char kVModule[]; extern const char kWaitForDebugger[]; -extern const char kTraceToConsole[]; #if defined(OS_POSIX) extern const char kEnableCrashReporterForTesting[]; diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc index 0847d5f..72049e4 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. } diff --git a/content/browser/android/content_startup_flags.cc b/content/browser/android/content_startup_flags.cc index 737fd7c..7d95034 100644 --- a/content/browser/android/content_startup_flags.cc +++ b/content/browser/android/content_startup_flags.cc @@ -4,6 +4,7 @@ #include "content/browser/android/content_startup_flags.h" +#include "base/base_switches.h" #include "base/command_line.h" #include "base/logging.h" #include "base/strings/string_number_conversions.h" @@ -89,6 +90,12 @@ void SetContentCommandLineFlags(int max_render_process_count, parsed_command_line->AppendSwitchNative( switches::kRegisterPepperPlugins, plugin_descriptor); } + + // Disable profiler timing by default. + if (!parsed_command_line->HasSwitch(switches::kProfilerTiming)) { + parsed_command_line->AppendSwitchASCII( + switches::kProfilerTiming, switches::kProfilerTimingDisabledValue); + } } } // namespace content diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 5018c54..231b59d 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -1037,6 +1037,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( switches::kNoReferrers, switches::kNoSandbox, switches::kPpapiInProcess, + switches::kProfilerTiming, switches::kRegisterPepperPlugins, switches::kRendererAssertTest, switches::kRendererStartupDialog, |