| 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 <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 #include "components/metrics/profiler/profiler_metrics_provider.h" | 63 #include "components/metrics/profiler/profiler_metrics_provider.h" |
| 64 #include "components/metrics/profiler/tracking_synchronizer.h" | 64 #include "components/metrics/profiler/tracking_synchronizer.h" |
| 65 #include "components/metrics/stability_metrics_helper.h" | 65 #include "components/metrics/stability_metrics_helper.h" |
| 66 #include "components/metrics/ui/screen_info_metrics_provider.h" | 66 #include "components/metrics/ui/screen_info_metrics_provider.h" |
| 67 #include "components/metrics/url_constants.h" | 67 #include "components/metrics/url_constants.h" |
| 68 #include "components/omnibox/browser/omnibox_metrics_provider.h" | 68 #include "components/omnibox/browser/omnibox_metrics_provider.h" |
| 69 #include "components/prefs/pref_registry_simple.h" | 69 #include "components/prefs/pref_registry_simple.h" |
| 70 #include "components/prefs/pref_service.h" | 70 #include "components/prefs/pref_service.h" |
| 71 #include "components/sync/device_info/device_count_metrics_provider.h" | 71 #include "components/sync/device_info/device_count_metrics_provider.h" |
| 72 #include "components/translate/core/browser/translate_ranker_metrics_provider.h" | 72 #include "components/translate/core/browser/translate_ranker_metrics_provider.h" |
| 73 #include "components/ukm/ukm_service.h" |
| 73 #include "components/version_info/version_info.h" | 74 #include "components/version_info/version_info.h" |
| 74 #include "content/public/browser/browser_thread.h" | 75 #include "content/public/browser/browser_thread.h" |
| 75 #include "content/public/browser/histogram_fetcher.h" | 76 #include "content/public/browser/histogram_fetcher.h" |
| 76 #include "content/public/browser/notification_service.h" | 77 #include "content/public/browser/notification_service.h" |
| 77 #include "extensions/features/features.h" | 78 #include "extensions/features/features.h" |
| 78 #include "ppapi/features/features.h" | 79 #include "ppapi/features/features.h" |
| 79 #include "printing/features/features.h" | 80 #include "printing/features/features.h" |
| 80 | 81 |
| 81 #if BUILDFLAG(ANDROID_JAVA_UI) | 82 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 82 #include "chrome/browser/metrics/android_metrics_provider.h" | 83 #include "chrome/browser/metrics/android_metrics_provider.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 std::unique_ptr<ChromeMetricsServiceClient> client( | 312 std::unique_ptr<ChromeMetricsServiceClient> client( |
| 312 new ChromeMetricsServiceClient(state_manager)); | 313 new ChromeMetricsServiceClient(state_manager)); |
| 313 client->Initialize(); | 314 client->Initialize(); |
| 314 | 315 |
| 315 return client; | 316 return client; |
| 316 } | 317 } |
| 317 | 318 |
| 318 // static | 319 // static |
| 319 void ChromeMetricsServiceClient::RegisterPrefs(PrefRegistrySimple* registry) { | 320 void ChromeMetricsServiceClient::RegisterPrefs(PrefRegistrySimple* registry) { |
| 320 metrics::MetricsService::RegisterPrefs(registry); | 321 metrics::MetricsService::RegisterPrefs(registry); |
| 322 ukm::UkmService::RegisterPrefs(registry); |
| 321 metrics::StabilityMetricsHelper::RegisterPrefs(registry); | 323 metrics::StabilityMetricsHelper::RegisterPrefs(registry); |
| 322 | 324 |
| 323 RegisterFileMetricsPreferences(registry); | 325 RegisterFileMetricsPreferences(registry); |
| 324 | 326 |
| 325 metrics::RegisterMetricsReportingStatePrefs(registry); | 327 metrics::RegisterMetricsReportingStatePrefs(registry); |
| 326 | 328 |
| 327 #if BUILDFLAG(ANDROID_JAVA_UI) | 329 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 328 AndroidMetricsProvider::RegisterPrefs(registry); | 330 AndroidMetricsProvider::RegisterPrefs(registry); |
| 329 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 331 #endif // BUILDFLAG(ANDROID_JAVA_UI) |
| 330 | 332 |
| 331 #if BUILDFLAG(ENABLE_PLUGINS) | 333 #if BUILDFLAG(ENABLE_PLUGINS) |
| 332 PluginMetricsProvider::RegisterPrefs(registry); | 334 PluginMetricsProvider::RegisterPrefs(registry); |
| 333 #endif // BUILDFLAG(ENABLE_PLUGINS) | 335 #endif // BUILDFLAG(ENABLE_PLUGINS) |
| 334 } | 336 } |
| 335 | 337 |
| 336 metrics::MetricsService* ChromeMetricsServiceClient::GetMetricsService() { | 338 metrics::MetricsService* ChromeMetricsServiceClient::GetMetricsService() { |
| 337 return metrics_service_.get(); | 339 return metrics_service_.get(); |
| 338 } | 340 } |
| 339 | 341 |
| 342 ukm::UkmService* ChromeMetricsServiceClient::GetUkmService() { |
| 343 return ukm_service_.get(); |
| 344 } |
| 345 |
| 340 void ChromeMetricsServiceClient::SetMetricsClientId( | 346 void ChromeMetricsServiceClient::SetMetricsClientId( |
| 341 const std::string& client_id) { | 347 const std::string& client_id) { |
| 342 crash_keys::SetMetricsClientIdFromGUID(client_id); | 348 crash_keys::SetMetricsClientIdFromGUID(client_id); |
| 343 } | 349 } |
| 344 | 350 |
| 345 int32_t ChromeMetricsServiceClient::GetProduct() { | 351 int32_t ChromeMetricsServiceClient::GetProduct() { |
| 346 return metrics::ChromeUserMetricsExtension::CHROME; | 352 return metrics::ChromeUserMetricsExtension::CHROME; |
| 347 } | 353 } |
| 348 | 354 |
| 349 std::string ChromeMetricsServiceClient::GetApplicationLocale() { | 355 std::string ChromeMetricsServiceClient::GetApplicationLocale() { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 // |FinishedReceivingProfilerData()| when the task completes. | 505 // |FinishedReceivingProfilerData()| when the task completes. |
| 500 metrics::TrackingSynchronizer::FetchProfilerDataAsynchronously( | 506 metrics::TrackingSynchronizer::FetchProfilerDataAsynchronously( |
| 501 weak_ptr_factory_.GetWeakPtr()); | 507 weak_ptr_factory_.GetWeakPtr()); |
| 502 } else { | 508 } else { |
| 503 CollectFinalHistograms(); | 509 CollectFinalHistograms(); |
| 504 } | 510 } |
| 505 } | 511 } |
| 506 | 512 |
| 507 std::unique_ptr<metrics::MetricsLogUploader> | 513 std::unique_ptr<metrics::MetricsLogUploader> |
| 508 ChromeMetricsServiceClient::CreateUploader( | 514 ChromeMetricsServiceClient::CreateUploader( |
| 515 const std::string& server_url, |
| 516 const std::string& mime_type, |
| 509 const base::Callback<void(int)>& on_upload_complete) { | 517 const base::Callback<void(int)>& on_upload_complete) { |
| 510 return std::unique_ptr<metrics::MetricsLogUploader>( | 518 return std::unique_ptr<metrics::MetricsLogUploader>( |
| 511 new metrics::NetMetricsLogUploader( | 519 new metrics::NetMetricsLogUploader( |
| 512 g_browser_process->system_request_context(), | 520 g_browser_process->system_request_context(), |
| 513 metrics::kDefaultMetricsServerUrl, metrics::kDefaultMetricsMimeType, | 521 server_url, mime_type, on_upload_complete)); |
| 514 on_upload_complete)); | |
| 515 } | 522 } |
| 516 | 523 |
| 517 base::TimeDelta ChromeMetricsServiceClient::GetStandardUploadInterval() { | 524 base::TimeDelta ChromeMetricsServiceClient::GetStandardUploadInterval() { |
| 518 return metrics::GetUploadInterval(); | 525 return metrics::GetUploadInterval(); |
| 519 } | 526 } |
| 520 | 527 |
| 521 base::string16 ChromeMetricsServiceClient::GetRegistryBackupKey() { | 528 base::string16 ChromeMetricsServiceClient::GetRegistryBackupKey() { |
| 522 #if defined(OS_WIN) | 529 #if defined(OS_WIN) |
| 523 BrowserDistribution* distribution = BrowserDistribution::GetDistribution(); | 530 BrowserDistribution* distribution = BrowserDistribution::GetDistribution(); |
| 524 return distribution->GetRegistryPath().append(L"\\StabilityMetrics"); | 531 return distribution->GetRegistryPath().append(L"\\StabilityMetrics"); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 551 | 558 |
| 552 // Clear deprecated metrics preference for Android. | 559 // Clear deprecated metrics preference for Android. |
| 553 // TODO(gayane): Cleanup this code after M60 when the pref would be cleared | 560 // TODO(gayane): Cleanup this code after M60 when the pref would be cleared |
| 554 // from clients. | 561 // from clients. |
| 555 #if BUILDFLAG(ANDROID_JAVA_UI) | 562 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 556 local_state->ClearPref(prefs::kCrashReportingEnabled); | 563 local_state->ClearPref(prefs::kCrashReportingEnabled); |
| 557 #endif | 564 #endif |
| 558 | 565 |
| 559 metrics_service_.reset( | 566 metrics_service_.reset( |
| 560 new metrics::MetricsService(metrics_state_manager_, this, local_state)); | 567 new metrics::MetricsService(metrics_state_manager_, this, local_state)); |
| 568 ukm_service_.reset( |
| 569 new ukm::UkmService(local_state, this)); |
| 561 | 570 |
| 562 // Gets access to persistent metrics shared by sub-processes. | 571 // Gets access to persistent metrics shared by sub-processes. |
| 563 metrics_service_->RegisterMetricsProvider( | 572 metrics_service_->RegisterMetricsProvider( |
| 564 std::unique_ptr<metrics::MetricsProvider>( | 573 std::unique_ptr<metrics::MetricsProvider>( |
| 565 new SubprocessMetricsProvider())); | 574 new SubprocessMetricsProvider())); |
| 566 | 575 |
| 567 // Register metrics providers. | 576 // Register metrics providers. |
| 568 #if BUILDFLAG(ENABLE_EXTENSIONS) | 577 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 569 metrics_service_->RegisterMetricsProvider( | 578 metrics_service_->RegisterMetricsProvider( |
| 570 std::unique_ptr<metrics::MetricsProvider>( | 579 std::unique_ptr<metrics::MetricsProvider>( |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 } | 903 } |
| 895 } | 904 } |
| 896 | 905 |
| 897 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { | 906 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { |
| 898 metrics_service_->OnApplicationNotIdle(); | 907 metrics_service_->OnApplicationNotIdle(); |
| 899 } | 908 } |
| 900 | 909 |
| 901 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { | 910 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { |
| 902 return metrics::IsCellularLogicEnabled(); | 911 return metrics::IsCellularLogicEnabled(); |
| 903 } | 912 } |
| OLD | NEW |