OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "net/nqe/network_quality_estimator.h" | 5 #include "net/nqe/network_quality_estimator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <utility> | 10 #include <utility> |
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 estimated_transport_rtt_is_higher_than_threshold || | 1356 estimated_transport_rtt_is_higher_than_threshold || |
1357 estimated_throughput_is_lower_than_threshold) { | 1357 estimated_throughput_is_lower_than_threshold) { |
1358 return type; | 1358 return type; |
1359 } | 1359 } |
1360 } | 1360 } |
1361 // Return the fastest connection type. | 1361 // Return the fastest connection type. |
1362 return static_cast<EffectiveConnectionType>(EFFECTIVE_CONNECTION_TYPE_LAST - | 1362 return static_cast<EffectiveConnectionType>(EFFECTIVE_CONNECTION_TYPE_LAST - |
1363 1); | 1363 1); |
1364 } | 1364 } |
1365 | 1365 |
1366 nqe::internal::NetworkQualityStore* | |
1367 NetworkQualityEstimator::NetworkQualityStoreForTesting() const { | |
1368 DCHECK(thread_checker_.CalledOnValidThread()); | |
1369 return network_quality_store_.get(); | |
1370 } | |
1371 | |
1372 void NetworkQualityEstimator::AddEffectiveConnectionTypeObserver( | 1366 void NetworkQualityEstimator::AddEffectiveConnectionTypeObserver( |
1373 EffectiveConnectionTypeObserver* observer) { | 1367 EffectiveConnectionTypeObserver* observer) { |
1374 DCHECK(thread_checker_.CalledOnValidThread()); | 1368 DCHECK(thread_checker_.CalledOnValidThread()); |
1375 effective_connection_type_observer_list_.AddObserver(observer); | 1369 effective_connection_type_observer_list_.AddObserver(observer); |
1376 } | 1370 } |
1377 | 1371 |
1378 void NetworkQualityEstimator::RemoveEffectiveConnectionTypeObserver( | 1372 void NetworkQualityEstimator::RemoveEffectiveConnectionTypeObserver( |
1379 EffectiveConnectionTypeObserver* observer) { | 1373 EffectiveConnectionTypeObserver* observer) { |
1380 DCHECK(thread_checker_.CalledOnValidThread()); | 1374 DCHECK(thread_checker_.CalledOnValidThread()); |
1381 effective_connection_type_observer_list_.RemoveObserver(observer); | 1375 effective_connection_type_observer_list_.RemoveObserver(observer); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1710 // Add the estimates of the current network to the cache store. | 1704 // Add the estimates of the current network to the cache store. |
1711 if (effective_connection_type_ != EFFECTIVE_CONNECTION_TYPE_UNKNOWN) { | 1705 if (effective_connection_type_ != EFFECTIVE_CONNECTION_TYPE_UNKNOWN) { |
1712 network_quality_store_->Add( | 1706 network_quality_store_->Add( |
1713 current_network_id_, | 1707 current_network_id_, |
1714 nqe::internal::CachedNetworkQuality( | 1708 nqe::internal::CachedNetworkQuality( |
1715 tick_clock_->NowTicks(), estimated_quality_at_last_main_frame_, | 1709 tick_clock_->NowTicks(), estimated_quality_at_last_main_frame_, |
1716 effective_connection_type_)); | 1710 effective_connection_type_)); |
1717 } | 1711 } |
1718 } | 1712 } |
1719 | 1713 |
| 1714 void NetworkQualityEstimator::AddNetworkQualitiesCacheObserver( |
| 1715 nqe::internal::NetworkQualityStore::NetworkQualitiesCacheObserver* |
| 1716 observer) { |
| 1717 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1718 network_quality_store_->AddNetworkQualitiesCacheObserver(observer); |
| 1719 } |
| 1720 |
| 1721 void NetworkQualityEstimator::RemoveNetworkQualitiesCacheObserver( |
| 1722 nqe::internal::NetworkQualityStore::NetworkQualitiesCacheObserver* |
| 1723 observer) { |
| 1724 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1725 network_quality_store_->RemoveNetworkQualitiesCacheObserver(observer); |
| 1726 } |
| 1727 |
1720 } // namespace net | 1728 } // namespace net |
OLD | NEW |