summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/network
diff options
context:
space:
mode:
authorAndrei Popescu <andreip@google.com>2010-01-14 19:19:31 +0000
committerAndrei Popescu <andreip@google.com>2010-01-15 20:05:20 +0000
commit488dcd54e257a3a18d92e5ec1897511dfb05482c (patch)
tree2b94289fcc32af6b379329f0d147a6e146e9496f /WebCore/platform/network
parent3498801a958b3c41f61e136faad545d1ed71f9f6 (diff)
downloadexternal_webkit-488dcd54e257a3a18d92e5ec1897511dfb05482c.zip
external_webkit-488dcd54e257a3a18d92e5ec1897511dfb05482c.tar.gz
external_webkit-488dcd54e257a3a18d92e5ec1897511dfb05482c.tar.bz2
Add navigator.networkType to allow apps to detect the connection type.
The online event is fired when the networkType changes. Bug: 2368650
Diffstat (limited to 'WebCore/platform/network')
-rw-r--r--WebCore/platform/network/NetworkStateNotifier.h13
-rw-r--r--WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp11
2 files changed, 24 insertions, 0 deletions
diff --git a/WebCore/platform/network/NetworkStateNotifier.h b/WebCore/platform/network/NetworkStateNotifier.h
index 570ced0..d0463d4 100644
--- a/WebCore/platform/network/NetworkStateNotifier.h
+++ b/WebCore/platform/network/NetworkStateNotifier.h
@@ -27,6 +27,9 @@
#define NetworkStateNotifier_h
#include <wtf/Noncopyable.h>
+#if PLATFORM(ANDROID)
+#include "Connection.h"
+#endif
#if PLATFORM(MAC)
@@ -54,9 +57,15 @@ public:
void setNetworkStateChangedFunction(void (*)());
bool onLine() const { return m_isOnLine; }
+#if PLATFORM(ANDROID)
+ Connection::ConnectionType type() const { return m_type; }
+#endif
private:
bool m_isOnLine;
+#if PLATFORM(ANDROID)
+ Connection::ConnectionType m_type;
+#endif
void (*m_networkStateChangedFunction)();
void updateState();
@@ -84,6 +93,7 @@ private:
#elif PLATFORM(ANDROID)
public:
void networkStateChange(bool online);
+ void networkTypeChange(Connection::ConnectionType type);
#endif
};
@@ -91,6 +101,9 @@ public:
inline NetworkStateNotifier::NetworkStateNotifier()
: m_isOnLine(true)
+#if PLATFORM(ANDROID)
+ , m_type(Connection::Unknown)
+#endif
, m_networkStateChangedFunction(0)
{
}
diff --git a/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp b/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp
index 3aa5578..134e206 100644
--- a/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp
+++ b/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp
@@ -39,4 +39,15 @@ void NetworkStateNotifier::networkStateChange(bool online)
m_networkStateChangedFunction();
}
+void NetworkStateNotifier::networkTypeChange(Connection::ConnectionType type)
+{
+ if (m_type == type)
+ return;
+
+ m_type = type;
+
+ if (m_networkStateChangedFunction)
+ m_networkStateChangedFunction();
+}
+
}