Chromium Code Reviews| Index: net/nqe/network_quality_store.cc |
| diff --git a/net/nqe/network_quality_store.cc b/net/nqe/network_quality_store.cc |
| index 43d2bcafaf8ca488459ae079f140b99392571479..62a34cb1d9a01085f29ab8ee222457a0d98ae483 100644 |
| --- a/net/nqe/network_quality_store.cc |
| +++ b/net/nqe/network_quality_store.cc |
| @@ -35,15 +35,8 @@ void NetworkQualityStore::Add( |
| DCHECK_LE(cached_network_qualities_.size(), |
| static_cast<size_t>(kMaximumNetworkQualityCacheSize)); |
| - // If the network name is unavailable, caching should not be performed. If |
| - // |disable_offline_check_| is set to true, cache the network quality even if |
| - // the network is set to offline. |
| - if (network_id.type != NetworkChangeNotifier::CONNECTION_ETHERNET && |
| - network_id.id.empty() && |
| - (network_id.type != NetworkChangeNotifier::CONNECTION_NONE || |
| - !disable_offline_check_)) { |
| + if (!EligibleForCaching(network_id)) |
| return; |
| - } |
| // Remove the entry from the map, if it is already present. |
| cached_network_qualities_.erase(network_id); |
| @@ -104,6 +97,19 @@ void NetworkQualityStore::RemoveNetworkQualitiesCacheObserver( |
| network_qualities_cache_observer_list_.RemoveObserver(observer); |
| } |
| +bool NetworkQualityStore::EligibleForCaching( |
| + const NetworkID& network_id) const { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + |
| + // If the network name is unavailable, caching should not be performed. If |
|
RyanSturm
2017/03/09 00:01:55
This comment seems unnecessary. It describes the c
tbansal1
2017/03/09 00:24:00
Done.
|
| + // |disable_offline_check_| is set to true, cache the network quality even if |
| + // the network is set to offline. |
| + return network_id.type == NetworkChangeNotifier::CONNECTION_ETHERNET || |
| + !network_id.id.empty() || |
| + (network_id.type == NetworkChangeNotifier::CONNECTION_NONE && |
| + disable_offline_check_); |
| +} |
| + |
| void NetworkQualityStore::DisableOfflineCheckForTesting( |
| bool disable_offline_check) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |