Index: chrome/browser/metrics/metrics_service.cc |
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc |
index a313c4514051b636009db4616c10559f98a64ca5..5ec323faf87fa35ba4af1267b6937a368372de50 100644 |
--- a/chrome/browser/metrics/metrics_service.cc |
+++ b/chrome/browser/metrics/metrics_service.cc |
@@ -521,7 +521,8 @@ void MetricsService::DiscardOldStabilityStats(PrefService* local_state) { |
} |
MetricsService::MetricsService() |
- : recording_active_(false), |
+ : variations_state_initialized_(false), |
+ recording_active_(false), |
reporting_active_(false), |
test_mode_active_(false), |
state_(INITIALIZED), |
@@ -558,6 +559,21 @@ void MetricsService::InitializeMetricsRecordingState( |
scheduler_.reset(new MetricsReportingScheduler(callback)); |
} |
+void MetricsService::InitializeVariationsState(bool recording_enabled) { |
+ if (!variations_state_initialized_) { |
+ variations_state_initialized_ = true; |
+ |
+ if (g_browser_process->local_state()->GetBoolean( |
+ prefs::kMetricsCloneDetected)) |
+ ResetVariationsState(); |
+ } |
+ |
+ GetLowEntropySource(); |
+ |
+ if (recording_enabled) |
Alexei Svitkine (slow)
2014/03/28 15:00:17
Hmm, this requires the caller to know this, which
jwd
2014/03/28 16:23:50
Done.
|
+ ForceClientIdCreation(); |
+} |
+ |
void MetricsService::Start() { |
HandleIdleSinceLastTransmission(false); |
EnableRecording(); |
@@ -633,6 +649,7 @@ MetricsService::CreateEntropyProvider(ReportingState reporting_state) { |
void MetricsService::ForceClientIdCreation() { |
if (!client_id_.empty()) |
return; |
+ |
PrefService* pref = g_browser_process->local_state(); |
client_id_ = pref->GetString(prefs::kMetricsClientID); |
if (!client_id_.empty()) |
@@ -1192,6 +1209,8 @@ int MetricsService::GetLowEntropySource() { |
if (low_entropy_source_ != kLowEntropySourceNotSet) |
return low_entropy_source_; |
+ ResetVariationsState(); |
Alexei Svitkine (slow)
2014/03/28 15:00:17
Why is this called from here? Did you mean Initial
jwd
2014/03/28 16:23:50
Done.
|
+ |
PrefService* local_state = g_browser_process->local_state(); |
const CommandLine* command_line(CommandLine::ForCurrentProcess()); |
// Only try to load the value from prefs if the user did not request a reset. |
@@ -1862,6 +1881,7 @@ void MetricsService::RegisterSyntheticFieldTrial( |
} |
void MetricsService::CheckForClonedInstall() { |
+ DVLOG(2) << "\n\nChecking for cloned installs\n\n"; |
DCHECK(!cloned_install_detector_); |
metrics::MachineIdProvider* provider = |
@@ -1876,6 +1896,19 @@ void MetricsService::CheckForClonedInstall() { |
cloned_install_detector_->CheckForClonedInstall(local_state); |
} |
+void MetricsService::ResetVariationsState() { |
+ PrefService* local_state = g_browser_process->local_state(); |
+ DCHECK(local_state->GetBoolean(prefs::kMetricsCloneDetected)); |
+ DCHECK(client_id_.empty()); |
+ DCHECK(low_entropy_source_ == kLowEntropySourceNotSet); |
+ |
+ DVLOG(2) << "\n\nresetting variatinos state\n\n"; |
+ |
+ local_state->ClearPref(prefs::kMetricsClientID); |
+ local_state->ClearPref(prefs::kMetricsLowEntropySource); |
+ local_state->SetBoolean(prefs::kMetricsCloneDetected, false); |
+} |
+ |
void MetricsService::GetCurrentSyntheticFieldTrials( |
std::vector<chrome_variations::ActiveGroupId>* synthetic_trials) { |
DCHECK(synthetic_trials); |