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

Unified Diff: android_webview/browser/net/aw_network_change_notifier.h

Issue 1761983003: [Android WebView] Implement support for Network Information API and enable it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 10 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: android_webview/browser/net/aw_network_change_notifier.h
diff --git a/android_webview/browser/net/aw_network_change_notifier.h b/android_webview/browser/net/aw_network_change_notifier.h
new file mode 100644
index 0000000000000000000000000000000000000000..6fc25b0ea92abe9d3ac8bebaf008d76c35e5f3d7
--- /dev/null
+++ b/android_webview/browser/net/aw_network_change_notifier.h
@@ -0,0 +1,66 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ANDROID_WEBVIEW_BROWSER_NET_AW_NETWORK_CHANGE_NOTIFIER_H_
+#define ANDROID_WEBVIEW_BROWSER_NET_AW_NETWORK_CHANGE_NOTIFIER_H_
+
+#include "base/compiler_specific.h"
+#include "base/macros.h"
+#include "net/android/network_change_notifier_delegate_android.h"
+#include "net/base/network_change_notifier.h"
+
+namespace android_webview {
+
+// AwNetworkChangeNotifier is similar to NetworkChangeNotifierAndroid except
+// it only propagates max-bandwidth changes in order to make the Network
+// Information API work in blink.
+//
+// This somewhat reduced functionality is necessary because of the way
+// NetworkChangeNotifier is enabled in WebView. It is enabled only when there
+// are living WebView instances (instead of using ApplicationStatus) hence the
+// existing Chrome for Android implementation is not applicable as is
+// (see crbug.com/529434).
+class AwNetworkChangeNotifier
+ : public net::NetworkChangeNotifier,
+ public net::NetworkChangeNotifierDelegateAndroid::Observer {
+ public:
+ ~AwNetworkChangeNotifier() override;
+
+ // NetworkChangeNotifier:
+ ConnectionType GetCurrentConnectionType() const override;
+ // Requires ACCESS_WIFI_STATE permission in order to provide precise WiFi link
+ // speed.
+ void GetCurrentMaxBandwidthAndConnectionType(
+ double* max_bandwidth_mbps,
+ ConnectionType* connection_type) const override;
+ bool AreNetworkHandlesCurrentlySupported() const override;
+ void GetCurrentConnectedNetworks(NetworkList* network_list) const override;
+ ConnectionType GetCurrentNetworkConnectionType(
+ NetworkHandle network) const override;
+ NetworkHandle GetCurrentDefaultNetwork() const override;
+
+ // NetworkChangeNotifierDelegateAndroid::Observer:
+ void OnConnectionTypeChanged() override;
+ void OnMaxBandwidthChanged(double max_bandwidth_mbps,
+ ConnectionType type) override;
+ void OnNetworkConnected(NetworkHandle network) override;
+ void OnNetworkSoonToDisconnect(NetworkHandle network) override;
+ void OnNetworkDisconnected(NetworkHandle network) override;
+ void OnNetworkMadeDefault(NetworkHandle network) override;
+
+ private:
+ friend class AwNetworkChangeNotifierFactory;
+
+ AwNetworkChangeNotifier(net::NetworkChangeNotifierDelegateAndroid* delegate);
+
+ static NetworkChangeCalculatorParams DefaultNetworkChangeCalculatorParams();
+
+ net::NetworkChangeNotifierDelegateAndroid* const delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(AwNetworkChangeNotifier);
+};
+
+} // namespace android_webview
+
+#endif // ANDROID_WEBVIEW_BROWSER_NET_AW_NETWORK_CHANGE_NOTIFIER_H_
« no previous file with comments | « android_webview/browser/aw_browser_main_parts.cc ('k') | android_webview/browser/net/aw_network_change_notifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698