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 "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 22 matching lines...) Expand all Loading... | |
33 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 33 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
34 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" | 34 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" |
35 #include "chrome/browser/metrics/https_engagement_metrics_provider.h" | 35 #include "chrome/browser/metrics/https_engagement_metrics_provider.h" |
36 #include "chrome/browser/metrics/metrics_reporting_state.h" | 36 #include "chrome/browser/metrics/metrics_reporting_state.h" |
37 #include "chrome/browser/metrics/network_quality_estimator_provider_impl.h" | 37 #include "chrome/browser/metrics/network_quality_estimator_provider_impl.h" |
38 #include "chrome/browser/metrics/sampling_metrics_provider.h" | 38 #include "chrome/browser/metrics/sampling_metrics_provider.h" |
39 #include "chrome/browser/metrics/subprocess_metrics_provider.h" | 39 #include "chrome/browser/metrics/subprocess_metrics_provider.h" |
40 #include "chrome/browser/profiles/profile_manager.h" | 40 #include "chrome/browser/profiles/profile_manager.h" |
41 #include "chrome/browser/safe_browsing/certificate_reporting_metrics_provider.h" | 41 #include "chrome/browser/safe_browsing/certificate_reporting_metrics_provider.h" |
42 #include "chrome/browser/sync/chrome_sync_client.h" | 42 #include "chrome/browser/sync/chrome_sync_client.h" |
43 #include "chrome/browser/sync/profile_sync_service_factory.h" | |
43 #include "chrome/browser/ui/browser_otr_state.h" | 44 #include "chrome/browser/ui/browser_otr_state.h" |
44 #include "chrome/common/channel_info.h" | 45 #include "chrome/common/channel_info.h" |
45 #include "chrome/common/chrome_paths.h" | 46 #include "chrome/common/chrome_paths.h" |
46 #include "chrome/common/chrome_paths_internal.h" | 47 #include "chrome/common/chrome_paths_internal.h" |
47 #include "chrome/common/chrome_switches.h" | 48 #include "chrome/common/chrome_switches.h" |
48 #include "chrome/common/crash_keys.h" | 49 #include "chrome/common/crash_keys.h" |
49 #include "chrome/common/features.h" | 50 #include "chrome/common/features.h" |
50 #include "chrome/common/pref_names.h" | 51 #include "chrome/common/pref_names.h" |
51 #include "chrome/installer/util/util_constants.h" | 52 #include "chrome/installer/util/util_constants.h" |
53 #include "components/browser_sync/profile_sync_service.h" | |
52 #include "components/browser_watcher/stability_debugging.h" | 54 #include "components/browser_watcher/stability_debugging.h" |
53 #include "components/history/core/browser/history_service.h" | 55 #include "components/history/core/browser/history_service.h" |
54 #include "components/metrics/call_stack_profile_metrics_provider.h" | 56 #include "components/metrics/call_stack_profile_metrics_provider.h" |
55 #include "components/metrics/drive_metrics_provider.h" | 57 #include "components/metrics/drive_metrics_provider.h" |
56 #include "components/metrics/file_metrics_provider.h" | 58 #include "components/metrics/file_metrics_provider.h" |
57 #include "components/metrics/gpu/gpu_metrics_provider.h" | 59 #include "components/metrics/gpu/gpu_metrics_provider.h" |
58 #include "components/metrics/metrics_pref_names.h" | 60 #include "components/metrics/metrics_pref_names.h" |
59 #include "components/metrics/metrics_reporting_default_state.h" | 61 #include "components/metrics/metrics_reporting_default_state.h" |
60 #include "components/metrics/metrics_service.h" | 62 #include "components/metrics/metrics_service.h" |
61 #include "components/metrics/metrics_service_client.h" | 63 #include "components/metrics/metrics_service_client.h" |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
876 omnibox_url_opened_subscription_ = | 878 omnibox_url_opened_subscription_ = |
877 OmniboxEventGlobalTracker::GetInstance()->RegisterCallback( | 879 OmniboxEventGlobalTracker::GetInstance()->RegisterCallback( |
878 base::Bind(&ChromeMetricsServiceClient::OnURLOpenedFromOmnibox, | 880 base::Bind(&ChromeMetricsServiceClient::OnURLOpenedFromOmnibox, |
879 base::Unretained(this))); | 881 base::Unretained(this))); |
880 | 882 |
881 // Observe history deletions for all profiles. | 883 // Observe history deletions for all profiles. |
882 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED, | 884 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED, |
883 content::NotificationService::AllBrowserContextsAndSources()); | 885 content::NotificationService::AllBrowserContextsAndSources()); |
884 for (Profile* profile : | 886 for (Profile* profile : |
885 g_browser_process->profile_manager()->GetLoadedProfiles()) { | 887 g_browser_process->profile_manager()->GetLoadedProfiles()) { |
886 RegisterForHistoryDeletions(profile); | 888 RegisterForProfileEvents(profile); |
887 } | 889 } |
888 } | 890 } |
889 | 891 |
890 void ChromeMetricsServiceClient::RegisterForHistoryDeletions(Profile* profile) { | 892 void ChromeMetricsServiceClient::RegisterForProfileEvents(Profile* profile) { |
891 history::HistoryService* history_service = | 893 history::HistoryService* history_service = |
892 HistoryServiceFactory::GetForProfile(profile, | 894 HistoryServiceFactory::GetForProfile(profile, |
893 ServiceAccessType::IMPLICIT_ACCESS); | 895 ServiceAccessType::IMPLICIT_ACCESS); |
894 ObserveServiceForDeletions(history_service); | 896 ObserveServiceForDeletions(history_service); |
897 browser_sync::ProfileSyncService* sync = | |
Alexei Svitkine (slow)
2017/02/01 19:31:07
Is it possible this is null?
If not, add a DCHECK
Steven Holte
2017/02/03 00:04:34
Added a null check.
| |
898 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | |
899 ObserveServiceForSyncDisables(static_cast<syncer::SyncService*>(sync)); | |
895 } | 900 } |
896 | 901 |
897 void ChromeMetricsServiceClient::Observe( | 902 void ChromeMetricsServiceClient::Observe( |
898 int type, | 903 int type, |
899 const content::NotificationSource& source, | 904 const content::NotificationSource& source, |
900 const content::NotificationDetails& details) { | 905 const content::NotificationDetails& details) { |
901 DCHECK(thread_checker_.CalledOnValidThread()); | 906 DCHECK(thread_checker_.CalledOnValidThread()); |
902 | 907 |
903 switch (type) { | 908 switch (type) { |
904 case chrome::NOTIFICATION_BROWSER_OPENED: | 909 case chrome::NOTIFICATION_BROWSER_OPENED: |
905 case chrome::NOTIFICATION_BROWSER_CLOSED: | 910 case chrome::NOTIFICATION_BROWSER_CLOSED: |
906 case chrome::NOTIFICATION_TAB_PARENTED: | 911 case chrome::NOTIFICATION_TAB_PARENTED: |
907 case chrome::NOTIFICATION_TAB_CLOSING: | 912 case chrome::NOTIFICATION_TAB_CLOSING: |
908 case content::NOTIFICATION_LOAD_STOP: | 913 case content::NOTIFICATION_LOAD_STOP: |
909 case content::NOTIFICATION_LOAD_START: | 914 case content::NOTIFICATION_LOAD_START: |
910 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: | 915 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: |
911 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: | 916 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: |
912 metrics_service_->OnApplicationNotIdle(); | 917 metrics_service_->OnApplicationNotIdle(); |
913 break; | 918 break; |
914 | 919 |
915 case chrome::NOTIFICATION_PROFILE_ADDED: | 920 case chrome::NOTIFICATION_PROFILE_ADDED: |
916 RegisterForHistoryDeletions(content::Source<Profile>(source).ptr()); | 921 RegisterForProfileEvents(content::Source<Profile>(source).ptr()); |
917 break; | 922 break; |
918 | 923 |
919 default: | 924 default: |
920 NOTREACHED(); | 925 NOTREACHED(); |
921 } | 926 } |
922 } | 927 } |
923 | 928 |
924 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { | 929 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { |
925 metrics_service_->OnApplicationNotIdle(); | 930 metrics_service_->OnApplicationNotIdle(); |
926 } | 931 } |
927 | 932 |
928 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { | 933 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { |
929 return metrics::IsCellularLogicEnabled(); | 934 return metrics::IsCellularLogicEnabled(); |
930 } | 935 } |
931 | 936 |
932 void ChromeMetricsServiceClient::OnHistoryDeleted() { | 937 void ChromeMetricsServiceClient::OnHistoryDeleted() { |
933 if (ukm_service_) | 938 if (ukm_service_) |
934 ukm_service_->Purge(); | 939 ukm_service_->Purge(); |
935 } | 940 } |
941 | |
942 void ChromeMetricsServiceClient::OnSyncPrefsChanged(bool must_purge) { | |
943 if (ukm_service_) { | |
944 if (must_purge) | |
945 ukm_service_->Purge(); | |
946 if (update_running_services_) | |
rkaplow
2017/02/01 16:40:55
can you comment on why this is needed
Steven Holte
2017/02/03 00:04:34
Done.
| |
947 update_running_services_.Run(); | |
948 } | |
949 } | |
OLD | NEW |