Use lock-free lazy initialization for static histogram references
Make all histogram macros thread safe, and fast by again
using statics to achieve performance.
...at the cost of:
Leak all histograms to avoid races at shutdown.
Also included leak suppression for valgrind.
r=rtenneti
BUG=78207
Review URL: http://codereview.chromium.org/6780035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80412 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: 81ce9f3b1eb34dc7f6954f0f6657a76b0f01fc12
diff --git a/base/message_loop.cc b/base/message_loop.cc
index 39881d1..1154c3e 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -122,6 +122,7 @@
: type_(type),
nestable_tasks_allowed_(true),
exception_restoration_(false),
+ message_histogram_(NULL),
state_(NULL),
#ifdef OS_WIN
os_modal_loop_(false),
@@ -531,7 +532,7 @@
// on each thread.
void MessageLoop::StartHistogrammer() {
- if (enable_histogrammer_ && !message_histogram_.get()
+ if (enable_histogrammer_ && !message_histogram_
&& base::StatisticsRecorder::IsActive()) {
DCHECK(!thread_name_.empty());
message_histogram_ = base::LinearHistogram::FactoryGet(
@@ -544,7 +545,7 @@
}
void MessageLoop::HistogramEvent(int event) {
- if (message_histogram_.get())
+ if (message_histogram_)
message_histogram_->Add(event);
}