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

Unified Diff: net/nqe/network_quality_store.cc

Issue 2731333003: Record UMA only when network quality is eligible for caching (Closed)
Patch Set: rebase, ryansturm comment Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/nqe/network_quality_store.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0686bd4549f1922639a34521424d31949b2f1fb2 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,18 @@ void NetworkQualityStore::RemoveNetworkQualitiesCacheObserver(
network_qualities_cache_observer_list_.RemoveObserver(observer);
}
+bool NetworkQualityStore::EligibleForCaching(
+ const NetworkID& network_id) const {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ // |disable_offline_check_| forces caching of 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());
« no previous file with comments | « net/nqe/network_quality_store.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698