Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 delayed post task allows this function to get called before the |
| 63 FROM_HERE, | 63 // blocking pool is ready to go. |
|
gab
2016/12/13 15:58:39
(this sentence is backwards?)
// Posting the task
robliao
2016/12/13 18:19:38
Clarified to
// The message loop processes message
| |
| 64 base::Bind(&GoogleUpdateSettings::StoreMetricsClientInfo, client_info)); | 64 content::BrowserThread::PostTask( |
| 65 content::BrowserThread::UI, FROM_HERE, | |
| 66 base::Bind( | |
| 67 [](const metrics::ClientInfo& client_info) { | |
| 68 content::BrowserThread::PostBlockingPoolTask( | |
| 69 FROM_HERE, | |
| 70 base::Bind(&GoogleUpdateSettings::StoreMetricsClientInfo, | |
| 71 client_info)); | |
| 72 }, | |
| 73 client_info)); | |
| 65 } | 74 } |
| 66 | 75 |
| 67 // Appends a group to the sampling controlling |trial|. The group will be | 76 // 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. | 77 // associated with a variation param for reporting sampling |rate| in per mille. |
| 69 void AppendSamplingTrialGroup(const std::string& group_name, | 78 void AppendSamplingTrialGroup(const std::string& group_name, |
| 70 int rate, | 79 int rate, |
| 71 base::FieldTrial* trial) { | 80 base::FieldTrial* trial) { |
| 72 std::map<std::string, std::string> params = { | 81 std::map<std::string, std::string> params = { |
| 73 {kRateParamName, base::IntToString(rate)}}; | 82 {kRateParamName, base::IntToString(rate)}}; |
| 74 variations::AssociateVariationParams(trial->trial_name(), group_name, params); | 83 variations::AssociateVariationParams(trial->trial_name(), group_name, params); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 ChromeMetricsServicesManagerClient::GetMetricsStateManager() { | 287 ChromeMetricsServicesManagerClient::GetMetricsStateManager() { |
| 279 DCHECK(thread_checker_.CalledOnValidThread()); | 288 DCHECK(thread_checker_.CalledOnValidThread()); |
| 280 if (!metrics_state_manager_) { | 289 if (!metrics_state_manager_) { |
| 281 metrics_state_manager_ = metrics::MetricsStateManager::Create( | 290 metrics_state_manager_ = metrics::MetricsStateManager::Create( |
| 282 local_state_, enabled_state_provider_.get(), | 291 local_state_, enabled_state_provider_.get(), |
| 283 base::Bind(&PostStoreMetricsClientInfo), | 292 base::Bind(&PostStoreMetricsClientInfo), |
| 284 base::Bind(&GoogleUpdateSettings::LoadMetricsClientInfo)); | 293 base::Bind(&GoogleUpdateSettings::LoadMetricsClientInfo)); |
| 285 } | 294 } |
| 286 return metrics_state_manager_.get(); | 295 return metrics_state_manager_.get(); |
| 287 } | 296 } |
| OLD | NEW |