| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ANDROID_WEBVIEW_BROWSER_NET_AW_NETWORK_CHANGE_NOTIFIER_H_ |
| 6 #define ANDROID_WEBVIEW_BROWSER_NET_AW_NETWORK_CHANGE_NOTIFIER_H_ |
| 7 |
| 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" |
| 10 #include "net/android/network_change_notifier_delegate_android.h" |
| 11 #include "net/base/network_change_notifier.h" |
| 12 |
| 13 namespace android_webview { |
| 14 |
| 15 // AwNetworkChangeNotifier is similar to NetworkChangeNotifierAndroid except |
| 16 // it only propagates max-bandwidth changes in order to make the Network |
| 17 // Information API work in blink. |
| 18 // |
| 19 // This somewhat reduced functionality is necessary because of the way |
| 20 // NetworkChangeNotifier is enabled in WebView. It is enabled only when there |
| 21 // are living WebView instances (instead of using ApplicationStatus) hence the |
| 22 // existing Chrome for Android implementation is not applicable as is |
| 23 // (see crbug.com/529434). |
| 24 class AwNetworkChangeNotifier |
| 25 : public net::NetworkChangeNotifier, |
| 26 public net::NetworkChangeNotifierDelegateAndroid::Observer { |
| 27 public: |
| 28 ~AwNetworkChangeNotifier() override; |
| 29 |
| 30 // NetworkChangeNotifier: |
| 31 ConnectionType GetCurrentConnectionType() const override; |
| 32 // Requires ACCESS_WIFI_STATE permission in order to provide precise WiFi link |
| 33 // speed. |
| 34 void GetCurrentMaxBandwidthAndConnectionType( |
| 35 double* max_bandwidth_mbps, |
| 36 ConnectionType* connection_type) const override; |
| 37 bool AreNetworkHandlesCurrentlySupported() const override; |
| 38 void GetCurrentConnectedNetworks(NetworkList* network_list) const override; |
| 39 ConnectionType GetCurrentNetworkConnectionType( |
| 40 NetworkHandle network) const override; |
| 41 NetworkHandle GetCurrentDefaultNetwork() const override; |
| 42 |
| 43 // NetworkChangeNotifierDelegateAndroid::Observer: |
| 44 void OnConnectionTypeChanged() override; |
| 45 void OnMaxBandwidthChanged(double max_bandwidth_mbps, |
| 46 ConnectionType type) override; |
| 47 void OnNetworkConnected(NetworkHandle network) override; |
| 48 void OnNetworkSoonToDisconnect(NetworkHandle network) override; |
| 49 void OnNetworkDisconnected(NetworkHandle network) override; |
| 50 void OnNetworkMadeDefault(NetworkHandle network) override; |
| 51 |
| 52 private: |
| 53 friend class AwNetworkChangeNotifierFactory; |
| 54 |
| 55 AwNetworkChangeNotifier(net::NetworkChangeNotifierDelegateAndroid* delegate); |
| 56 |
| 57 static NetworkChangeCalculatorParams DefaultNetworkChangeCalculatorParams(); |
| 58 |
| 59 net::NetworkChangeNotifierDelegateAndroid* const delegate_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(AwNetworkChangeNotifier); |
| 62 }; |
| 63 |
| 64 } // namespace android_webview |
| 65 |
| 66 #endif // ANDROID_WEBVIEW_BROWSER_NET_AW_NETWORK_CHANGE_NOTIFIER_H_ |
| OLD | NEW |