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 2964572feca42e65a417afc35cbd53d843adb19a..1585e06514a88fde1a2dce383b08fff9f9defb02 100644 |
--- a/chrome/browser/net/nqe/ui_network_quality_estimator_service.cc |
+++ b/chrome/browser/net/nqe/ui_network_quality_estimator_service.cc |
@@ -126,12 +126,6 @@ class UINetworkQualityEstimatorService::IONetworkQualityObserver |
if (!network_quality_estimator_) |
return; |
network_quality_estimator_->AddEffectiveConnectionTypeObserver(this); |
- content::BrowserThread::PostTask( |
- content::BrowserThread::UI, FROM_HERE, |
- base::Bind( |
- &UINetworkQualityEstimatorService::EffectiveConnectionTypeChanged, |
- service_, |
- network_quality_estimator_->GetEffectiveConnectionType())); |
} |
// net::NetworkQualityEstimator::EffectiveConnectionTypeObserver |
@@ -215,6 +209,12 @@ void UINetworkQualityEstimatorService::AddEffectiveConnectionTypeObserver( |
net::NetworkQualityEstimator::EffectiveConnectionTypeObserver* observer) { |
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
effective_connection_type_observer_list_.AddObserver(observer); |
+ |
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::UI, FROM_HERE, |
+ base::Bind(&UINetworkQualityEstimatorService:: |
+ NotifyEffectiveConnectionTypeObserverIfPresent, |
+ weak_factory_.GetWeakPtr(), observer)); |
} |
void UINetworkQualityEstimatorService::RemoveEffectiveConnectionTypeObserver( |
@@ -242,6 +242,19 @@ void UINetworkQualityEstimatorService::ClearPrefs() { |
prefs_manager_->ClearPrefs(); |
} |
+void UINetworkQualityEstimatorService:: |
+ NotifyEffectiveConnectionTypeObserverIfPresent( |
+ net::NetworkQualityEstimator::EffectiveConnectionTypeObserver* observer) |
+ const { |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
+ |
+ if (!effective_connection_type_observer_list_.HasObserver(observer)) |
+ return; |
+ if (type_ == net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN) |
+ return; |
+ observer->OnEffectiveConnectionTypeChanged(type_); |
+} |
+ |
// static |
void UINetworkQualityEstimatorService::RegisterProfilePrefs( |
PrefRegistrySimple* registry) { |