diff options
author | droger@google.com <droger@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-24 11:30:05 +0000 |
---|---|---|
committer | droger@google.com <droger@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-24 11:30:05 +0000 |
commit | 8bbc7a79b07a8ea33b356492947ad8d455ab438a (patch) | |
tree | 2b7e728f0eb8467d51390846d1059595347a1d36 /remoting | |
parent | 9f230ed18793828c7f1776189b5b66a5b5f07771 (diff) | |
download | chromium_src-8bbc7a79b07a8ea33b356492947ad8d455ab438a.zip chromium_src-8bbc7a79b07a8ea33b356492947ad8d455ab438a.tar.gz chromium_src-8bbc7a79b07a8ea33b356492947ad8d455ab438a.tar.bz2 |
Support for navigator.connection API
This replaces the online state (a boolean) by a more complex state (UNKNOWN/NONE
/2G/3G/4G/WIFI/ETHERNET) inspired by the Network Information API
(http://www.w3.org/TR/netinfo-api/).
Breakdown of the modified files:
- network_change_notifier.h/.cc: actual API change
- network_change_notifier_*: platform specific implementations. This CL only provide a basic implementation where CONNECTION_UNKNOWN is returned when online and CONNECTION_NONE is returned when offline.
- other files: call sites for the static function and observer implementations. Most of the time this only changes the test IsOffline() by (GetConnectionType() == CONNECTION_NONE).
BUG=112937
TEST=NONE
Review URL: https://chromiumcodereview.appspot.com/9147026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138780 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/signaling_connector.cc | 9 | ||||
-rw-r--r-- | remoting/host/signaling_connector.h | 9 |
2 files changed, 10 insertions, 8 deletions
diff --git a/remoting/host/signaling_connector.cc b/remoting/host/signaling_connector.cc index a9bef15..e93c398 100644 --- a/remoting/host/signaling_connector.cc +++ b/remoting/host/signaling_connector.cc @@ -39,7 +39,7 @@ SignalingConnector::SignalingConnector( reconnect_attempts_(0), refreshing_oauth_token_(false) { DCHECK(!auth_failed_callback_.is_null()); - net::NetworkChangeNotifier::AddOnlineStateObserver(this); + net::NetworkChangeNotifier::AddConnectionTypeObserver(this); net::NetworkChangeNotifier::AddIPAddressObserver(this); signal_strategy_->AddListener(this); ScheduleTryReconnect(); @@ -47,7 +47,7 @@ SignalingConnector::SignalingConnector( SignalingConnector::~SignalingConnector() { signal_strategy_->RemoveListener(this); - net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); + net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); net::NetworkChangeNotifier::RemoveIPAddressObserver(this); } @@ -86,9 +86,10 @@ void SignalingConnector::OnIPAddressChanged() { ResetAndTryReconnect(); } -void SignalingConnector::OnOnlineStateChanged(bool online) { +void SignalingConnector::OnConnectionTypeChanged( + net::NetworkChangeNotifier::ConnectionType type) { DCHECK(CalledOnValidThread()); - if (online) { + if (type != net::NetworkChangeNotifier::CONNECTION_NONE) { LOG(INFO) << "Network state changed to online."; ResetAndTryReconnect(); } diff --git a/remoting/host/signaling_connector.h b/remoting/host/signaling_connector.h index 4b432f3..582b4ae 100644 --- a/remoting/host/signaling_connector.h +++ b/remoting/host/signaling_connector.h @@ -24,12 +24,12 @@ namespace remoting { // not connected it keeps trying to reconnect it until it is // connected. It limits connection attempt rate using exponential // backoff. It also monitors network state and reconnects signalling -// whenever online state changes or IP address changes. +// whenever connection type changes or IP address changes. class SignalingConnector : public base::SupportsWeakPtr<SignalingConnector>, public base::NonThreadSafe, public SignalStrategy::Listener, - public net::NetworkChangeNotifier::OnlineStateObserver, + public net::NetworkChangeNotifier::ConnectionTypeObserver, public net::NetworkChangeNotifier::IPAddressObserver, public GaiaOAuthClient::Delegate { public: @@ -67,8 +67,9 @@ class SignalingConnector // NetworkChangeNotifier::IPAddressObserver interface. virtual void OnIPAddressChanged() OVERRIDE; - // NetworkChangeNotifier::OnlineStateObserver interface. - virtual void OnOnlineStateChanged(bool online) OVERRIDE; + // NetworkChangeNotifier::ConnectionTypeObserver interface. + virtual void OnConnectionTypeChanged( + net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; // GaiaOAuthClient::Delegate interface. virtual void OnRefreshTokenResponse(const std::string& user_email, |