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

Unified Diff: chrome/browser/metrics/metrics_services_manager.cc

Issue 937013002: Propogate RAPPOR permission changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/metrics/metrics_services_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/metrics_services_manager.cc
diff --git a/chrome/browser/metrics/metrics_services_manager.cc b/chrome/browser/metrics/metrics_services_manager.cc
index 53acd977e231390c84665ad5ff32236bf15aed6d..b471d9cc18966628916a8a43a41d15323e4ffca2 100644
--- a/chrome/browser/metrics/metrics_services_manager.cc
+++ b/chrome/browser/metrics/metrics_services_manager.cc
@@ -58,8 +58,14 @@ void PostStoreMetricsClientInfo(const metrics::ClientInfo& client_info) {
} // namespace
MetricsServicesManager::MetricsServicesManager(PrefService* local_state)
- : local_state_(local_state) {
+ : local_state_(local_state),
+ may_upload_(false),
+ may_record_(false) {
DCHECK(local_state);
+ pref_change_registrar_.Init(local_state);
+ pref_change_registrar_.Add(rappor::prefs::kRapporEnabled,
+ base::Bind(&MetricsServicesManager::UpdateRapporService,
+ base::Unretained(this)));
}
MetricsServicesManager::~MetricsServicesManager() {
@@ -144,8 +150,19 @@ rappor::RecordingLevel MetricsServicesManager::GetRapporRecordingLevel(
return recording_level;
}
+void MetricsServicesManager::UpdateRapporService() {
+ GetRapporService()->Update(GetRapporRecordingLevel(may_record_), may_upload_);
+}
+
void MetricsServicesManager::UpdatePermissions(bool may_record,
bool may_upload) {
+ // Stash the current permissions so that we can update the RapporService
+ // correctly when the Rappor preference changes. The metrics recording
+ // preference partially determines the initial rappor setting, and also
+ // controls whether FINE metrics are sent.
+ may_record_ = may_record;
+ may_upload_ = may_upload;
+
metrics::MetricsService* metrics = GetMetricsService();
const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
@@ -172,7 +189,7 @@ void MetricsServicesManager::UpdatePermissions(bool may_record,
metrics->Stop();
}
- GetRapporService()->Update(GetRapporRecordingLevel(may_record), may_upload);
+ UpdateRapporService();
}
void MetricsServicesManager::UpdateUploadPermissions(bool may_upload) {
« no previous file with comments | « chrome/browser/metrics/metrics_services_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698