summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome_frame/metrics_service.cc7
-rw-r--r--chrome_frame/metrics_service.h5
2 files changed, 11 insertions, 1 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);
}
diff --git a/chrome_frame/metrics_service.h b/chrome_frame/metrics_service.h
index 38eb1f4..baea9c8 100644
--- a/chrome_frame/metrics_service.h
+++ b/chrome_frame/metrics_service.h
@@ -13,6 +13,7 @@
#include "base/basictypes.h"
#include "base/lazy_instance.h"
+#include "base/lock.h"
#include "base/metrics/histogram.h"
#include "base/platform_thread.h"
#include "base/scoped_ptr.h"
@@ -146,8 +147,10 @@ class MetricsService : public MetricsServiceBase {
// The transmission timer id returned by SetTimer
int transmission_timer_id_;
+ // Used to serialize the Start and Stop operations on the metrics service.
+ static Lock metrics_service_lock_;
+
DISALLOW_COPY_AND_ASSIGN(MetricsService);
};
#endif // CHROME_FRAME_METRICS_METRICS_SERVICE_H_
-