OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/metrics/network_quality_estimator_provider_impl.h" |
| 6 |
| 7 #include "chrome/browser/io_thread.h" |
| 8 #include "content/public/browser/browser_thread.h" |
| 9 |
| 10 namespace net { |
| 11 class NetworkQualityEstimator; |
| 12 } |
| 13 |
| 14 namespace metrics { |
| 15 |
| 16 NetworkQualityEstimatorProviderImpl::NetworkQualityEstimatorProviderImpl( |
| 17 IOThread* io_thread) |
| 18 : io_thread_(io_thread) { |
| 19 DCHECK(io_thread_); |
| 20 // |this| is constructed on UI thread, but must be used on the IO thread. |
| 21 thread_checker_.DetachFromThread(); |
| 22 } |
| 23 |
| 24 NetworkQualityEstimatorProviderImpl::~NetworkQualityEstimatorProviderImpl() { |
| 25 DCHECK(thread_checker_.CalledOnValidThread()); |
| 26 } |
| 27 |
| 28 void NetworkQualityEstimatorProviderImpl::ProvideEstimator( |
| 29 const base::Callback<void(net::NetworkQualityEstimator*)>& callback) { |
| 30 DCHECK(thread_checker_.CalledOnValidThread()); |
| 31 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 32 callback.Run(io_thread_->globals()->network_quality_estimator.get()); |
| 33 } |
| 34 |
| 35 } // namespace metrics |
OLD | NEW |