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

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

Issue 2653693004: UKM Sync Observer (Closed)
Patch Set: Address comments Created 3 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 unified diff | Download patch
OLDNEW
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 "chrome/browser/metrics/chrome_metrics_service_client.h" 5 #include "chrome/browser/metrics/chrome_metrics_service_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 23 matching lines...) Expand all
34 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 34 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
35 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" 35 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h"
36 #include "chrome/browser/metrics/https_engagement_metrics_provider.h" 36 #include "chrome/browser/metrics/https_engagement_metrics_provider.h"
37 #include "chrome/browser/metrics/metrics_reporting_state.h" 37 #include "chrome/browser/metrics/metrics_reporting_state.h"
38 #include "chrome/browser/metrics/network_quality_estimator_provider_impl.h" 38 #include "chrome/browser/metrics/network_quality_estimator_provider_impl.h"
39 #include "chrome/browser/metrics/sampling_metrics_provider.h" 39 #include "chrome/browser/metrics/sampling_metrics_provider.h"
40 #include "chrome/browser/metrics/subprocess_metrics_provider.h" 40 #include "chrome/browser/metrics/subprocess_metrics_provider.h"
41 #include "chrome/browser/profiles/profile_manager.h" 41 #include "chrome/browser/profiles/profile_manager.h"
42 #include "chrome/browser/safe_browsing/certificate_reporting_metrics_provider.h" 42 #include "chrome/browser/safe_browsing/certificate_reporting_metrics_provider.h"
43 #include "chrome/browser/sync/chrome_sync_client.h" 43 #include "chrome/browser/sync/chrome_sync_client.h"
44 #include "chrome/browser/sync/profile_sync_service_factory.h"
44 #include "chrome/browser/ui/browser_otr_state.h" 45 #include "chrome/browser/ui/browser_otr_state.h"
45 #include "chrome/common/channel_info.h" 46 #include "chrome/common/channel_info.h"
46 #include "chrome/common/chrome_paths.h" 47 #include "chrome/common/chrome_paths.h"
47 #include "chrome/common/chrome_paths_internal.h" 48 #include "chrome/common/chrome_paths_internal.h"
48 #include "chrome/common/chrome_switches.h" 49 #include "chrome/common/chrome_switches.h"
49 #include "chrome/common/crash_keys.h" 50 #include "chrome/common/crash_keys.h"
50 #include "chrome/common/features.h" 51 #include "chrome/common/features.h"
51 #include "chrome/common/pref_names.h" 52 #include "chrome/common/pref_names.h"
52 #include "chrome/installer/util/util_constants.h" 53 #include "chrome/installer/util/util_constants.h"
54 #include "components/browser_sync/profile_sync_service.h"
53 #include "components/browser_watcher/stability_debugging.h" 55 #include "components/browser_watcher/stability_debugging.h"
54 #include "components/history/core/browser/history_service.h" 56 #include "components/history/core/browser/history_service.h"
55 #include "components/metrics/call_stack_profile_metrics_provider.h" 57 #include "components/metrics/call_stack_profile_metrics_provider.h"
56 #include "components/metrics/drive_metrics_provider.h" 58 #include "components/metrics/drive_metrics_provider.h"
57 #include "components/metrics/file_metrics_provider.h" 59 #include "components/metrics/file_metrics_provider.h"
58 #include "components/metrics/gpu/gpu_metrics_provider.h" 60 #include "components/metrics/gpu/gpu_metrics_provider.h"
59 #include "components/metrics/metrics_pref_names.h" 61 #include "components/metrics/metrics_pref_names.h"
60 #include "components/metrics/metrics_reporting_default_state.h" 62 #include "components/metrics/metrics_reporting_default_state.h"
61 #include "components/metrics/metrics_service.h" 63 #include "components/metrics/metrics_service.h"
62 #include "components/metrics/metrics_service_client.h" 64 #include "components/metrics/metrics_service_client.h"
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 omnibox_url_opened_subscription_ = 872 omnibox_url_opened_subscription_ =
871 OmniboxEventGlobalTracker::GetInstance()->RegisterCallback( 873 OmniboxEventGlobalTracker::GetInstance()->RegisterCallback(
872 base::Bind(&ChromeMetricsServiceClient::OnURLOpenedFromOmnibox, 874 base::Bind(&ChromeMetricsServiceClient::OnURLOpenedFromOmnibox,
873 base::Unretained(this))); 875 base::Unretained(this)));
874 876
875 // Observe history deletions for all profiles. 877 // Observe history deletions for all profiles.
876 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED, 878 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED,
877 content::NotificationService::AllBrowserContextsAndSources()); 879 content::NotificationService::AllBrowserContextsAndSources());
878 for (Profile* profile : 880 for (Profile* profile :
879 g_browser_process->profile_manager()->GetLoadedProfiles()) { 881 g_browser_process->profile_manager()->GetLoadedProfiles()) {
880 RegisterForHistoryDeletions(profile); 882 RegisterForProfileEvents(profile);
881 } 883 }
882 } 884 }
883 885
884 void ChromeMetricsServiceClient::RegisterForHistoryDeletions(Profile* profile) { 886 void ChromeMetricsServiceClient::RegisterForProfileEvents(Profile* profile) {
885 history::HistoryService* history_service = 887 history::HistoryService* history_service =
886 HistoryServiceFactory::GetForProfile(profile, 888 HistoryServiceFactory::GetForProfile(profile,
887 ServiceAccessType::IMPLICIT_ACCESS); 889 ServiceAccessType::IMPLICIT_ACCESS);
888 ObserveServiceForDeletions(history_service); 890 ObserveServiceForDeletions(history_service);
891 browser_sync::ProfileSyncService* sync =
892 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
893 if (sync)
894 ObserveServiceForSyncDisables(static_cast<syncer::SyncService*>(sync));
889 } 895 }
890 896
891 void ChromeMetricsServiceClient::Observe( 897 void ChromeMetricsServiceClient::Observe(
892 int type, 898 int type,
893 const content::NotificationSource& source, 899 const content::NotificationSource& source,
894 const content::NotificationDetails& details) { 900 const content::NotificationDetails& details) {
895 DCHECK(thread_checker_.CalledOnValidThread()); 901 DCHECK(thread_checker_.CalledOnValidThread());
896 902
897 switch (type) { 903 switch (type) {
898 case chrome::NOTIFICATION_BROWSER_OPENED: 904 case chrome::NOTIFICATION_BROWSER_OPENED:
899 case chrome::NOTIFICATION_BROWSER_CLOSED: 905 case chrome::NOTIFICATION_BROWSER_CLOSED:
900 case chrome::NOTIFICATION_TAB_PARENTED: 906 case chrome::NOTIFICATION_TAB_PARENTED:
901 case chrome::NOTIFICATION_TAB_CLOSING: 907 case chrome::NOTIFICATION_TAB_CLOSING:
902 case content::NOTIFICATION_LOAD_STOP: 908 case content::NOTIFICATION_LOAD_STOP:
903 case content::NOTIFICATION_LOAD_START: 909 case content::NOTIFICATION_LOAD_START:
904 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: 910 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED:
905 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: 911 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG:
906 metrics_service_->OnApplicationNotIdle(); 912 metrics_service_->OnApplicationNotIdle();
907 break; 913 break;
908 914
909 case chrome::NOTIFICATION_PROFILE_ADDED: 915 case chrome::NOTIFICATION_PROFILE_ADDED:
skym 2017/02/03 01:03:59 I'm worried unimportant profiles are going to keep
Steven Holte 2017/02/04 00:16:32 I'm not too worried about this since the multi-pro
skym 2017/02/07 16:45:44 Okay. Thanks for adding the histogram to track thi
910 RegisterForHistoryDeletions(content::Source<Profile>(source).ptr()); 916 RegisterForProfileEvents(content::Source<Profile>(source).ptr());
911 break; 917 break;
912 918
913 default: 919 default:
914 NOTREACHED(); 920 NOTREACHED();
915 } 921 }
916 } 922 }
917 923
918 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { 924 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) {
919 metrics_service_->OnApplicationNotIdle(); 925 metrics_service_->OnApplicationNotIdle();
920 } 926 }
921 927
922 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { 928 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() {
923 return metrics::IsCellularLogicEnabled(); 929 return metrics::IsCellularLogicEnabled();
924 } 930 }
925 931
926 void ChromeMetricsServiceClient::OnHistoryDeleted() { 932 void ChromeMetricsServiceClient::OnHistoryDeleted() {
927 if (ukm_service_) 933 if (ukm_service_)
928 ukm_service_->Purge(); 934 ukm_service_->Purge();
929 } 935 }
936
937 void ChromeMetricsServiceClient::OnSyncPrefsChanged(bool must_purge) {
938 if (ukm_service_) {
939 if (must_purge)
940 ukm_service_->Purge();
941 // Signal service manager to enable/disable UKM based on new state.
942 if (update_running_services_)
943 update_running_services_.Run();
944 }
945 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698