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 } |
| 21 |
| 22 NetworkQualityEstimatorProviderImpl::~NetworkQualityEstimatorProviderImpl() { |
| 23 DCHECK(thread_checker_.CalledOnValidThread()); |
| 24 } |
| 25 |
| 26 scoped_refptr<base::SequencedTaskRunner> |
| 27 NetworkQualityEstimatorProviderImpl::GetTaskRunner() { |
| 28 DCHECK(thread_checker_.CalledOnValidThread()); |
| 29 // |this| is constructed on UI thread, but must be used on the IO thread. |
| 30 thread_checker_.DetachFromThread(); |
| 31 return content::BrowserThread::GetTaskRunnerForThread( |
| 32 content::BrowserThread::IO); |
| 33 } |
| 34 |
| 35 net::NetworkQualityEstimator* |
| 36 NetworkQualityEstimatorProviderImpl::GetNetworkQualityEstimator() { |
| 37 DCHECK(thread_checker_.CalledOnValidThread()); |
| 38 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 39 return io_thread_->globals()->network_quality_estimator.get(); |
| 40 } |
| 41 |
| 42 } // namespace metrics |
OLD | NEW |