Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: chrome/browser/metrics/metrics_service.cc

Issue 213363004: Resetting metrics ids on clump detection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 //------------------------------------------------------------------------------ 5 //------------------------------------------------------------------------------
6 // Description of the life cycle of a instance of MetricsService. 6 // Description of the life cycle of a instance of MetricsService.
7 // 7 //
8 // OVERVIEW 8 // OVERVIEW
9 // 9 //
10 // A MetricsService instance is typically created at application startup. It is 10 // A MetricsService instance is typically created at application startup. It is
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // twice. For example, if a log file is sent, but not yet acknowledged by 156 // twice. For example, if a log file is sent, but not yet acknowledged by
157 // the external server, and the user shuts down, then a copy of the log may be 157 // the external server, and the user shuts down, then a copy of the log may be
158 // saved for re-transmission. These duplicates could be filtered out server 158 // saved for re-transmission. These duplicates could be filtered out server
159 // side, but are not expected to be a significant problem. 159 // side, but are not expected to be a significant problem.
160 // 160 //
161 // 161 //
162 //------------------------------------------------------------------------------ 162 //------------------------------------------------------------------------------
163 163
164 #include "chrome/browser/metrics/metrics_service.h" 164 #include "chrome/browser/metrics/metrics_service.h"
165 165
166 #include "base/debug/stack_trace.h"
167
166 #include <algorithm> 168 #include <algorithm>
167 169
168 #include "base/bind.h" 170 #include "base/bind.h"
169 #include "base/callback.h" 171 #include "base/callback.h"
170 #include "base/command_line.h" 172 #include "base/command_line.h"
171 #include "base/guid.h" 173 #include "base/guid.h"
172 #include "base/md5.h" 174 #include "base/md5.h"
173 #include "base/metrics/histogram.h" 175 #include "base/metrics/histogram.h"
174 #include "base/metrics/sparse_histogram.h" 176 #include "base/metrics/sparse_histogram.h"
175 #include "base/metrics/statistics_recorder.h" 177 #include "base/metrics/statistics_recorder.h"
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 low_entropy_source_value, 626 low_entropy_source_value,
625 kMaxLowEntropySize)); 627 kMaxLowEntropySize));
626 #else 628 #else
627 return scoped_ptr<const base::FieldTrial::EntropyProvider>( 629 return scoped_ptr<const base::FieldTrial::EntropyProvider>(
628 new metrics::PermutedEntropyProvider(low_entropy_source_value, 630 new metrics::PermutedEntropyProvider(low_entropy_source_value,
629 kMaxLowEntropySize)); 631 kMaxLowEntropySize));
630 #endif 632 #endif
631 } 633 }
632 634
633 void MetricsService::ForceClientIdCreation() { 635 void MetricsService::ForceClientIdCreation() {
636 DVLOG(2) << "\n\nCreating client id\n\n";
637 base::debug::StackTrace st;
638 // DVLOG(2) << st.ToString();
634 if (!client_id_.empty()) 639 if (!client_id_.empty())
635 return; 640 return;
641 DVLOG(2) << "\n\nActually creating id\n\n";
636 PrefService* pref = g_browser_process->local_state(); 642 PrefService* pref = g_browser_process->local_state();
637 client_id_ = pref->GetString(prefs::kMetricsClientID); 643 client_id_ = pref->GetString(prefs::kMetricsClientID);
638 if (!client_id_.empty()) 644 if (!client_id_.empty())
639 return; 645 return;
640 646
641 client_id_ = GenerateClientID(); 647 client_id_ = GenerateClientID();
642 pref->SetString(prefs::kMetricsClientID, client_id_); 648 pref->SetString(prefs::kMetricsClientID, client_id_);
643 649
644 // Might as well make a note of how long this ID has existed 650 // Might as well make a note of how long this ID has existed
645 pref->SetString(prefs::kMetricsClientIDTimestamp, 651 pref->SetString(prefs::kMetricsClientIDTimestamp,
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 1185
1180 const int64 incremental_time_secs = incremental_uptime->InSeconds(); 1186 const int64 incremental_time_secs = incremental_uptime->InSeconds();
1181 if (incremental_time_secs > 0) { 1187 if (incremental_time_secs > 0) {
1182 int64 metrics_uptime = pref->GetInt64(prefs::kUninstallMetricsUptimeSec); 1188 int64 metrics_uptime = pref->GetInt64(prefs::kUninstallMetricsUptimeSec);
1183 metrics_uptime += incremental_time_secs; 1189 metrics_uptime += incremental_time_secs;
1184 pref->SetInt64(prefs::kUninstallMetricsUptimeSec, metrics_uptime); 1190 pref->SetInt64(prefs::kUninstallMetricsUptimeSec, metrics_uptime);
1185 } 1191 }
1186 } 1192 }
1187 1193
1188 int MetricsService::GetLowEntropySource() { 1194 int MetricsService::GetLowEntropySource() {
1195 DVLOG(2) << "\n\nGetting LES\n\n";
1196 base::debug::StackTrace st;
1197 // DVLOG(2) << st.ToString();
1189 // Note that the default value for the low entropy source and the default pref 1198 // Note that the default value for the low entropy source and the default pref
1190 // value are both kLowEntropySourceNotSet, which is used to identify if the 1199 // value are both kLowEntropySourceNotSet, which is used to identify if the
1191 // value has been set or not. 1200 // value has been set or not.
1192 if (low_entropy_source_ != kLowEntropySourceNotSet) 1201 if (low_entropy_source_ != kLowEntropySourceNotSet)
1193 return low_entropy_source_; 1202 return low_entropy_source_;
1194 1203
1195 PrefService* local_state = g_browser_process->local_state(); 1204 PrefService* local_state = g_browser_process->local_state();
1196 const CommandLine* command_line(CommandLine::ForCurrentProcess()); 1205 const CommandLine* command_line(CommandLine::ForCurrentProcess());
1197 // Only try to load the value from prefs if the user did not request a reset. 1206 // Only try to load the value from prefs if the user did not request a reset.
1198 // Otherwise, skip to generating a new value. 1207 // Otherwise, skip to generating a new value.
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 return; 1864 return;
1856 } 1865 }
1857 } 1866 }
1858 1867
1859 SyntheticTrialGroup trial_group = trial; 1868 SyntheticTrialGroup trial_group = trial;
1860 trial_group.start_time = base::TimeTicks::Now(); 1869 trial_group.start_time = base::TimeTicks::Now();
1861 synthetic_trial_groups_.push_back(trial_group); 1870 synthetic_trial_groups_.push_back(trial_group);
1862 } 1871 }
1863 1872
1864 void MetricsService::CheckForClonedInstall() { 1873 void MetricsService::CheckForClonedInstall() {
1874 DVLOG(2) << "\n\nChecking for cloned installs\n\n";
1865 DCHECK(!cloned_install_detector_); 1875 DCHECK(!cloned_install_detector_);
1866 1876
1867 metrics::MachineIdProvider* provider = 1877 metrics::MachineIdProvider* provider =
1868 metrics::MachineIdProvider::CreateInstance(); 1878 metrics::MachineIdProvider::CreateInstance();
1869 if (!provider) 1879 if (!provider)
1870 return; 1880 return;
1871 1881
1872 cloned_install_detector_.reset( 1882 cloned_install_detector_.reset(
1873 new metrics::ClonedInstallDetector(provider)); 1883 new metrics::ClonedInstallDetector(provider));
1874 1884
1875 PrefService* local_state = g_browser_process->local_state(); 1885 PrefService* local_state = g_browser_process->local_state();
1876 cloned_install_detector_->CheckForClonedInstall(local_state); 1886 cloned_install_detector_->CheckForClonedInstall(local_state);
1877 } 1887 }
1878 1888
1889 void MetricsService::ResetVariationsState() {
1890 PrefService* local_state = g_browser_process->local_state();
1891 DCHECK(local_state->GetBoolean(prefs::kMetricsCloneDetected));
1892 DCHECK(client_id_.empty());
1893 DCHECK(low_entropy_source_ == kLowEntropySourceNotSet);
1894
1895 DVLOG(2) << "\n\nresetting variatinos state\n\n";
1896
1897 local_state->ClearPref(prefs::kMetricsClientID);
1898 local_state->ClearPref(prefs::kMetricsLowEntropySource);
1899 local_state->SetBoolean(prefs::kMetricsCloneDetected, false);
Alexei Svitkine (slow) 2014/03/26 21:34:50 Why not ClearPref()?
jwd 2014/03/28 16:23:49 Done.
1900 }
1901
1879 void MetricsService::GetCurrentSyntheticFieldTrials( 1902 void MetricsService::GetCurrentSyntheticFieldTrials(
1880 std::vector<chrome_variations::ActiveGroupId>* synthetic_trials) { 1903 std::vector<chrome_variations::ActiveGroupId>* synthetic_trials) {
1881 DCHECK(synthetic_trials); 1904 DCHECK(synthetic_trials);
1882 synthetic_trials->clear(); 1905 synthetic_trials->clear();
1883 const MetricsLog* current_log = 1906 const MetricsLog* current_log =
1884 static_cast<const MetricsLog*>(log_manager_.current_log()); 1907 static_cast<const MetricsLog*>(log_manager_.current_log());
1885 for (size_t i = 0; i < synthetic_trial_groups_.size(); ++i) { 1908 for (size_t i = 0; i < synthetic_trial_groups_.size(); ++i) {
1886 if (synthetic_trial_groups_[i].start_time <= current_log->creation_time()) 1909 if (synthetic_trial_groups_[i].start_time <= current_log->creation_time())
1887 synthetic_trials->push_back(synthetic_trial_groups_[i].id); 1910 synthetic_trials->push_back(synthetic_trial_groups_[i].id);
1888 } 1911 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 // Android has its own settings for metrics / crash uploading. 2121 // Android has its own settings for metrics / crash uploading.
2099 const PrefService* prefs = g_browser_process->local_state(); 2122 const PrefService* prefs = g_browser_process->local_state();
2100 return prefs->GetBoolean(prefs::kCrashReportingEnabled); 2123 return prefs->GetBoolean(prefs::kCrashReportingEnabled);
2101 #else 2124 #else
2102 return MetricsServiceHelper::IsMetricsReportingEnabled(); 2125 return MetricsServiceHelper::IsMetricsReportingEnabled();
2103 #endif 2126 #endif
2104 #else 2127 #else
2105 return false; 2128 return false;
2106 #endif 2129 #endif
2107 } 2130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698