From fe0f84184b33ea539c79102eb13f7401baaeb892 Mon Sep 17 00:00:00 2001 From: "willchan@chromium.org" Date: Fri, 22 Jan 2010 03:04:26 +0000 Subject: Revert 36837 (caused XP unit_tests crashes) - Implement NetworkChangeNotifierWin. Uses the NotifyAddrChange() API to detect ip address changes. BUG=http://crbug.com/26156 Review URL: http://codereview.chromium.org/551077 TBR=willchan@chromium.org Review URL: http://codereview.chromium.org/543167 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36842 0039d316-1c4b-4281-b951-d872f2087c98 --- net/base/network_change_notifier_win.cc | 60 +-------------------------------- 1 file changed, 1 insertion(+), 59 deletions(-) (limited to 'net/base/network_change_notifier_win.cc') diff --git a/net/base/network_change_notifier_win.cc b/net/base/network_change_notifier_win.cc index e52bd46..711bd66 100644 --- a/net/base/network_change_notifier_win.cc +++ b/net/base/network_change_notifier_win.cc @@ -3,68 +3,10 @@ // found in the LICENSE file. #include "net/base/network_change_notifier_win.h" -#include -#include -#include -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/logging.h" -#include "base/object_watcher.h" namespace net { -class NetworkChangeNotifierWin::Impl - : public base::ObjectWatcher::Delegate { - public: - explicit Impl(NetworkChangeNotifierWin* notifier); - virtual ~Impl(); - - void WatchForAddressChange(); - - // ObjectWatcher::Delegate methods: - - virtual void OnObjectSignaled(HANDLE object); - - private: - NetworkChangeNotifierWin* const notifier_; - base::ObjectWatcher addr_watcher_; - OVERLAPPED addr_overlapped_; - - DISALLOW_COPY_AND_ASSIGN(Impl); -}; - -NetworkChangeNotifierWin::Impl::Impl(NetworkChangeNotifierWin* notifier) - : notifier_(notifier) { - memset(&addr_overlapped_, 0, sizeof(addr_overlapped_)); - addr_overlapped_.hEvent = WSACreateEvent(); -} - -NetworkChangeNotifierWin::Impl::~Impl() { - CancelIPChangeNotify(&addr_overlapped_); - addr_watcher_.StopWatching(); - WSACloseEvent(addr_overlapped_.hEvent); - memset(&addr_overlapped_, 0, sizeof(addr_overlapped_)); -} - -void NetworkChangeNotifierWin::Impl::WatchForAddressChange() { - HANDLE handle = NULL; - DWORD ret = NotifyAddrChange(&handle, &addr_overlapped_); - CHECK(ret == ERROR_IO_PENDING); - addr_watcher_.StartWatching(addr_overlapped_.hEvent, this); -} - -void NetworkChangeNotifierWin::Impl::OnObjectSignaled(HANDLE object) { - notifier_->OnIPAddressChanged(); - - // Start watching for further address changes. - WatchForAddressChange(); -} - -NetworkChangeNotifierWin::NetworkChangeNotifierWin() - : impl_(new Impl(ALLOW_THIS_IN_INITIALIZER_LIST(this))) { - impl_->WatchForAddressChange(); -} - +NetworkChangeNotifierWin::NetworkChangeNotifierWin() {} NetworkChangeNotifierWin::~NetworkChangeNotifierWin() {} } // namespace net -- cgit v1.1