From 81cb4bb9dc17206a1baaea906c73e7b735f181db Mon Sep 17 00:00:00 2001 From: "zork@google.com" Date: Wed, 11 Nov 2009 00:43:53 +0000 Subject: Check for an active network connection when network adapter status changes. BUG=19784 TEST=On a system with two network adapters, ensure one has an active internet connection, and the other does not. Disconnect the active one, and check that in notifier::NetworkStatusDetectorTaskMT::OnNetworkAliveDone() the call to network_alive->alive() returns false. Review URL: http://codereview.chromium.org/377019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31623 0039d316-1c4b-4281-b951-d872f2087c98 --- .../notifier/base/win/async_network_alive_win32.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'chrome/browser/sync/notifier') diff --git a/chrome/browser/sync/notifier/base/win/async_network_alive_win32.cc b/chrome/browser/sync/notifier/base/win/async_network_alive_win32.cc index 9497b66..6e02a7f 100644 --- a/chrome/browser/sync/notifier/base/win/async_network_alive_win32.cc +++ b/chrome/browser/sync/notifier/base/win/async_network_alive_win32.cc @@ -11,6 +11,7 @@ #include "talk/base/common.h" #include "talk/base/criticalsection.h" #include "talk/base/logging.h" +#include "talk/base/physicalsocketserver.h" #include "talk/base/scoped_ptr.h" namespace notifier { @@ -102,6 +103,7 @@ class PlatformNetworkInfo { } } } while (true); + LOG(INFO) << "alive: " << alive; return alive; } @@ -215,7 +217,21 @@ class AsyncNetworkAliveWin32 : public AsyncNetworkAlive { return; } } - alive_ = network_info_->IsAlive(&error_); + + if (network_info_->IsAlive(&error_)) { + // If there is an active connection, check that www.google.com:80 + // is reachable. + talk_base::PhysicalSocketServer physical; + scoped_ptr socket(physical.CreateSocket(SOCK_STREAM)); + if (socket->Connect(talk_base::SocketAddress("talk.google.com", 5222))) { + alive_ = false; + } else { + alive_ = true; + } + } else { + // If there are no available connections, then we aren't alive. + alive_ = false; + } } virtual void OnWorkStop() { -- cgit v1.1