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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "chrome/common/crash_keys.h" | 35 #include "chrome/common/crash_keys.h" |
36 #include "chrome/common/features.h" | 36 #include "chrome/common/features.h" |
37 #include "chrome/installer/util/util_constants.h" | 37 #include "chrome/installer/util/util_constants.h" |
38 #include "components/metrics/call_stack_profile_metrics_provider.h" | 38 #include "components/metrics/call_stack_profile_metrics_provider.h" |
39 #include "components/metrics/drive_metrics_provider.h" | 39 #include "components/metrics/drive_metrics_provider.h" |
40 #include "components/metrics/file_metrics_provider.h" | 40 #include "components/metrics/file_metrics_provider.h" |
41 #include "components/metrics/gpu/gpu_metrics_provider.h" | 41 #include "components/metrics/gpu/gpu_metrics_provider.h" |
42 #include "components/metrics/metrics_pref_names.h" | 42 #include "components/metrics/metrics_pref_names.h" |
43 #include "components/metrics/metrics_service.h" | 43 #include "components/metrics/metrics_service.h" |
44 #include "components/metrics/metrics_service_client.h" | 44 #include "components/metrics/metrics_service_client.h" |
| 45 #include "components/metrics/net/cellular_logic_helper.h" |
45 #include "components/metrics/net/net_metrics_log_uploader.h" | 46 #include "components/metrics/net/net_metrics_log_uploader.h" |
46 #include "components/metrics/net/network_metrics_provider.h" | 47 #include "components/metrics/net/network_metrics_provider.h" |
47 #include "components/metrics/net/version_utils.h" | 48 #include "components/metrics/net/version_utils.h" |
48 #include "components/metrics/profiler/profiler_metrics_provider.h" | 49 #include "components/metrics/profiler/profiler_metrics_provider.h" |
49 #include "components/metrics/profiler/tracking_synchronizer.h" | 50 #include "components/metrics/profiler/tracking_synchronizer.h" |
50 #include "components/metrics/stability_metrics_helper.h" | 51 #include "components/metrics/stability_metrics_helper.h" |
51 #include "components/metrics/ui/screen_info_metrics_provider.h" | 52 #include "components/metrics/ui/screen_info_metrics_provider.h" |
52 #include "components/metrics/url_constants.h" | 53 #include "components/metrics/url_constants.h" |
53 #include "components/omnibox/browser/omnibox_metrics_provider.h" | 54 #include "components/omnibox/browser/omnibox_metrics_provider.h" |
54 #include "components/prefs/pref_registry_simple.h" | 55 #include "components/prefs/pref_registry_simple.h" |
55 #include "components/prefs/pref_service.h" | 56 #include "components/prefs/pref_service.h" |
56 #include "components/sync_driver/device_count_metrics_provider.h" | 57 #include "components/sync_driver/device_count_metrics_provider.h" |
57 #include "components/variations/variations_associated_data.h" | |
58 #include "components/version_info/version_info.h" | 58 #include "components/version_info/version_info.h" |
59 #include "content/public/browser/browser_thread.h" | 59 #include "content/public/browser/browser_thread.h" |
60 #include "content/public/browser/histogram_fetcher.h" | 60 #include "content/public/browser/histogram_fetcher.h" |
61 #include "content/public/browser/notification_service.h" | 61 #include "content/public/browser/notification_service.h" |
62 | 62 |
63 #if BUILDFLAG(ANDROID_JAVA_UI) | 63 #if BUILDFLAG(ANDROID_JAVA_UI) |
64 #include "chrome/browser/metrics/android_metrics_provider.h" | 64 #include "chrome/browser/metrics/android_metrics_provider.h" |
65 #endif | 65 #endif |
66 | 66 |
67 #if defined(ENABLE_PRINT_PREVIEW) | 67 #if defined(ENABLE_PRINT_PREVIEW) |
(...skipping 25 matching lines...) Expand all Loading... |
93 #include "chrome/browser/signin/chrome_signin_status_metrics_provider_delegate.h
" | 93 #include "chrome/browser/signin/chrome_signin_status_metrics_provider_delegate.h
" |
94 #include "components/signin/core/browser/signin_status_metrics_provider.h" | 94 #include "components/signin/core/browser/signin_status_metrics_provider.h" |
95 #endif // !defined(OS_CHROMEOS) | 95 #endif // !defined(OS_CHROMEOS) |
96 | 96 |
97 namespace { | 97 namespace { |
98 | 98 |
99 // This specifies the amount of time to wait for all renderers to send their | 99 // This specifies the amount of time to wait for all renderers to send their |
100 // data. | 100 // data. |
101 const int kMaxHistogramGatheringWaitDuration = 60000; // 60 seconds. | 101 const int kMaxHistogramGatheringWaitDuration = 60000; // 60 seconds. |
102 | 102 |
103 // Standard interval between log uploads, in seconds. | |
104 #if defined(OS_ANDROID) | |
105 const int kStandardUploadIntervalSeconds = 5 * 60; // Five minutes. | |
106 const int kStandardUploadIntervalCellularSeconds = 15 * 60; // Fifteen minutes. | |
107 #else | |
108 const int kStandardUploadIntervalSeconds = 30 * 60; // Thirty minutes. | |
109 #endif | |
110 | |
111 // Returns true if current connection type is cellular and user is assigned to | |
112 // experimental group for enabled cellular uploads. | |
113 bool IsCellularLogicEnabled() { | |
114 if (variations::GetVariationParamValue("UMA_EnableCellularLogUpload", | |
115 "Enabled") != "true" || | |
116 variations::GetVariationParamValue("UMA_EnableCellularLogUpload", | |
117 "Optimize") == "false") { | |
118 return false; | |
119 } | |
120 | |
121 return net::NetworkChangeNotifier::IsConnectionCellular( | |
122 net::NetworkChangeNotifier::GetConnectionType()); | |
123 } | |
124 | |
125 // Checks whether it is the first time that cellular uploads logic should be | 103 // Checks whether it is the first time that cellular uploads logic should be |
126 // enabled based on whether the the preference for that logic is initialized. | 104 // enabled based on whether the the preference for that logic is initialized. |
127 // This should happen only once as the used preference will be initialized | 105 // This should happen only once as the used preference will be initialized |
128 // afterwards in |UmaSessionStats.java|. | 106 // afterwards in |UmaSessionStats.java|. |
129 bool ShouldClearSavedMetrics() { | 107 bool ShouldClearSavedMetrics() { |
130 #if BUILDFLAG(ANDROID_JAVA_UI) | 108 #if BUILDFLAG(ANDROID_JAVA_UI) |
131 PrefService* local_state = g_browser_process->local_state(); | 109 PrefService* local_state = g_browser_process->local_state(); |
132 return !local_state->HasPrefPath(metrics::prefs::kMetricsReportingEnabled) && | 110 return !local_state->HasPrefPath(metrics::prefs::kMetricsReportingEnabled) && |
133 variations::GetVariationParamValue("UMA_EnableCellularLogUpload", | 111 metrics::IsCellularLogicEnabled(); |
134 "Enabled") == "true"; | |
135 #else | 112 #else |
136 return false; | 113 return false; |
137 #endif | 114 #endif |
138 } | 115 } |
139 | 116 |
140 void RegisterInstallerFileMetricsPreferences(PrefRegistrySimple* registry) { | 117 void RegisterInstallerFileMetricsPreferences(PrefRegistrySimple* registry) { |
141 #if defined(OS_WIN) | 118 #if defined(OS_WIN) |
142 metrics::FileMetricsProvider::RegisterPrefs( | 119 metrics::FileMetricsProvider::RegisterPrefs( |
143 registry, installer::kSetupHistogramAllocatorName); | 120 registry, installer::kSetupHistogramAllocatorName); |
144 #endif | 121 #endif |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 ChromeMetricsServiceClient::CreateUploader( | 284 ChromeMetricsServiceClient::CreateUploader( |
308 const base::Callback<void(int)>& on_upload_complete) { | 285 const base::Callback<void(int)>& on_upload_complete) { |
309 return std::unique_ptr<metrics::MetricsLogUploader>( | 286 return std::unique_ptr<metrics::MetricsLogUploader>( |
310 new metrics::NetMetricsLogUploader( | 287 new metrics::NetMetricsLogUploader( |
311 g_browser_process->system_request_context(), | 288 g_browser_process->system_request_context(), |
312 metrics::kDefaultMetricsServerUrl, metrics::kDefaultMetricsMimeType, | 289 metrics::kDefaultMetricsServerUrl, metrics::kDefaultMetricsMimeType, |
313 on_upload_complete)); | 290 on_upload_complete)); |
314 } | 291 } |
315 | 292 |
316 base::TimeDelta ChromeMetricsServiceClient::GetStandardUploadInterval() { | 293 base::TimeDelta ChromeMetricsServiceClient::GetStandardUploadInterval() { |
317 #if defined(OS_ANDROID) | 294 return metrics::GetUploadInterval(); |
318 if (IsCellularLogicEnabled()) | |
319 return base::TimeDelta::FromSeconds(kStandardUploadIntervalCellularSeconds); | |
320 #endif | |
321 return base::TimeDelta::FromSeconds(kStandardUploadIntervalSeconds); | |
322 } | 295 } |
323 | 296 |
324 base::string16 ChromeMetricsServiceClient::GetRegistryBackupKey() { | 297 base::string16 ChromeMetricsServiceClient::GetRegistryBackupKey() { |
325 #if defined(OS_WIN) | 298 #if defined(OS_WIN) |
326 BrowserDistribution* distribution = BrowserDistribution::GetDistribution(); | 299 BrowserDistribution* distribution = BrowserDistribution::GetDistribution(); |
327 return distribution->GetRegistryPath().append(L"\\StabilityMetrics"); | 300 return distribution->GetRegistryPath().append(L"\\StabilityMetrics"); |
328 #else | 301 #else |
329 return base::string16(); | 302 return base::string16(); |
330 #endif | 303 #endif |
331 } | 304 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 369 |
397 RegisterInstallerFileMetricsProvider(metrics_service_.get()); | 370 RegisterInstallerFileMetricsProvider(metrics_service_.get()); |
398 | 371 |
399 drive_metrics_provider_ = new metrics::DriveMetricsProvider( | 372 drive_metrics_provider_ = new metrics::DriveMetricsProvider( |
400 content::BrowserThread::GetMessageLoopProxyForThread( | 373 content::BrowserThread::GetMessageLoopProxyForThread( |
401 content::BrowserThread::FILE), | 374 content::BrowserThread::FILE), |
402 chrome::FILE_LOCAL_STATE); | 375 chrome::FILE_LOCAL_STATE); |
403 metrics_service_->RegisterMetricsProvider( | 376 metrics_service_->RegisterMetricsProvider( |
404 std::unique_ptr<metrics::MetricsProvider>(drive_metrics_provider_)); | 377 std::unique_ptr<metrics::MetricsProvider>(drive_metrics_provider_)); |
405 | 378 |
406 profiler_metrics_provider_ = | 379 profiler_metrics_provider_ = new metrics::ProfilerMetricsProvider( |
407 new metrics::ProfilerMetricsProvider(base::Bind(&IsCellularLogicEnabled)); | 380 base::Bind(&metrics::IsCellularLogicEnabled)); |
408 metrics_service_->RegisterMetricsProvider( | 381 metrics_service_->RegisterMetricsProvider( |
409 std::unique_ptr<metrics::MetricsProvider>(profiler_metrics_provider_)); | 382 std::unique_ptr<metrics::MetricsProvider>(profiler_metrics_provider_)); |
410 | 383 |
411 metrics_service_->RegisterMetricsProvider( | 384 metrics_service_->RegisterMetricsProvider( |
412 std::unique_ptr<metrics::MetricsProvider>( | 385 std::unique_ptr<metrics::MetricsProvider>( |
413 new metrics::CallStackProfileMetricsProvider)); | 386 new metrics::CallStackProfileMetricsProvider)); |
414 | 387 |
415 #if BUILDFLAG(ANDROID_JAVA_UI) | 388 #if BUILDFLAG(ANDROID_JAVA_UI) |
416 metrics_service_->RegisterMetricsProvider( | 389 metrics_service_->RegisterMetricsProvider( |
417 std::unique_ptr<metrics::MetricsProvider>( | 390 std::unique_ptr<metrics::MetricsProvider>( |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 default: | 665 default: |
693 NOTREACHED(); | 666 NOTREACHED(); |
694 } | 667 } |
695 } | 668 } |
696 | 669 |
697 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { | 670 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { |
698 metrics_service_->OnApplicationNotIdle(); | 671 metrics_service_->OnApplicationNotIdle(); |
699 } | 672 } |
700 | 673 |
701 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { | 674 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { |
702 return IsCellularLogicEnabled(); | 675 return metrics::IsCellularLogicEnabled(); |
703 } | 676 } |
OLD | NEW |