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

Unified Diff: Source/modules/netinfo/NetworkInformation.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: Update test expectations Created 5 years, 4 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: Source/modules/netinfo/NetworkInformation.cpp
diff --git a/Source/modules/netinfo/NetworkInformation.cpp b/Source/modules/netinfo/NetworkInformation.cpp
index a3596e340419781a12f531e405c9263381be5534..696d90829db621384bef64ffaca74e7aea783fa6 100644
--- a/Source/modules/netinfo/NetworkInformation.cpp
+++ b/Source/modules/netinfo/NetworkInformation.cpp
@@ -9,6 +9,7 @@
#include "core/events/Event.h"
#include "core/page/NetworkStateNotifier.h"
#include "modules/EventTargetModules.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "wtf/text/WTFString.h"
namespace {
@@ -26,6 +27,8 @@ String connectionTypeToString(WebConnectionType type)
return "ethernet";
case ConnectionTypeWifi:
return "wifi";
+ case ConnectionTypeWimax:
+ return "wimax";
case ConnectionTypeOther:
return "other";
case ConnectionTypeNone:
@@ -64,17 +67,29 @@ String NetworkInformation::type() const
return connectionTypeToString(m_type);
}
-void NetworkInformation::connectionTypeChange(WebConnectionType type)
+double NetworkInformation::downlinkMax() const
+{
+ if (!m_observing)
+ return networkStateNotifier().maxBandwidth();
+
+ return m_downlinkMax;
+}
+
+void NetworkInformation::connectionChange(WebConnectionType type, double downlinkMax)
{
ASSERT(executionContext()->isContextThread());
// This can happen if the observer removes and then adds itself again
// during notification.
- if (m_type == type)
+ if (m_type == type && m_downlinkMax == downlinkMax)
return;
m_type = type;
+ m_downlinkMax = downlinkMax;
dispatchEvent(Event::create(EventTypeNames::typechange));
+
+ if (RuntimeEnabledFeatures::netInfoDownlinkMaxEnabled())
+ dispatchEvent(Event::create(EventTypeNames::change));
}
const AtomicString& NetworkInformation::interfaceName() const
@@ -145,6 +160,7 @@ void NetworkInformation::stopObserving()
NetworkInformation::NetworkInformation(ExecutionContext* context)
: ActiveDOMObject(context)
, m_type(networkStateNotifier().connectionType())
+ , m_downlinkMax(networkStateNotifier().maxBandwidth())
, m_observing(false)
, m_contextStopped(false)
{

Powered by Google App Engine
This is Rietveld 408576698