| 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 #include "android_webview/browser/net/aw_network_change_notifier.h" | |
| 6 | |
| 7 namespace android_webview { | |
| 8 | |
| 9 AwNetworkChangeNotifier::~AwNetworkChangeNotifier() { | |
| 10 delegate_->RemoveObserver(this); | |
| 11 } | |
| 12 | |
| 13 net::NetworkChangeNotifier::ConnectionType | |
| 14 AwNetworkChangeNotifier::GetCurrentConnectionType() const { | |
| 15 return delegate_->GetCurrentConnectionType(); | |
| 16 } | |
| 17 | |
| 18 void AwNetworkChangeNotifier::GetCurrentMaxBandwidthAndConnectionType( | |
| 19 double* max_bandwidth_mbps, | |
| 20 ConnectionType* connection_type) const { | |
| 21 delegate_->GetCurrentMaxBandwidthAndConnectionType(max_bandwidth_mbps, | |
| 22 connection_type); | |
| 23 } | |
| 24 | |
| 25 bool AwNetworkChangeNotifier::AreNetworkHandlesCurrentlySupported() const { | |
| 26 return false; | |
| 27 } | |
| 28 | |
| 29 void AwNetworkChangeNotifier::GetCurrentConnectedNetworks( | |
| 30 NetworkChangeNotifier::NetworkList* networks) const { | |
| 31 delegate_->GetCurrentlyConnectedNetworks(networks); | |
| 32 } | |
| 33 | |
| 34 net::NetworkChangeNotifier::ConnectionType | |
| 35 AwNetworkChangeNotifier::GetCurrentNetworkConnectionType( | |
| 36 NetworkHandle network) const { | |
| 37 return delegate_->GetNetworkConnectionType(network); | |
| 38 } | |
| 39 | |
| 40 net::NetworkChangeNotifier::NetworkHandle | |
| 41 AwNetworkChangeNotifier::GetCurrentDefaultNetwork() const { | |
| 42 return delegate_->GetCurrentDefaultNetwork(); | |
| 43 } | |
| 44 | |
| 45 void AwNetworkChangeNotifier::OnConnectionTypeChanged() {} | |
| 46 | |
| 47 void AwNetworkChangeNotifier::OnMaxBandwidthChanged( | |
| 48 double max_bandwidth_mbps, | |
| 49 ConnectionType type) { | |
| 50 // Note that this callback is sufficient for Network Information API because | |
| 51 // it also occurs on type changes (see network_change_notifier.h). | |
| 52 NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChange(max_bandwidth_mbps, | |
| 53 type); | |
| 54 } | |
| 55 | |
| 56 void AwNetworkChangeNotifier::OnNetworkConnected(NetworkHandle network) {} | |
| 57 void AwNetworkChangeNotifier::OnNetworkSoonToDisconnect( | |
| 58 NetworkHandle network) {} | |
| 59 void AwNetworkChangeNotifier::OnNetworkDisconnected( | |
| 60 NetworkHandle network) {} | |
| 61 void AwNetworkChangeNotifier::OnNetworkMadeDefault(NetworkHandle network){} | |
| 62 | |
| 63 AwNetworkChangeNotifier::AwNetworkChangeNotifier( | |
| 64 net::NetworkChangeNotifierDelegateAndroid* delegate) | |
| 65 : net::NetworkChangeNotifier(DefaultNetworkChangeCalculatorParams()), | |
| 66 delegate_(delegate) { | |
| 67 delegate_->AddObserver(this); | |
| 68 } | |
| 69 | |
| 70 // static | |
| 71 net::NetworkChangeNotifier::NetworkChangeCalculatorParams | |
| 72 AwNetworkChangeNotifier::DefaultNetworkChangeCalculatorParams() { | |
| 73 net::NetworkChangeNotifier::NetworkChangeCalculatorParams params; | |
| 74 // Use defaults as in network_change_notifier_android.cc | |
| 75 params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(1); | |
| 76 params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(1); | |
| 77 params.connection_type_offline_delay_ = base::TimeDelta::FromSeconds(0); | |
| 78 params.connection_type_online_delay_ = base::TimeDelta::FromSeconds(0); | |
| 79 return params; | |
| 80 } | |
| 81 | |
| 82 } // namespace android_webview | |
| OLD | NEW |