Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: net/nqe/network_quality_estimator.cc

Issue 2672733002: Read NQE prefs to network quality store under all cases (Closed)
Patch Set: ps Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/nqe/network_quality_estimator.h ('k') | net/nqe/network_quality_estimator_params.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 signal_strength_dbm_(INT32_MIN), 282 signal_strength_dbm_(INT32_MIN),
283 min_signal_strength_since_connection_change_(INT32_MAX), 283 min_signal_strength_since_connection_change_(INT32_MAX),
284 max_signal_strength_since_connection_change_(INT32_MIN), 284 max_signal_strength_since_connection_change_(INT32_MIN),
285 correlation_uma_logging_probability_( 285 correlation_uma_logging_probability_(
286 nqe::internal::correlation_uma_logging_probability(variation_params)), 286 nqe::internal::correlation_uma_logging_probability(variation_params)),
287 forced_effective_connection_type_set_( 287 forced_effective_connection_type_set_(
288 nqe::internal::forced_effective_connection_type_set( 288 nqe::internal::forced_effective_connection_type_set(
289 variation_params)), 289 variation_params)),
290 forced_effective_connection_type_( 290 forced_effective_connection_type_(
291 nqe::internal::forced_effective_connection_type(variation_params)), 291 nqe::internal::forced_effective_connection_type(variation_params)),
292 persistent_cache_reading_enabled_(
293 nqe::internal::persistent_cache_reading_enabled(variation_params)),
292 event_creator_(net_log), 294 event_creator_(net_log),
293 weak_ptr_factory_(this) { 295 weak_ptr_factory_(this) {
294 // None of the algorithms can have an empty name. 296 // None of the algorithms can have an empty name.
295 DCHECK(algorithm_name_to_enum_.end() == 297 DCHECK(algorithm_name_to_enum_.end() ==
296 algorithm_name_to_enum_.find(std::string())); 298 algorithm_name_to_enum_.find(std::string()));
297 299
298 DCHECK_EQ(algorithm_name_to_enum_.size(), 300 DCHECK_EQ(algorithm_name_to_enum_.size(),
299 static_cast<size_t>(EffectiveConnectionTypeAlgorithm:: 301 static_cast<size_t>(EffectiveConnectionTypeAlgorithm::
300 EFFECTIVE_CONNECTION_TYPE_ALGORITHM_LAST)); 302 EFFECTIVE_CONNECTION_TYPE_ALGORITHM_LAST));
301 DCHECK_NE(EffectiveConnectionTypeAlgorithm:: 303 DCHECK_NE(EffectiveConnectionTypeAlgorithm::
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 1401
1400 if (network_id.type == NetworkChangeNotifier::GetConnectionType()) 1402 if (network_id.type == NetworkChangeNotifier::GetConnectionType())
1401 return network_id; 1403 return network_id;
1402 } 1404 }
1403 NOTREACHED(); 1405 NOTREACHED();
1404 } 1406 }
1405 1407
1406 bool NetworkQualityEstimator::ReadCachedNetworkQualityEstimate() { 1408 bool NetworkQualityEstimator::ReadCachedNetworkQualityEstimate() {
1407 DCHECK(thread_checker_.CalledOnValidThread()); 1409 DCHECK(thread_checker_.CalledOnValidThread());
1408 1410
1411 if (!persistent_cache_reading_enabled_)
1412 return false;
1413
1409 nqe::internal::CachedNetworkQuality cached_network_quality; 1414 nqe::internal::CachedNetworkQuality cached_network_quality;
1410 1415
1411 const bool cached_estimate_available = network_quality_store_->GetById( 1416 const bool cached_estimate_available = network_quality_store_->GetById(
1412 current_network_id_, &cached_network_quality); 1417 current_network_id_, &cached_network_quality);
1413 UMA_HISTOGRAM_BOOLEAN("NQE.CachedNetworkQualityAvailable", 1418 UMA_HISTOGRAM_BOOLEAN("NQE.CachedNetworkQualityAvailable",
1414 cached_estimate_available); 1419 cached_estimate_available);
1415 1420
1416 if (!cached_estimate_available) 1421 if (!cached_estimate_available)
1417 return false; 1422 return false;
1418 1423
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1688 1693
1689 network_quality_store_->Add(it.first, cached_network_quality); 1694 network_quality_store_->Add(it.first, cached_network_quality);
1690 MaybeUpdateNetworkQualityFromCache(it.first, cached_network_quality); 1695 MaybeUpdateNetworkQualityFromCache(it.first, cached_network_quality);
1691 } 1696 }
1692 } 1697 }
1693 1698
1694 void NetworkQualityEstimator::MaybeUpdateNetworkQualityFromCache( 1699 void NetworkQualityEstimator::MaybeUpdateNetworkQualityFromCache(
1695 const nqe::internal::NetworkID& network_id, 1700 const nqe::internal::NetworkID& network_id,
1696 const nqe::internal::CachedNetworkQuality& cached_network_quality) { 1701 const nqe::internal::CachedNetworkQuality& cached_network_quality) {
1697 DCHECK(thread_checker_.CalledOnValidThread()); 1702 DCHECK(thread_checker_.CalledOnValidThread());
1703
1704 if (!persistent_cache_reading_enabled_)
1705 return;
1698 if (network_id != current_network_id_) 1706 if (network_id != current_network_id_)
1699 return; 1707 return;
1700 1708
1701 // Since the cached network quality is for the current network, add it to 1709 // Since the cached network quality is for the current network, add it to
1702 // the current observations. 1710 // the current observations.
1703 RttObservation http_rtt_observation( 1711 RttObservation http_rtt_observation(
1704 cached_network_quality.network_quality().http_rtt(), 1712 cached_network_quality.network_quality().http_rtt(),
1705 base::TimeTicks::Now(), INT32_MIN, 1713 base::TimeTicks::Now(), INT32_MIN,
1706 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); 1714 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1707 rtt_observations_.AddObservation(http_rtt_observation); 1715 rtt_observations_.AddObservation(http_rtt_observation);
(...skipping 15 matching lines...) Expand all
1723 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); 1731 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1724 downstream_throughput_kbps_observations_.AddObservation( 1732 downstream_throughput_kbps_observations_.AddObservation(
1725 throughput_observation); 1733 throughput_observation);
1726 NotifyObserversOfThroughput(throughput_observation); 1734 NotifyObserversOfThroughput(throughput_observation);
1727 } 1735 }
1728 1736
1729 ComputeEffectiveConnectionType(); 1737 ComputeEffectiveConnectionType();
1730 } 1738 }
1731 1739
1732 } // namespace net 1740 } // namespace net
OLDNEW
« no previous file with comments | « net/nqe/network_quality_estimator.h ('k') | net/nqe/network_quality_estimator_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698