Index: Source/core/page/NetworkStateNotifier.cpp |
diff --git a/Source/core/page/NetworkStateNotifier.cpp b/Source/core/page/NetworkStateNotifier.cpp |
index a8ebbdcfb49bc4dfce04d2b0dc01af55a4a4291c..74a6124771ef1daadb8a28fde97b00f77cebe9f6 100644 |
--- a/Source/core/page/NetworkStateNotifier.cpp |
+++ b/Source/core/page/NetworkStateNotifier.cpp |
@@ -58,28 +58,13 @@ void NetworkStateNotifier::setOnLine(bool onLine) |
Page::networkStateChanged(onLine); |
} |
-void NetworkStateNotifier::setWebConnectionType(WebConnectionType type) |
+void NetworkStateNotifier::setWebConnection(WebConnectionType type, double maxBandwidthMbps) |
{ |
ASSERT(isMainThread()); |
if (m_testUpdatesOnly) |
return; |
- setWebConnectionTypeImpl(type); |
-} |
- |
-void NetworkStateNotifier::setWebConnectionTypeImpl(WebConnectionType type) |
-{ |
- ASSERT(isMainThread()); |
- |
- MutexLocker locker(m_mutex); |
- if (m_type == type) |
- return; |
- m_type = type; |
- |
- for (const auto& entry : m_observers) { |
- ExecutionContext* context = entry.key; |
- context->postTask(FROM_HERE, createCrossThreadTask(&NetworkStateNotifier::notifyObserversOnContext, this, type)); |
- } |
+ setWebConnectionImpl(type, maxBandwidthMbps); |
} |
void NetworkStateNotifier::addObserver(NetworkStateObserver* observer, ExecutionContext* context) |
@@ -122,14 +107,30 @@ void NetworkStateNotifier::setTestUpdatesOnly(bool updatesOnly) |
m_testUpdatesOnly = updatesOnly; |
} |
-void NetworkStateNotifier::setWebConnectionTypeForTest(WebConnectionType type) |
+void NetworkStateNotifier::setWebConnectionForTest(WebConnectionType type, double maxBandwidthMbps) |
{ |
ASSERT(isMainThread()); |
ASSERT(m_testUpdatesOnly); |
- setWebConnectionTypeImpl(type); |
+ setWebConnectionImpl(type, maxBandwidthMbps); |
+} |
+ |
+void NetworkStateNotifier::setWebConnectionImpl(WebConnectionType type, double maxBandwidthMbps) |
+{ |
+ ASSERT(isMainThread()); |
+ |
+ MutexLocker locker(m_mutex); |
+ if (m_type == type && m_maxBandwidthMbps == maxBandwidthMbps) |
+ return; |
+ m_type = type; |
+ m_maxBandwidthMbps = maxBandwidthMbps; |
+ |
+ for (const auto& entry : m_observers) { |
+ ExecutionContext* context = entry.key; |
+ context->postTask(FROM_HERE, createCrossThreadTask(&NetworkStateNotifier::notifyObserversOfConnectionChangeOnContext, this, type, maxBandwidthMbps)); |
+ } |
} |
-void NetworkStateNotifier::notifyObserversOnContext(WebConnectionType type, ExecutionContext* context) |
+void NetworkStateNotifier::notifyObserversOfConnectionChangeOnContext(WebConnectionType type, double maxBandwidthMbps, ExecutionContext* context) |
{ |
ObserverList* observerList = lockAndFindObserverList(context); |
@@ -144,7 +145,7 @@ void NetworkStateNotifier::notifyObserversOnContext(WebConnectionType type, Exec |
for (size_t i = 0; i < observerList->observers.size(); ++i) { |
// Observers removed during iteration are zeroed out, skip them. |
if (observerList->observers[i]) |
- observerList->observers[i]->connectionTypeChange(type); |
+ observerList->observers[i]->connectionChange(type, maxBandwidthMbps); |
} |
observerList->iterating = false; |