summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-08 04:52:15 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-08 04:52:15 +0000
commitb0c819facfd2222853b1fe69a2e0891e17db6791 (patch)
treeca2a4fbf1c60f3299cb3a049c8ae8712c71c4e4d
parentb78292153e19f2c8b04d153abc3b63b795cfff54 (diff)
downloadchromium_src-b0c819facfd2222853b1fe69a2e0891e17db6791.zip
chromium_src-b0c819facfd2222853b1fe69a2e0891e17db6791.tar.gz
chromium_src-b0c819facfd2222853b1fe69a2e0891e17db6791.tar.bz2
The MetricsService are not initialized unless the user have opted in
See contributed CL 28315 by Xharze BUG=2278 Review URL: http://codereview.chromium.org/40274 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11219 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/metrics/metrics_service.cc22
1 files changed, 13 insertions, 9 deletions
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index 220102f..858032a 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -430,6 +430,19 @@ void MetricsService::SetRecording(bool enabled) {
return;
if (enabled) {
+ if (client_id_.empty()) {
+ PrefService* pref = g_browser_process->local_state();
+ DCHECK(pref);
+ client_id_ = WideToUTF8(pref->GetString(prefs::kMetricsClientID));
+ if (client_id_.empty()) {
+ client_id_ = GenerateClientID();
+ pref->SetString(prefs::kMetricsClientID, UTF8ToWide(client_id_));
+
+ // Might as well make a note of how long this ID has existed
+ pref->SetString(prefs::kMetricsClientIDTimestamp,
+ Int64ToWString(Time::Now().ToTimeT()));
+ }
+ }
StartRecording();
ListenerRegistration(true);
} else {
@@ -592,15 +605,6 @@ void MetricsService::InitializeMetricsState() {
UTF8ToWide(MetricsLog::GetVersionString()));
}
- client_id_ = WideToUTF8(pref->GetString(prefs::kMetricsClientID));
- if (client_id_.empty()) {
- client_id_ = GenerateClientID();
- pref->SetString(prefs::kMetricsClientID, UTF8ToWide(client_id_));
-
- // Might as well make a note of how long this ID has existed
- pref->SetInt64(prefs::kMetricsClientIDTimestamp, Time::Now().ToTimeT());
- }
-
// Update session ID
session_id_ = pref->GetInteger(prefs::kMetricsSessionID);
++session_id_;