From 333590006f12dc30ef7e46187c8d62a3a401d695 Mon Sep 17 00:00:00 2001 From: "ananta@chromium.org" Date: Fri, 5 Mar 2010 18:49:21 +0000 Subject: Fix a ChromeFrame crash which occured in the Histogram code while adding a histogram. The histogram macros basically instantiate a static Histogram instance which is then tracked. The static initialization is not thread safe and thus could cause a crash if there is a race between multiple threads trying to access the object at the same time. Fix based on a discussion with Jim is to add thread safe versions of the macros we use for ChromeFrame. Fixes bug http://code.google.com/p/chromium/issues/detail?id=37470 Bug=37470 Review URL: http://codereview.chromium.org/669135 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40757 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome_frame/utils.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'chrome_frame/utils.h') diff --git a/chrome_frame/utils.h b/chrome_frame/utils.h index 16fa836..adbd65e 100644 --- a/chrome_frame/utils.h +++ b/chrome_frame/utils.h @@ -11,6 +11,8 @@ #include #include "base/basictypes.h" +#include "base/histogram.h" +#include "base/lock.h" #include "base/logging.h" #include "base/thread.h" @@ -349,5 +351,21 @@ std::wstring GetActualUrlFromMoniker(IMoniker* moniker, // Checks if a window is a top level window bool IsTopLevelWindow(HWND window); +extern Lock g_ChromeFrameHistogramLock; + +// Thread safe versions of the UMA histogram macros we use for ChromeFrame. +// These should be used for histograms in ChromeFrame. If other histogram +// macros from base/histogram.h are needed then thread safe versions of those +// should be defined and used. +#define THREAD_SAFE_UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, \ + bucket_count) { \ + AutoLock lock(g_ChromeFrameHistogramLock); \ + UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count); \ +} + +#define THREAD_SAFE_UMA_HISTOGRAM_TIMES(name, sample) { \ + AutoLock lock(g_ChromeFrameHistogramLock); \ + UMA_HISTOGRAM_TIMES(name, sample); \ +} #endif // CHROME_FRAME_UTILS_H_ -- cgit v1.1