diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-22 03:04:26 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-22 03:04:26 +0000 |
commit | fe0f84184b33ea539c79102eb13f7401baaeb892 (patch) | |
tree | bf19da0bbde0ca4df133b974ba823bf199d94071 | |
parent | 25e65ec8c39b3ba0a420f60d6c5c6021ef317b56 (diff) | |
download | chromium_src-fe0f84184b33ea539c79102eb13f7401baaeb892.zip chromium_src-fe0f84184b33ea539c79102eb13f7401baaeb892.tar.gz chromium_src-fe0f84184b33ea539c79102eb13f7401baaeb892.tar.bz2 |
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
-rw-r--r-- | net/base/network_change_notifier_win.cc | 60 | ||||
-rw-r--r-- | net/base/network_change_notifier_win.h | 11 | ||||
-rwxr-xr-x | net/net.gyp | 5 |
3 files changed, 3 insertions, 73 deletions
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 <iphlpapi.h> -#include <windows.h> -#include <winsock2.h> -#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 diff --git a/net/base/network_change_notifier_win.h b/net/base/network_change_notifier_win.h index b11ec0d..b208ad7 100644 --- a/net/base/network_change_notifier_win.h +++ b/net/base/network_change_notifier_win.h @@ -6,7 +6,6 @@ #define NET_BASE_NETWORK_CHANGE_NOTIFIER_WIN_H_ #include "base/basictypes.h" -#include "base/object_watcher.h" #include "net/base/network_change_notifier_helper.h" namespace net { @@ -15,11 +14,6 @@ class NetworkChangeNotifierWin : public NetworkChangeNotifier { public: NetworkChangeNotifierWin(); - // Called by NetworkChangeNotifierWin::Impl. - void OnIPAddressChanged() { helper_.OnIPAddressChanged(); } - - // NetworkChangeNotifier methods: - virtual void AddObserver(Observer* observer) { helper_.AddObserver(observer); } @@ -29,12 +23,11 @@ class NetworkChangeNotifierWin : public NetworkChangeNotifier { } private: - class Impl; - virtual ~NetworkChangeNotifierWin(); + void OnIPAddressChanged() { helper_.OnIPAddressChanged(); } + internal::NetworkChangeNotifierHelper helper_; - scoped_ptr<Impl> impl_; DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierWin); }; diff --git a/net/net.gyp b/net/net.gyp index 9a8824b..f16ebab 100755 --- a/net/net.gyp +++ b/net/net.gyp @@ -524,11 +524,6 @@ 'dependencies': [ 'tld_cleanup', ], - 'link_settings': { - 'libraries': [ - '-lIphlpapi.lib', - ], - }, }, { # else: OS != "win" 'sources!': [ |