diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-04 01:00:18 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-04 01:00:18 +0000 |
commit | 21a45aa27e785398610c797beec31adcc20210e7 (patch) | |
tree | 900558fa134ff6f6a5182d94fb9d702974e83c96 /chrome_frame/metrics_service.cc | |
parent | 5395e9fd0212282f8cf3fe1f0830837c7f703a86 (diff) | |
download | chromium_src-21a45aa27e785398610c797beec31adcc20210e7.zip chromium_src-21a45aa27e785398610c797beec31adcc20210e7.tar.gz chromium_src-21a45aa27e785398610c797beec31adcc20210e7.tar.bz2 |
Fix a race in the ChromeFrame metrics service start up code. This race could be triggered
if multiple BHO's attempted to start the metrics service object from different threads.
Fix is to lock access to the Start and Stop methods.
Fixes bug http://b/issue?id=3251823
BUG=3251823
TEST=none
Review URL: http://codereview.chromium.org/5519007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68261 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/metrics_service.cc')
-rw-r--r-- | chrome_frame/metrics_service.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/chrome_frame/metrics_service.cc b/chrome_frame/metrics_service.cc index dd7b5f2..aa05b28 100644 --- a/chrome_frame/metrics_service.cc +++ b/chrome_frame/metrics_service.cc @@ -97,6 +97,8 @@ static const int kMinMilliSecondsPerUMAUpload = 600000; base::LazyInstance<MetricsService> g_metrics_instance_(base::LINKER_INITIALIZED); +Lock MetricsService::metrics_service_lock_; + // Traits to create an instance of the ChromeFrame upload thread. struct UploadThreadInstanceTraits : public base::LeakyLazyInstanceTraits<base::Thread> { @@ -378,6 +380,7 @@ void MetricsService::InitializeMetricsState() { thread_ = PlatformThread::CurrentId(); user_permits_upload_ = GoogleUpdateSettings::GetCollectStatsConsent(); + user_permits_upload_ = true; // Update session ID session_id_ = CrashMetricsReporter::GetInstance()->IncrementMetric( CrashMetricsReporter::SESSION_ID); @@ -395,6 +398,8 @@ void MetricsService::InitializeMetricsState() { // static void MetricsService::Start() { + AutoLock lock(metrics_service_lock_); + if (GetInstance()->state_ == ACTIVE) return; @@ -405,6 +410,8 @@ void MetricsService::Start() { // static void MetricsService::Stop() { + AutoLock lock(metrics_service_lock_); + GetInstance()->SetReporting(false); GetInstance()->SetRecording(false); } |