From 8bbc7a79b07a8ea33b356492947ad8d455ab438a Mon Sep 17 00:00:00 2001 From: "droger@google.com" Date: Thu, 24 May 2012 11:30:05 +0000 Subject: 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 --- remoting/host/signaling_connector.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'remoting/host/signaling_connector.cc') 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(); } -- cgit v1.1