| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // Metrics reporting feature. This feature, along with user consent, controls if | 57 // Metrics reporting feature. This feature, along with user consent, controls if |
| 58 // recording and reporting are enabled. If the feature is enabled, but no | 58 // recording and reporting are enabled. If the feature is enabled, but no |
| 59 // consent is given, then there will be no recording or reporting. | 59 // consent is given, then there will be no recording or reporting. |
| 60 const base::Feature kMetricsReportingFeature{"MetricsReporting", | 60 const base::Feature kMetricsReportingFeature{"MetricsReporting", |
| 61 base::FEATURE_ENABLED_BY_DEFAULT}; | 61 base::FEATURE_ENABLED_BY_DEFAULT}; |
| 62 | 62 |
| 63 // Posts |GoogleUpdateSettings::StoreMetricsClientInfo| on blocking pool thread | 63 // Posts |GoogleUpdateSettings::StoreMetricsClientInfo| on blocking pool thread |
| 64 // because it needs access to IO and cannot work from UI thread. | 64 // because it needs access to IO and cannot work from UI thread. |
| 65 void PostStoreMetricsClientInfo(const metrics::ClientInfo& client_info) { | 65 void PostStoreMetricsClientInfo(const metrics::ClientInfo& client_info) { |
| 66 base::PostTaskWithTraits( | 66 base::PostTaskWithTraits( |
| 67 FROM_HERE, | 67 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
| 68 base::TaskTraits() | |
| 69 .WithPriority(base::TaskPriority::BACKGROUND) | |
| 70 .MayBlock(), | |
| 71 base::BindOnce(&GoogleUpdateSettings::StoreMetricsClientInfo, | 68 base::BindOnce(&GoogleUpdateSettings::StoreMetricsClientInfo, |
| 72 client_info)); | 69 client_info)); |
| 73 } | 70 } |
| 74 | 71 |
| 75 // Appends a group to the sampling controlling |trial|. The group will be | 72 // Appends a group to the sampling controlling |trial|. The group will be |
| 76 // associated with a variation param for reporting sampling |rate| in per mille. | 73 // associated with a variation param for reporting sampling |rate| in per mille. |
| 77 void AppendSamplingTrialGroup(const std::string& group_name, | 74 void AppendSamplingTrialGroup(const std::string& group_name, |
| 78 int rate, | 75 int rate, |
| 79 base::FieldTrial* trial) { | 76 base::FieldTrial* trial) { |
| 80 std::map<std::string, std::string> params = { | 77 std::map<std::string, std::string> params = { |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 ChromeMetricsServicesManagerClient::GetMetricsStateManager() { | 281 ChromeMetricsServicesManagerClient::GetMetricsStateManager() { |
| 285 DCHECK(thread_checker_.CalledOnValidThread()); | 282 DCHECK(thread_checker_.CalledOnValidThread()); |
| 286 if (!metrics_state_manager_) { | 283 if (!metrics_state_manager_) { |
| 287 metrics_state_manager_ = metrics::MetricsStateManager::Create( | 284 metrics_state_manager_ = metrics::MetricsStateManager::Create( |
| 288 local_state_, enabled_state_provider_.get(), | 285 local_state_, enabled_state_provider_.get(), |
| 289 base::Bind(&PostStoreMetricsClientInfo), | 286 base::Bind(&PostStoreMetricsClientInfo), |
| 290 base::Bind(&GoogleUpdateSettings::LoadMetricsClientInfo)); | 287 base::Bind(&GoogleUpdateSettings::LoadMetricsClientInfo)); |
| 291 } | 288 } |
| 292 return metrics_state_manager_.get(); | 289 return metrics_state_manager_.get(); |
| 293 } | 290 } |
| OLD | NEW |