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 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1760 nqe::internal::CachedNetworkQuality cached_network_quality( | 1760 nqe::internal::CachedNetworkQuality cached_network_quality( |
1761 base::TimeTicks::Now(), | 1761 base::TimeTicks::Now(), |
1762 params_.TypicalNetworkQuality(effective_connection_type), | 1762 params_.TypicalNetworkQuality(effective_connection_type), |
1763 effective_connection_type); | 1763 effective_connection_type); |
1764 | 1764 |
1765 network_quality_store_->Add(it.first, cached_network_quality); | 1765 network_quality_store_->Add(it.first, cached_network_quality); |
1766 MaybeUpdateNetworkQualityFromCache(it.first, cached_network_quality); | 1766 MaybeUpdateNetworkQualityFromCache(it.first, cached_network_quality); |
1767 } | 1767 } |
1768 } | 1768 } |
1769 | 1769 |
| 1770 base::Optional<base::TimeDelta> NetworkQualityEstimator::GetHttpRTT() const { |
| 1771 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1772 |
| 1773 if (network_quality_.http_rtt() == nqe::internal::InvalidRTT()) |
| 1774 return base::Optional<base::TimeDelta>(); |
| 1775 return network_quality_.http_rtt(); |
| 1776 } |
| 1777 |
1770 base::Optional<base::TimeDelta> NetworkQualityEstimator::GetTransportRTT() | 1778 base::Optional<base::TimeDelta> NetworkQualityEstimator::GetTransportRTT() |
1771 const { | 1779 const { |
1772 DCHECK(thread_checker_.CalledOnValidThread()); | 1780 DCHECK(thread_checker_.CalledOnValidThread()); |
1773 | 1781 |
1774 if (network_quality_.transport_rtt() == nqe::internal::InvalidRTT()) | 1782 if (network_quality_.transport_rtt() == nqe::internal::InvalidRTT()) |
1775 return base::Optional<base::TimeDelta>(); | 1783 return base::Optional<base::TimeDelta>(); |
1776 return network_quality_.transport_rtt(); | 1784 return network_quality_.transport_rtt(); |
1777 } | 1785 } |
1778 | 1786 |
| 1787 base::Optional<int32_t> NetworkQualityEstimator::GetDownstreamThroughputKbps() |
| 1788 const { |
| 1789 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1790 |
| 1791 if (network_quality_.downstream_throughput_kbps() == |
| 1792 nqe::internal::kInvalidThroughput) { |
| 1793 return base::Optional<int32_t>(); |
| 1794 } |
| 1795 return network_quality_.downstream_throughput_kbps(); |
| 1796 } |
| 1797 |
1779 void NetworkQualityEstimator::MaybeUpdateNetworkQualityFromCache( | 1798 void NetworkQualityEstimator::MaybeUpdateNetworkQualityFromCache( |
1780 const nqe::internal::NetworkID& network_id, | 1799 const nqe::internal::NetworkID& network_id, |
1781 const nqe::internal::CachedNetworkQuality& cached_network_quality) { | 1800 const nqe::internal::CachedNetworkQuality& cached_network_quality) { |
1782 DCHECK(thread_checker_.CalledOnValidThread()); | 1801 DCHECK(thread_checker_.CalledOnValidThread()); |
1783 | 1802 |
1784 if (!params_.persistent_cache_reading_enabled()) | 1803 if (!params_.persistent_cache_reading_enabled()) |
1785 return; | 1804 return; |
1786 if (network_id != current_network_id_) | 1805 if (network_id != current_network_id_) |
1787 return; | 1806 return; |
1788 | 1807 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1825 case STATISTIC_UNWEIGHTED_AVERAGE: | 1844 case STATISTIC_UNWEIGHTED_AVERAGE: |
1826 return "UnweightedAverage"; | 1845 return "UnweightedAverage"; |
1827 case STATISTIC_LAST: | 1846 case STATISTIC_LAST: |
1828 NOTREACHED(); | 1847 NOTREACHED(); |
1829 return ""; | 1848 return ""; |
1830 } | 1849 } |
1831 NOTREACHED(); | 1850 NOTREACHED(); |
1832 return ""; | 1851 return ""; |
1833 } | 1852 } |
1834 | 1853 |
1835 base::Optional<base::TimeDelta> | |
1836 NetworkQualityEstimator::NetworkQualityProvider::GetHttpRTT() const { | |
1837 return base::Optional<base::TimeDelta>(); | |
1838 } | |
1839 | |
1840 base::Optional<base::TimeDelta> | |
1841 NetworkQualityEstimator::NetworkQualityProvider::GetTransportRTT() const { | |
1842 return base::Optional<base::TimeDelta>(); | |
1843 } | |
1844 | |
1845 base::Optional<int32_t> | |
1846 NetworkQualityEstimator::NetworkQualityProvider::GetDownstreamThroughputKbps() | |
1847 const { | |
1848 return base::Optional<int32_t>(); | |
1849 } | |
1850 | |
1851 } // namespace net | 1854 } // namespace net |
OLD | NEW |