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

Unified Diff: Source/core/page/NetworkStateNotifier.cpp

Issue 1308943005: [NetInfo] Add Blink support for connection.change, connection.downlinkMax, and wimax (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 3 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 | « Source/core/page/NetworkStateNotifier.h ('k') | Source/core/page/NetworkStateNotifierTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « Source/core/page/NetworkStateNotifier.h ('k') | Source/core/page/NetworkStateNotifierTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698