| 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 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 bool NetworkQualityEstimator::ReadCachedNetworkQualityEstimate() { | 1462 bool NetworkQualityEstimator::ReadCachedNetworkQualityEstimate() { |
| 1463 DCHECK(thread_checker_.CalledOnValidThread()); | 1463 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1464 | 1464 |
| 1465 if (!persistent_cache_reading_enabled_) | 1465 if (!persistent_cache_reading_enabled_) |
| 1466 return false; | 1466 return false; |
| 1467 | 1467 |
| 1468 nqe::internal::CachedNetworkQuality cached_network_quality; | 1468 nqe::internal::CachedNetworkQuality cached_network_quality; |
| 1469 | 1469 |
| 1470 const bool cached_estimate_available = network_quality_store_->GetById( | 1470 const bool cached_estimate_available = network_quality_store_->GetById( |
| 1471 current_network_id_, &cached_network_quality); | 1471 current_network_id_, &cached_network_quality); |
| 1472 UMA_HISTOGRAM_BOOLEAN("NQE.CachedNetworkQualityAvailable", | 1472 if (network_quality_store_->EligibleForCaching(current_network_id_)) { |
| 1473 cached_estimate_available); | 1473 UMA_HISTOGRAM_BOOLEAN("NQE.CachedNetworkQualityAvailable", |
| 1474 cached_estimate_available); |
| 1475 } |
| 1474 | 1476 |
| 1475 if (!cached_estimate_available) | 1477 if (!cached_estimate_available) |
| 1476 return false; | 1478 return false; |
| 1477 | 1479 |
| 1478 const base::TimeTicks now = tick_clock_->NowTicks(); | 1480 const base::TimeTicks now = tick_clock_->NowTicks(); |
| 1479 | 1481 |
| 1480 if (cached_network_quality.network_quality().downstream_throughput_kbps() != | 1482 if (cached_network_quality.network_quality().downstream_throughput_kbps() != |
| 1481 nqe::internal::kInvalidThroughput) { | 1483 nqe::internal::kInvalidThroughput) { |
| 1482 ThroughputObservation througphput_observation( | 1484 ThroughputObservation througphput_observation( |
| 1483 cached_network_quality.network_quality().downstream_throughput_kbps(), | 1485 cached_network_quality.network_quality().downstream_throughput_kbps(), |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1812 return "UnweightedAverage"; | 1814 return "UnweightedAverage"; |
| 1813 case STATISTIC_LAST: | 1815 case STATISTIC_LAST: |
| 1814 NOTREACHED(); | 1816 NOTREACHED(); |
| 1815 return ""; | 1817 return ""; |
| 1816 } | 1818 } |
| 1817 NOTREACHED(); | 1819 NOTREACHED(); |
| 1818 return ""; | 1820 return ""; |
| 1819 } | 1821 } |
| 1820 | 1822 |
| 1821 } // namespace net | 1823 } // namespace net |
| OLD | NEW |