summaryrefslogtreecommitdiffstats
path: root/chrome_frame/utils.h
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-05 18:49:21 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-05 18:49:21 +0000
commit333590006f12dc30ef7e46187c8d62a3a401d695 (patch)
treef413bc97ed77cf502486204845aec810e42b1ade /chrome_frame/utils.h
parent004dcf2cf16bb77847f60b304b60956b8fe0079c (diff)
downloadchromium_src-333590006f12dc30ef7e46187c8d62a3a401d695.zip
chromium_src-333590006f12dc30ef7e46187c8d62a3a401d695.tar.gz
chromium_src-333590006f12dc30ef7e46187c8d62a3a401d695.tar.bz2
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
Diffstat (limited to 'chrome_frame/utils.h')
-rw-r--r--chrome_frame/utils.h18
1 files changed, 18 insertions, 0 deletions
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 <urlmon.h>
#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_