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

Unified Diff: chrome/browser/net/nqe/ui_network_quality_estimator_service.cc

Issue 2450433003: Adding observer functionality to UINetworkQualityService (Closed)
Patch Set: nits Created 4 years, 2 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
Index: chrome/browser/net/nqe/ui_network_quality_estimator_service.cc
diff --git a/chrome/browser/net/nqe/ui_network_quality_estimator_service.cc b/chrome/browser/net/nqe/ui_network_quality_estimator_service.cc
index 6e00352acd3e916b9f5fc6170364fc3b2866164e..3208ce46583b2147c8b4177df054151774bdc4da 100644
--- a/chrome/browser/net/nqe/ui_network_quality_estimator_service.cc
+++ b/chrome/browser/net/nqe/ui_network_quality_estimator_service.cc
@@ -200,26 +200,40 @@ void UINetworkQualityEstimatorService::Shutdown() {
DCHECK(deleted);
// Silence unused variable warning in release builds.
(void)deleted;
}
}
void UINetworkQualityEstimatorService::EffectiveConnectionTypeChanged(
net::EffectiveConnectionType type) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
type_ = type;
+ for (auto& observer : effective_connection_type_observer_list_)
+ observer.OnEffectiveConnectionTypeChanged(type);
+}
+
+void UINetworkQualityEstimatorService::AddEffectiveConnectionTypeObserver(
+ net::NetworkQualityEstimator::EffectiveConnectionTypeObserver* observer) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ effective_connection_type_observer_list_.AddObserver(observer);
+}
+
+void UINetworkQualityEstimatorService::RemoveEffectiveConnectionTypeObserver(
+ net::NetworkQualityEstimator::EffectiveConnectionTypeObserver* observer) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ effective_connection_type_observer_list_.RemoveObserver(observer);
}
void UINetworkQualityEstimatorService::SetEffectiveConnectionTypeForTesting(
net::EffectiveConnectionType type) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- type_ = type;
+ EffectiveConnectionTypeChanged(type);
}
net::EffectiveConnectionType
UINetworkQualityEstimatorService::GetEffectiveConnectionType() const {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
return type_;
}
// static
void UINetworkQualityEstimatorService::RegisterProfilePrefs(

Powered by Google App Engine
This is Rietveld 408576698