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

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: 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/modules/netinfo/NetworkInformation.h ('k') | Source/modules/netinfo/NetworkInformation.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/netinfo/NetworkInformation.cpp
diff --git a/Source/modules/netinfo/NetworkInformation.cpp b/Source/modules/netinfo/NetworkInformation.cpp
index a3596e340419781a12f531e405c9263381be5534..0be19dab5d5c709249a4ff08fd809c80a9c56b15 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_downlinkMaxMbps;
+}
+
+void NetworkInformation::connectionChange(WebConnectionType type, double downlinkMaxMbps)
{
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_downlinkMaxMbps == downlinkMaxMbps)
return;
m_type = type;
+ m_downlinkMaxMbps = downlinkMaxMbps;
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_downlinkMaxMbps(networkStateNotifier().maxBandwidth())
, m_observing(false)
, m_contextStopped(false)
{
« no previous file with comments | « Source/modules/netinfo/NetworkInformation.h ('k') | Source/modules/netinfo/NetworkInformation.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698