diff options
author | miletus <miletus@chromium.org> | 2015-04-14 09:42:20 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-14 16:42:38 +0000 |
commit | afb3a3897a1964fb565fb489c5148cae06375644 (patch) | |
tree | de72e7a17cfcc9bcd640c90b4df89f6ffb0bf0e8 /ui | |
parent | b260baeed9c93d30fe893d50946b3e446050bb5f (diff) | |
download | chromium_src-afb3a3897a1964fb565fb489c5148cae06375644.zip chromium_src-afb3a3897a1964fb565fb489c5148cae06375644.tar.gz chromium_src-afb3a3897a1964fb565fb489c5148cae06375644.tar.bz2 |
Make initialization of benchmark_enabled thread_safe
BUG=468396
Review URL: https://codereview.chromium.org/1081243002
Cr-Commit-Position: refs/heads/master@{#325069}
Diffstat (limited to 'ui')
-rw-r--r-- | ui/events/latency_info.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/ui/events/latency_info.cc b/ui/events/latency_info.cc index c4b18fc..9718aa4 100644 --- a/ui/events/latency_info.cc +++ b/ui/events/latency_info.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/json/json_writer.h" +#include "base/lazy_instance.h" #include "base/memory/scoped_ptr.h" #include "base/strings/stringprintf.h" #include "base/trace_event/trace_event.h" @@ -136,6 +137,18 @@ scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsTraceableData( return LatencyInfoTracedValue::FromValue(record_data.Pass()); } +struct BenchmarkEnabledInitializer { + BenchmarkEnabledInitializer() : + benchmark_enabled(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( + "benchmark")) { + } + + const unsigned char* benchmark_enabled; +}; + +static base::LazyInstance<BenchmarkEnabledInitializer>::Leaky + g_benchmark_enabled = LAZY_INSTANCE_INITIALIZER; + } // namespace namespace ui { @@ -213,8 +226,8 @@ void LatencyInfo::AddLatencyNumberWithTimestamp(LatencyComponentType component, base::TimeTicks time, uint32 event_count) { - static const unsigned char* benchmark_enabled = - TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED("benchmark"); + const unsigned char* benchmark_enabled = + g_benchmark_enabled.Get().benchmark_enabled; if (IsBeginComponent(component)) { // Should only ever add begin component once. |