OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/network_change_notifier_win.h" | 5 #include "net/base/network_change_notifier_win.h" |
6 | 6 |
7 #include <iphlpapi.h> | 7 #include <iphlpapi.h> |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <winsock2.h> | 9 #include <winsock2.h> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 NetworkChangeNotifierWin::Impl::~Impl() { | 44 NetworkChangeNotifierWin::Impl::~Impl() { |
45 CancelIPChangeNotify(&addr_overlapped_); | 45 CancelIPChangeNotify(&addr_overlapped_); |
46 addr_watcher_.StopWatching(); | 46 addr_watcher_.StopWatching(); |
47 WSACloseEvent(addr_overlapped_.hEvent); | 47 WSACloseEvent(addr_overlapped_.hEvent); |
48 memset(&addr_overlapped_, 0, sizeof(addr_overlapped_)); | 48 memset(&addr_overlapped_, 0, sizeof(addr_overlapped_)); |
49 } | 49 } |
50 | 50 |
51 void NetworkChangeNotifierWin::Impl::WatchForAddressChange() { | 51 void NetworkChangeNotifierWin::Impl::WatchForAddressChange() { |
52 HANDLE handle = NULL; | 52 HANDLE handle = NULL; |
53 DWORD ret = NotifyAddrChange(&handle, &addr_overlapped_); | 53 DWORD ret = NotifyAddrChange(&handle, &addr_overlapped_); |
54 CHECK_EQ(ERROR_IO_PENDING, ret); | 54 CHECK(ret == ERROR_IO_PENDING); |
55 addr_watcher_.StartWatching(addr_overlapped_.hEvent, this); | 55 addr_watcher_.StartWatching(addr_overlapped_.hEvent, this); |
56 } | 56 } |
57 | 57 |
58 void NetworkChangeNotifierWin::Impl::OnObjectSignaled(HANDLE object) { | 58 void NetworkChangeNotifierWin::Impl::OnObjectSignaled(HANDLE object) { |
59 notifier_->OnIPAddressChanged(); | 59 notifier_->OnIPAddressChanged(); |
60 | 60 |
61 // Start watching for further address changes. | 61 // Start watching for further address changes. |
62 WatchForAddressChange(); | 62 WatchForAddressChange(); |
63 } | 63 } |
64 | 64 |
65 NetworkChangeNotifierWin::NetworkChangeNotifierWin() | 65 NetworkChangeNotifierWin::NetworkChangeNotifierWin() |
66 : impl_(new Impl(ALLOW_THIS_IN_INITIALIZER_LIST(this))) { | 66 : impl_(new Impl(ALLOW_THIS_IN_INITIALIZER_LIST(this))) { |
67 impl_->WatchForAddressChange(); | 67 impl_->WatchForAddressChange(); |
68 } | 68 } |
69 | 69 |
70 NetworkChangeNotifierWin::~NetworkChangeNotifierWin() {} | 70 NetworkChangeNotifierWin::~NetworkChangeNotifierWin() {} |
71 | 71 |
72 } // namespace net | 72 } // namespace net |
OLD | NEW |