Chromium Code Reviews| Index: base/tracked_objects.cc |
| diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc |
| index 0847d5f9163622cd65449707775fe7594de9a2b1..4916c2de0292e2c93858cd12bc0623c711e2baf4 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,25 @@ const ThreadData::Status kInitialStartupState = |
| // problem with its presence). |
| static const bool kAllowAlternateTimeSourceHandling = true; |
| +inline bool IsProfilerTimingEnabled() { |
| + enum { |
|
no sievers
2013/12/09 20:10:23
missing static
qsr
2013/12/11 09:11:21
Done.
|
| + UNDEFINED_TIMING, |
| + ENABLED_TIMING, |
| + DISABLED_TIMING, |
| + } g_timing_enabled = UNDEFINED_TIMING; |
|
jar (doing other things)
2013/12/09 20:31:34
It probably *should* be a global static per the g_
Mark Mentovai
2013/12/09 20:42:39
jar wrote:
jar (doing other things)
2013/12/09 20:47:55
<doh> My mistaken... function statics don't need
qsr
2013/12/11 09:11:21
Done.
|
| + // This initialization is not thread-safe, so the value of |g_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. |
| + 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 +775,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. |
| } |