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

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

Issue 2566323002: Defer Posting StoreMetricsClientInfo During PreCreateThreads (Closed)
Patch Set: Update Comment Created 4 years 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_services_manager_client.h" 5 #include "chrome/browser/metrics/chrome_metrics_services_manager_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/feature_list.h" 8 #include "base/feature_list.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 // Metrics reporting feature. This feature, along with user consent, controls if 53 // Metrics reporting feature. This feature, along with user consent, controls if
54 // recording and reporting are enabled. If the feature is enabled, but no 54 // recording and reporting are enabled. If the feature is enabled, but no
55 // consent is given, then there will be no recording or reporting. 55 // consent is given, then there will be no recording or reporting.
56 const base::Feature kMetricsReportingFeature{"MetricsReporting", 56 const base::Feature kMetricsReportingFeature{"MetricsReporting",
57 base::FEATURE_ENABLED_BY_DEFAULT}; 57 base::FEATURE_ENABLED_BY_DEFAULT};
58 58
59 // Posts |GoogleUpdateSettings::StoreMetricsClientInfo| on blocking pool thread 59 // Posts |GoogleUpdateSettings::StoreMetricsClientInfo| on blocking pool thread
60 // because it needs access to IO and cannot work from UI thread. 60 // because it needs access to IO and cannot work from UI thread.
61 void PostStoreMetricsClientInfo(const metrics::ClientInfo& client_info) { 61 void PostStoreMetricsClientInfo(const metrics::ClientInfo& client_info) {
62 content::BrowserThread::GetBlockingPool()->PostTask( 62 // The message loop processes messages after the blocking pool is initialized.
63 FROM_HERE, 63 // Posting a task to the message loop to post a task to the blocking pool
64 base::Bind(&GoogleUpdateSettings::StoreMetricsClientInfo, client_info)); 64 // ensures that the blocking pool is ready to accept tasks at that time.
65 content::BrowserThread::PostTask(
66 content::BrowserThread::UI, FROM_HERE,
67 base::Bind(
68 [](const metrics::ClientInfo& client_info) {
69 content::BrowserThread::PostBlockingPoolTask(
70 FROM_HERE,
71 base::Bind(&GoogleUpdateSettings::StoreMetricsClientInfo,
72 client_info));
73 },
74 client_info));
65 } 75 }
66 76
67 // Appends a group to the sampling controlling |trial|. The group will be 77 // Appends a group to the sampling controlling |trial|. The group will be
68 // associated with a variation param for reporting sampling |rate| in per mille. 78 // associated with a variation param for reporting sampling |rate| in per mille.
69 void AppendSamplingTrialGroup(const std::string& group_name, 79 void AppendSamplingTrialGroup(const std::string& group_name,
70 int rate, 80 int rate,
71 base::FieldTrial* trial) { 81 base::FieldTrial* trial) {
72 std::map<std::string, std::string> params = { 82 std::map<std::string, std::string> params = {
73 {kRateParamName, base::IntToString(rate)}}; 83 {kRateParamName, base::IntToString(rate)}};
74 variations::AssociateVariationParams(trial->trial_name(), group_name, params); 84 variations::AssociateVariationParams(trial->trial_name(), group_name, params);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 ChromeMetricsServicesManagerClient::GetMetricsStateManager() { 288 ChromeMetricsServicesManagerClient::GetMetricsStateManager() {
279 DCHECK(thread_checker_.CalledOnValidThread()); 289 DCHECK(thread_checker_.CalledOnValidThread());
280 if (!metrics_state_manager_) { 290 if (!metrics_state_manager_) {
281 metrics_state_manager_ = metrics::MetricsStateManager::Create( 291 metrics_state_manager_ = metrics::MetricsStateManager::Create(
282 local_state_, enabled_state_provider_.get(), 292 local_state_, enabled_state_provider_.get(),
283 base::Bind(&PostStoreMetricsClientInfo), 293 base::Bind(&PostStoreMetricsClientInfo),
284 base::Bind(&GoogleUpdateSettings::LoadMetricsClientInfo)); 294 base::Bind(&GoogleUpdateSettings::LoadMetricsClientInfo));
285 } 295 }
286 return metrics_state_manager_.get(); 296 return metrics_state_manager_.get();
287 } 297 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698