| OLD | NEW |
| 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 "components/metrics_services_manager/metrics_services_manager.h" | 5 #include "components/metrics_services_manager/metrics_services_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/metrics/histogram_macros.h" |
| 11 #include "components/metrics/metrics_service.h" | 12 #include "components/metrics/metrics_service.h" |
| 12 #include "components/metrics/metrics_service_client.h" | 13 #include "components/metrics/metrics_service_client.h" |
| 13 #include "components/metrics/metrics_state_manager.h" | 14 #include "components/metrics/metrics_state_manager.h" |
| 14 #include "components/metrics/metrics_switches.h" | 15 #include "components/metrics/metrics_switches.h" |
| 15 #include "components/metrics_services_manager/metrics_services_manager_client.h" | 16 #include "components/metrics_services_manager/metrics_services_manager_client.h" |
| 16 #include "components/rappor/rappor_service_impl.h" | 17 #include "components/rappor/rappor_service_impl.h" |
| 17 #include "components/ukm/ukm_service.h" | 18 #include "components/ukm/ukm_service.h" |
| 18 #include "components/variations/service/variations_service.h" | 19 #include "components/variations/service/variations_service.h" |
| 19 | 20 |
| 20 namespace metrics_services_manager { | 21 namespace metrics_services_manager { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 metrics_service_client_->SetUpdateRunningServicesCallback( | 77 metrics_service_client_->SetUpdateRunningServicesCallback( |
| 77 base::Bind(&MetricsServicesManager::UpdateRunningServices, | 78 base::Bind(&MetricsServicesManager::UpdateRunningServices, |
| 78 base::Unretained(this))); | 79 base::Unretained(this))); |
| 79 } | 80 } |
| 80 return metrics_service_client_.get(); | 81 return metrics_service_client_.get(); |
| 81 } | 82 } |
| 82 | 83 |
| 83 void MetricsServicesManager::UpdatePermissions(bool current_may_record, | 84 void MetricsServicesManager::UpdatePermissions(bool current_may_record, |
| 84 bool current_may_upload) { | 85 bool current_may_upload) { |
| 85 DCHECK(thread_checker_.CalledOnValidThread()); | 86 DCHECK(thread_checker_.CalledOnValidThread()); |
| 87 UMA_HISTOGRAM_BOOLEAN("UMA.Dbg.UpdatePermissions.may_record", current_may_reco
rd); |
| 88 UMA_HISTOGRAM_BOOLEAN("UMA.Dbg.UpdatePermissions.may_upload", current_may_uplo
ad); |
| 86 // If the user has opted out of metrics, delete local UKM state. | 89 // If the user has opted out of metrics, delete local UKM state. |
| 87 if (may_record_ && !current_may_record) { | 90 if (may_record_ && !current_may_record) { |
| 88 ukm::UkmService* ukm = GetUkmService(); | 91 ukm::UkmService* ukm = GetUkmService(); |
| 89 if (ukm) { | 92 if (ukm) { |
| 90 ukm->Purge(); | 93 ukm->Purge(); |
| 91 ukm->ResetClientId(); | 94 ukm->ResetClientId(); |
| 92 } | 95 } |
| 93 } | 96 } |
| 94 | 97 |
| 95 // Stash the current permissions so that we can update the RapporServiceImpl | 98 // Stash the current permissions so that we can update the RapporServiceImpl |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 153 } |
| 151 } | 154 } |
| 152 | 155 |
| 153 void MetricsServicesManager::UpdateUploadPermissions(bool may_upload) { | 156 void MetricsServicesManager::UpdateUploadPermissions(bool may_upload) { |
| 154 UpdatePermissions((client_->IsMetricsReportingForceEnabled() || | 157 UpdatePermissions((client_->IsMetricsReportingForceEnabled() || |
| 155 client_->IsMetricsReportingEnabled()), | 158 client_->IsMetricsReportingEnabled()), |
| 156 client_->IsMetricsReportingForceEnabled() || may_upload); | 159 client_->IsMetricsReportingForceEnabled() || may_upload); |
| 157 } | 160 } |
| 158 | 161 |
| 159 } // namespace metrics_services_manager | 162 } // namespace metrics_services_manager |
| OLD | NEW |