Chromium Code Reviews| 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 10 matching lines...) Expand all Loading... | |
| 21 #include "base/metrics/persistent_histogram_allocator.h" | 21 #include "base/metrics/persistent_histogram_allocator.h" |
| 22 #include "base/path_service.h" | 22 #include "base/path_service.h" |
| 23 #include "base/rand_util.h" | 23 #include "base/rand_util.h" |
| 24 #include "base/strings/string16.h" | 24 #include "base/strings/string16.h" |
| 25 #include "base/threading/platform_thread.h" | 25 #include "base/threading/platform_thread.h" |
| 26 #include "base/threading/thread_task_runner_handle.h" | 26 #include "base/threading/thread_task_runner_handle.h" |
| 27 #include "build/build_config.h" | 27 #include "build/build_config.h" |
| 28 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
| 29 #include "chrome/browser/chrome_notification_types.h" | 29 #include "chrome/browser/chrome_notification_types.h" |
| 30 #include "chrome/browser/google/google_brand.h" | 30 #include "chrome/browser/google/google_brand.h" |
| 31 #include "chrome/browser/io_thread.h" | |
| 31 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 32 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 32 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" | 33 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" |
| 33 #include "chrome/browser/metrics/https_engagement_metrics_provider.h" | 34 #include "chrome/browser/metrics/https_engagement_metrics_provider.h" |
| 34 #include "chrome/browser/metrics/metrics_reporting_state.h" | 35 #include "chrome/browser/metrics/metrics_reporting_state.h" |
| 35 #include "chrome/browser/metrics/sampling_metrics_provider.h" | 36 #include "chrome/browser/metrics/sampling_metrics_provider.h" |
| 36 #include "chrome/browser/metrics/subprocess_metrics_provider.h" | 37 #include "chrome/browser/metrics/subprocess_metrics_provider.h" |
| 37 #include "chrome/browser/metrics/time_ticks_experiment_win.h" | 38 #include "chrome/browser/metrics/time_ticks_experiment_win.h" |
| 38 #include "chrome/browser/sync/chrome_sync_client.h" | 39 #include "chrome/browser/sync/chrome_sync_client.h" |
| 39 #include "chrome/browser/ui/browser_otr_state.h" | 40 #include "chrome/browser/ui/browser_otr_state.h" |
| 40 #include "chrome/common/channel_info.h" | 41 #include "chrome/common/channel_info.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 #include "third_party/crashpad/crashpad/client/crashpad_info.h" | 115 #include "third_party/crashpad/crashpad/client/crashpad_info.h" |
| 115 #endif | 116 #endif |
| 116 | 117 |
| 117 #if !defined(OS_CHROMEOS) | 118 #if !defined(OS_CHROMEOS) |
| 118 #include "chrome/browser/signin/chrome_signin_status_metrics_provider_delegate.h " | 119 #include "chrome/browser/signin/chrome_signin_status_metrics_provider_delegate.h " |
| 119 #include "components/signin/core/browser/signin_status_metrics_provider.h" | 120 #include "components/signin/core/browser/signin_status_metrics_provider.h" |
| 120 #endif // !defined(OS_CHROMEOS) | 121 #endif // !defined(OS_CHROMEOS) |
| 121 | 122 |
| 122 namespace { | 123 namespace { |
| 123 | 124 |
| 125 // Returns the network quality estimator. Runs on IO thread. | |
| 126 net::NetworkQualityEstimator* GetNetworkQualityEstimatorOnIOThread( | |
| 127 IOThread* io_thread) { | |
| 128 if (!io_thread) | |
| 129 return nullptr; | |
| 130 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | |
| 131 return io_thread->globals()->network_quality_estimator.get(); | |
| 132 } | |
| 133 | |
| 124 // This specifies the amount of time to wait for all renderers to send their | 134 // This specifies the amount of time to wait for all renderers to send their |
| 125 // data. | 135 // data. |
| 126 const int kMaxHistogramGatheringWaitDuration = 60000; // 60 seconds. | 136 const int kMaxHistogramGatheringWaitDuration = 60000; // 60 seconds. |
| 127 | 137 |
| 128 // Needs to be kept in sync with the writer in | 138 // Needs to be kept in sync with the writer in |
| 129 // third_party/crashpad/crashpad/handler/handler_main.cc. | 139 // third_party/crashpad/crashpad/handler/handler_main.cc. |
| 130 const char kCrashpadHistogramAllocatorName[] = "CrashpadMetrics"; | 140 const char kCrashpadHistogramAllocatorName[] = "CrashpadMetrics"; |
| 131 | 141 |
| 132 #if defined(OS_WIN) || defined(OS_MACOSX) | 142 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 133 // The stream type assigned to the minidump stream that holds the serialized | 143 // The stream type assigned to the minidump stream that holds the serialized |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 plugin_metrics_provider_(nullptr), | 285 plugin_metrics_provider_(nullptr), |
| 276 #endif | 286 #endif |
| 277 #if defined(OS_WIN) | 287 #if defined(OS_WIN) |
| 278 google_update_metrics_provider_(nullptr), | 288 google_update_metrics_provider_(nullptr), |
| 279 watcher_metrics_provider_(nullptr), | 289 watcher_metrics_provider_(nullptr), |
| 280 antivirus_metrics_provider_(nullptr), | 290 antivirus_metrics_provider_(nullptr), |
| 281 #endif | 291 #endif |
| 282 drive_metrics_provider_(nullptr), | 292 drive_metrics_provider_(nullptr), |
| 283 start_time_(base::TimeTicks::Now()), | 293 start_time_(base::TimeTicks::Now()), |
| 284 has_uploaded_profiler_data_(false), | 294 has_uploaded_profiler_data_(false), |
| 295 network_metrics_provider_(nullptr), | |
| 285 weak_ptr_factory_(this) { | 296 weak_ptr_factory_(this) { |
| 286 DCHECK(thread_checker_.CalledOnValidThread()); | 297 DCHECK(thread_checker_.CalledOnValidThread()); |
| 287 RecordCommandLineMetrics(); | 298 RecordCommandLineMetrics(); |
| 288 RegisterForNotifications(); | 299 RegisterForNotifications(); |
| 289 } | 300 } |
| 290 | 301 |
| 291 ChromeMetricsServiceClient::~ChromeMetricsServiceClient() { | 302 ChromeMetricsServiceClient::~ChromeMetricsServiceClient() { |
| 292 DCHECK(thread_checker_.CalledOnValidThread()); | 303 DCHECK(thread_checker_.CalledOnValidThread()); |
| 293 base::GlobalHistogramAllocator* allocator = | 304 base::GlobalHistogramAllocator* allocator = |
| 294 base::GlobalHistogramAllocator::Get(); | 305 base::GlobalHistogramAllocator::Get(); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 metrics_service_->RegisterMetricsProvider( | 573 metrics_service_->RegisterMetricsProvider( |
| 563 std::unique_ptr<metrics::MetricsProvider>( | 574 std::unique_ptr<metrics::MetricsProvider>( |
| 564 new SubprocessMetricsProvider())); | 575 new SubprocessMetricsProvider())); |
| 565 | 576 |
| 566 // Register metrics providers. | 577 // Register metrics providers. |
| 567 #if BUILDFLAG(ENABLE_EXTENSIONS) | 578 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 568 metrics_service_->RegisterMetricsProvider( | 579 metrics_service_->RegisterMetricsProvider( |
| 569 std::unique_ptr<metrics::MetricsProvider>( | 580 std::unique_ptr<metrics::MetricsProvider>( |
| 570 new ExtensionsMetricsProvider(metrics_state_manager_))); | 581 new ExtensionsMetricsProvider(metrics_state_manager_))); |
| 571 #endif | 582 #endif |
| 583 | |
| 584 std::unique_ptr<metrics::NetworkMetricsProvider> network_metrics_provider( | |
| 585 new metrics::NetworkMetricsProvider( | |
| 586 content::BrowserThread::GetBlockingPool())); | |
| 587 | |
| 588 network_metrics_provider_ = network_metrics_provider.get(); | |
| 589 | |
| 590 // Get the network quality estimator on the IO thread, and provide it to the | |
| 591 // |network_metrics_provider|. | |
| 592 content::BrowserThread::PostTaskAndReplyWithResult( | |
| 593 content::BrowserThread::IO, FROM_HERE, | |
| 594 base::Bind(GetNetworkQualityEstimatorOnIOThread, | |
| 595 g_browser_process->io_thread()), | |
| 596 base::Bind(&ChromeMetricsServiceClient::ProvideNetworkQualityEstimator, | |
| 597 weak_ptr_factory_.GetWeakPtr())); | |
| 598 | |
| 572 metrics_service_->RegisterMetricsProvider( | 599 metrics_service_->RegisterMetricsProvider( |
| 573 std::unique_ptr<metrics::MetricsProvider>( | 600 std::move(network_metrics_provider)); |
| 574 new metrics::NetworkMetricsProvider( | |
| 575 content::BrowserThread::GetBlockingPool()))); | |
| 576 | 601 |
| 577 // Currently, we configure OmniboxMetricsProvider to not log events to UMA | 602 // Currently, we configure OmniboxMetricsProvider to not log events to UMA |
| 578 // if there is a single incognito session visible. In the future, it may | 603 // if there is a single incognito session visible. In the future, it may |
| 579 // be worth revisiting this to still log events from non-incognito sessions. | 604 // be worth revisiting this to still log events from non-incognito sessions. |
| 580 metrics_service_->RegisterMetricsProvider( | 605 metrics_service_->RegisterMetricsProvider( |
| 581 std::unique_ptr<metrics::MetricsProvider>(new OmniboxMetricsProvider( | 606 std::unique_ptr<metrics::MetricsProvider>(new OmniboxMetricsProvider( |
| 582 base::Bind(&chrome::IsIncognitoSessionActive)))); | 607 base::Bind(&chrome::IsIncognitoSessionActive)))); |
| 583 metrics_service_->RegisterMetricsProvider( | 608 metrics_service_->RegisterMetricsProvider( |
| 584 std::unique_ptr<metrics::MetricsProvider>( | 609 std::unique_ptr<metrics::MetricsProvider>( |
| 585 new ChromeStabilityMetricsProvider(local_state))); | 610 new ChromeStabilityMetricsProvider(local_state))); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 889 } | 914 } |
| 890 } | 915 } |
| 891 | 916 |
| 892 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { | 917 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { |
| 893 metrics_service_->OnApplicationNotIdle(); | 918 metrics_service_->OnApplicationNotIdle(); |
| 894 } | 919 } |
| 895 | 920 |
| 896 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { | 921 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { |
| 897 return metrics::IsCellularLogicEnabled(); | 922 return metrics::IsCellularLogicEnabled(); |
| 898 } | 923 } |
| 924 | |
| 925 void ChromeMetricsServiceClient::ProvideNetworkQualityEstimator( | |
| 926 net::NetworkQualityEstimator* network_quality_estimator) const { | |
| 927 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 928 // Provide the |network_quality_estimator| and the thread on which | |
|
RyanSturm
2016/12/28 21:53:11
nit: s/the thread/the taskrunner for the thread/
tbansal1
2017/01/03 17:25:13
Done.
| |
| 929 // |network_quality_estimator| runs to |network_metrics_provider_|. | |
| 930 network_metrics_provider_->ProvideNetworkQualityEstimator( | |
| 931 network_quality_estimator, content::BrowserThread::GetTaskRunnerForThread( | |
| 932 content::BrowserThread::IO)); | |
| 933 } | |
| OLD | NEW |