| Index: Source/core/page/NetworkStateNotifier.cpp
|
| diff --git a/Source/core/page/NetworkStateNotifier.cpp b/Source/core/page/NetworkStateNotifier.cpp
|
| index a8ebbdcfb49bc4dfce04d2b0dc01af55a4a4291c..fa2210a7a892a9ad8e98cc39eb1fbcbf05e208a4 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 maxBandwidth)
|
| {
|
| 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, maxBandwidth);
|
| }
|
|
|
| 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 maxBandwidth)
|
| {
|
| ASSERT(isMainThread());
|
| ASSERT(m_testUpdatesOnly);
|
| - setWebConnectionTypeImpl(type);
|
| + setWebConnectionImpl(type, maxBandwidth);
|
| +}
|
| +
|
| +void NetworkStateNotifier::setWebConnectionImpl(WebConnectionType type, double maxBandwidth)
|
| +{
|
| + ASSERT(isMainThread());
|
| +
|
| + MutexLocker locker(m_mutex);
|
| + if (m_type == type && m_maxBandwidth == maxBandwidth)
|
| + return;
|
| + m_type = type;
|
| + m_maxBandwidth = maxBandwidth;
|
| +
|
| + for (const auto& entry : m_observers) {
|
| + ExecutionContext* context = entry.key;
|
| + context->postTask(FROM_HERE, createCrossThreadTask(&NetworkStateNotifier::notifyObserversOfConnectionChangeOnContext, this, type, maxBandwidth));
|
| + }
|
| }
|
|
|
| -void NetworkStateNotifier::notifyObserversOnContext(WebConnectionType type, ExecutionContext* context)
|
| +void NetworkStateNotifier::notifyObserversOfConnectionChangeOnContext(WebConnectionType type, double maxBandwidth, 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, maxBandwidth);
|
| }
|
|
|
| observerList->iterating = false;
|
|
|