Chromium Code Reviews| Index: chrome/browser/metrics/chrome_metrics_service_client.cc |
| diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc |
| index 2674edc9846239bbbd99dae3a27951874899b078..a468184d876ef3f361d0cbb4e7bfaf62fcf9d935 100644 |
| --- a/chrome/browser/metrics/chrome_metrics_service_client.cc |
| +++ b/chrome/browser/metrics/chrome_metrics_service_client.cc |
| @@ -28,6 +28,7 @@ |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/chrome_notification_types.h" |
| #include "chrome/browser/google/google_brand.h" |
| +#include "chrome/browser/io_thread.h" |
| #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" |
| #include "chrome/browser/metrics/https_engagement_metrics_provider.h" |
| @@ -121,6 +122,15 @@ |
| namespace { |
| +// Returns the network quality estimator. Runs on IO thread. |
| +net::NetworkQualityEstimator* GetNetworkQualityEstimatorOnIOThread( |
| + IOThread* io_thread) { |
| + if (!io_thread) |
| + return nullptr; |
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| + return io_thread->globals()->network_quality_estimator.get(); |
| +} |
| + |
| // This specifies the amount of time to wait for all renderers to send their |
| // data. |
| const int kMaxHistogramGatheringWaitDuration = 60000; // 60 seconds. |
| @@ -282,6 +292,7 @@ ChromeMetricsServiceClient::ChromeMetricsServiceClient( |
| drive_metrics_provider_(nullptr), |
| start_time_(base::TimeTicks::Now()), |
| has_uploaded_profiler_data_(false), |
| + network_metrics_provider_(nullptr), |
| weak_ptr_factory_(this) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| RecordCommandLineMetrics(); |
| @@ -569,10 +580,24 @@ void ChromeMetricsServiceClient::Initialize() { |
| std::unique_ptr<metrics::MetricsProvider>( |
| new ExtensionsMetricsProvider(metrics_state_manager_))); |
| #endif |
| + |
| + std::unique_ptr<metrics::NetworkMetricsProvider> network_metrics_provider( |
| + new metrics::NetworkMetricsProvider( |
| + content::BrowserThread::GetBlockingPool())); |
| + |
| + network_metrics_provider_ = network_metrics_provider.get(); |
| + |
| + // Get the network quality estimator on the IO thread, and provide it to the |
| + // |network_metrics_provider|. |
| + content::BrowserThread::PostTaskAndReplyWithResult( |
| + content::BrowserThread::IO, FROM_HERE, |
| + base::Bind(GetNetworkQualityEstimatorOnIOThread, |
| + g_browser_process->io_thread()), |
| + base::Bind(&ChromeMetricsServiceClient::ProvideNetworkQualityEstimator, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + |
| metrics_service_->RegisterMetricsProvider( |
| - std::unique_ptr<metrics::MetricsProvider>( |
| - new metrics::NetworkMetricsProvider( |
| - content::BrowserThread::GetBlockingPool()))); |
| + std::move(network_metrics_provider)); |
| // Currently, we configure OmniboxMetricsProvider to not log events to UMA |
| // if there is a single incognito session visible. In the future, it may |
| @@ -896,3 +921,13 @@ void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { |
| bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { |
| return metrics::IsCellularLogicEnabled(); |
| } |
| + |
| +void ChromeMetricsServiceClient::ProvideNetworkQualityEstimator( |
| + net::NetworkQualityEstimator* network_quality_estimator) const { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + // 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.
|
| + // |network_quality_estimator| runs to |network_metrics_provider_|. |
| + network_metrics_provider_->ProvideNetworkQualityEstimator( |
| + network_quality_estimator, content::BrowserThread::GetTaskRunnerForThread( |
| + content::BrowserThread::IO)); |
| +} |