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

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

Issue 2918533003: Send metrics with embedded system profiles after system startup. (Closed)
Patch Set: addressed final review comments Created 3 years, 6 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
« no previous file with comments | « no previous file | components/metrics/file_metrics_provider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/metrics/chrome_metrics_service_client.h" 5 #include "chrome/browser/metrics/chrome_metrics_service_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 #endif 170 #endif
171 } 171 }
172 172
173 // Constructs the name of a persistent metrics file from a directory and metrics 173 // Constructs the name of a persistent metrics file from a directory and metrics
174 // name, and either registers that file as associated with a previous run if 174 // name, and either registers that file as associated with a previous run if
175 // metrics reporting is enabled, or deletes it if not. 175 // metrics reporting is enabled, or deletes it if not.
176 void RegisterOrRemovePreviousRunMetricsFile( 176 void RegisterOrRemovePreviousRunMetricsFile(
177 bool metrics_reporting_enabled, 177 bool metrics_reporting_enabled,
178 const base::FilePath& dir, 178 const base::FilePath& dir,
179 base::StringPiece metrics_name, 179 base::StringPiece metrics_name,
180 metrics::FileMetricsProvider::SourceAssociation association,
180 scoped_refptr<base::TaskRunner> task_runner, 181 scoped_refptr<base::TaskRunner> task_runner,
181 metrics::FileMetricsProvider* file_metrics_provider) { 182 metrics::FileMetricsProvider* file_metrics_provider) {
182 base::FilePath metrics_file; 183 base::FilePath metrics_file;
183 base::GlobalHistogramAllocator::ConstructFilePaths( 184 base::GlobalHistogramAllocator::ConstructFilePaths(
184 dir, metrics_name, &metrics_file, nullptr, nullptr); 185 dir, metrics_name, &metrics_file, nullptr, nullptr);
185 186
186 if (metrics_reporting_enabled) { 187 if (metrics_reporting_enabled) {
187 // Enable reading any existing saved metrics. 188 // Enable reading any existing saved metrics.
188 file_metrics_provider->RegisterSource( 189 file_metrics_provider->RegisterSource(
189 metrics_file, 190 metrics_file,
190 metrics::FileMetricsProvider::SOURCE_HISTOGRAMS_ATOMIC_FILE, 191 metrics::FileMetricsProvider::SOURCE_HISTOGRAMS_ATOMIC_FILE,
191 metrics::FileMetricsProvider::ASSOCIATE_PREVIOUS_RUN, metrics_name); 192 association, metrics_name);
192 } else { 193 } else {
193 // When metrics reporting is not enabled, any existing file should be 194 // When metrics reporting is not enabled, any existing file should be
194 // deleted in order to preserve user privacy. 195 // deleted in order to preserve user privacy.
195 task_runner->PostTask(FROM_HERE, 196 task_runner->PostTask(FROM_HERE,
196 base::BindOnce(base::IgnoreResult(&base::DeleteFile), 197 base::BindOnce(base::IgnoreResult(&base::DeleteFile),
197 metrics_file, /*recursive=*/false)); 198 metrics_file, /*recursive=*/false));
198 } 199 }
199 } 200 }
200 201
201 std::unique_ptr<metrics::FileMetricsProvider> CreateFileMetricsProvider( 202 std::unique_ptr<metrics::FileMetricsProvider> CreateFileMetricsProvider(
(...skipping 14 matching lines...) Expand all
216 if (base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { 217 if (base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
217 // Reporting of persistent histograms from last session is controlled by 218 // Reporting of persistent histograms from last session is controlled by
218 // a feature param. TODO(bcwhite): The current default is not to upload 219 // a feature param. TODO(bcwhite): The current default is not to upload
219 // until some issues are resolved. See crbug.com/706422 for details. 220 // until some issues are resolved. See crbug.com/706422 for details.
220 std::string send_unreported = base::GetFieldTrialParamValueByFeature( 221 std::string send_unreported = base::GetFieldTrialParamValueByFeature(
221 base::kPersistentHistogramsFeature, "send_unreported_metrics"); 222 base::kPersistentHistogramsFeature, "send_unreported_metrics");
222 bool report_previous_persistent_histograms = 223 bool report_previous_persistent_histograms =
223 metrics_reporting_enabled && (send_unreported == "yes"); 224 metrics_reporting_enabled && (send_unreported == "yes");
224 RegisterOrRemovePreviousRunMetricsFile( 225 RegisterOrRemovePreviousRunMetricsFile(
225 report_previous_persistent_histograms, user_data_dir, 226 report_previous_persistent_histograms, user_data_dir,
226 ChromeMetricsServiceClient::kBrowserMetricsName, task_runner, 227 ChromeMetricsServiceClient::kBrowserMetricsName,
228 metrics::FileMetricsProvider::ASSOCIATE_INTERNAL_PROFILE, task_runner,
227 file_metrics_provider.get()); 229 file_metrics_provider.get());
228 230
229 // Register the Crashpad metrics files. 231 // Register the Crashpad metrics files.
230 // Register the data from the previous run if crashpad_handler didn't exit 232 // Register the data from the previous run if crashpad_handler didn't exit
231 // cleanly. 233 // cleanly.
232 RegisterOrRemovePreviousRunMetricsFile( 234 RegisterOrRemovePreviousRunMetricsFile(
233 metrics_reporting_enabled, user_data_dir, 235 metrics_reporting_enabled, user_data_dir,
234 kCrashpadHistogramAllocatorName, task_runner, 236 kCrashpadHistogramAllocatorName,
235 file_metrics_provider.get()); 237 metrics::FileMetricsProvider::
238 ASSOCIATE_INTERNAL_PROFILE_OR_PREVIOUS_RUN,
239 task_runner, file_metrics_provider.get());
236 if (metrics_reporting_enabled) { 240 if (metrics_reporting_enabled) {
237 base::FilePath active_path; 241 base::FilePath active_path;
238 base::GlobalHistogramAllocator::ConstructFilePaths( 242 base::GlobalHistogramAllocator::ConstructFilePaths(
239 user_data_dir, kCrashpadHistogramAllocatorName, nullptr, &active_path, 243 user_data_dir, kCrashpadHistogramAllocatorName, nullptr, &active_path,
240 nullptr); 244 nullptr);
241 // Register data that will be populated for the current run. "Active" 245 // Register data that will be populated for the current run. "Active"
242 // files need an empty "prefs_key" because they update the file itself. 246 // files need an empty "prefs_key" because they update the file itself.
243 file_metrics_provider->RegisterSource( 247 file_metrics_provider->RegisterSource(
244 active_path, 248 active_path,
245 metrics::FileMetricsProvider::SOURCE_HISTOGRAMS_ACTIVE_FILE, 249 metrics::FileMetricsProvider::SOURCE_HISTOGRAMS_ACTIVE_FILE,
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 ukm_service_->Purge(); 997 ukm_service_->Purge();
994 ukm_service_->ResetClientId(); 998 ukm_service_->ResetClientId();
995 } 999 }
996 // Signal service manager to enable/disable UKM based on new state. 1000 // Signal service manager to enable/disable UKM based on new state.
997 UpdateRunningServices(); 1001 UpdateRunningServices();
998 } 1002 }
999 1003
1000 bool ChromeMetricsServiceClient::IsHistorySyncEnabledOnAllProfiles() { 1004 bool ChromeMetricsServiceClient::IsHistorySyncEnabledOnAllProfiles() {
1001 return SyncDisableObserver::IsHistorySyncEnabledOnAllProfiles(); 1005 return SyncDisableObserver::IsHistorySyncEnabledOnAllProfiles();
1002 } 1006 }
OLDNEW
« no previous file with comments | « no previous file | components/metrics/file_metrics_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698