OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 "net/base/network_quality_estimator_watcher_factory.h" |
| 6 |
| 7 #include "base/location.h" |
| 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/time/time.h" |
| 10 #include "net/base/network_quality_estimator.h" |
| 11 |
| 12 namespace net { |
| 13 |
| 14 NetworkQualityEstimatorWatcherFactory::NetworkQualityEstimatorWatcherFactory( |
| 15 const base::WeakPtr<NetworkQualityEstimator>& network_quality_estimator, |
| 16 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) |
| 17 : network_quality_estimator_(network_quality_estimator), |
| 18 task_runner_(task_runner) { |
| 19 DCHECK(network_quality_estimator_); |
| 20 DCHECK(task_runner_); |
| 21 } |
| 22 |
| 23 NetworkQualityEstimatorWatcherFactory:: |
| 24 ~NetworkQualityEstimatorWatcherFactory() {} |
| 25 |
| 26 scoped_ptr<SocketPerformanceWatcher> |
| 27 NetworkQualityEstimatorWatcherFactory::CreateSocketPerformanceWatcher( |
| 28 const Protocol protocol) { |
| 29 return scoped_ptr<SocketPerformanceWatcher>( |
| 30 new SocketPerformanceWatcher(protocol, this)); |
| 31 } |
| 32 |
| 33 void NetworkQualityEstimatorWatcherFactory::OnUpdatedRTTAvailable( |
| 34 const Protocol protocol, |
| 35 const base::TimeDelta& rtt) { |
| 36 task_runner_->PostTask( |
| 37 FROM_HERE, base::Bind(&NetworkQualityEstimator::OnUpdatedRTTAvailable, |
| 38 network_quality_estimator_, protocol, rtt)); |
| 39 } |
| 40 |
| 41 void NetworkQualityEstimatorWatcherFactory::OnWatcherReset() { |
| 42 task_runner_->PostTask(FROM_HERE, |
| 43 base::Bind(&NetworkQualityEstimator::OnWatcherReset, |
| 44 network_quality_estimator_)); |
| 45 } |
| 46 |
| 47 } // namespace net |
OLD | NEW |