Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1022)

Side by Side Diff: net/base/network_change_notifier_win.cc

Issue 6526059: Plumb through NetworkChangeNotifier::IsOffline() to WebKit, enabling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No tests yet Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/network_change_notifier.cc ('k') | net/proxy/proxy_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 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 <winsock2.h> 8 #include <winsock2.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h"
12 #include "base/task.h"
11 #include "net/base/winsock_init.h" 13 #include "net/base/winsock_init.h"
12 14
13 #pragma comment(lib, "iphlpapi.lib") 15 #pragma comment(lib, "iphlpapi.lib")
14 16
15 namespace net { 17 namespace net {
16 18
17 NetworkChangeNotifierWin::NetworkChangeNotifierWin() { 19 NetworkChangeNotifierWin::NetworkChangeNotifierWin() {
18 memset(&addr_overlapped_, 0, sizeof addr_overlapped_); 20 memset(&addr_overlapped_, 0, sizeof addr_overlapped_);
19 addr_overlapped_.hEvent = WSACreateEvent(); 21 addr_overlapped_.hEvent = WSACreateEvent();
20 WatchForAddressChange(); 22 WatchForAddressChange();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 result = WSALookupServiceEnd(ws_handle); 141 result = WSALookupServiceEnd(ws_handle);
140 LOG_IF(ERROR, result != 0) 142 LOG_IF(ERROR, result != 0)
141 << "WSALookupServiceEnd() failed with: " << result; 143 << "WSALookupServiceEnd() failed with: " << result;
142 144
143 return !found_connection; 145 return !found_connection;
144 } 146 }
145 147
146 void NetworkChangeNotifierWin::OnObjectSignaled(HANDLE object) { 148 void NetworkChangeNotifierWin::OnObjectSignaled(HANDLE object) {
147 NotifyObserversOfIPAddressChange(); 149 NotifyObserversOfIPAddressChange();
148 150
151 // Calling IsOffline() at this very moment is likely to give
152 // the wrong result, so we delay that until a little bit later.
153 //
154 // The one second delay chosen here was determined experimentally
155 // by adamk on Windows 7.
156 MessageLoop::current()->PostDelayedTask(
eroman 2011/03/01 05:23:10 I suggest adding a bit to keep track of the outsta
adamk 2011/03/01 19:20:06 Thanks for the tip, replaced with a OneShotTimer.
157 FROM_HERE,
158 NewRunnableFunction(&NotifyObserversOfOnlineStateChange),
159 1000);
160
149 // Start watching for the next address change. 161 // Start watching for the next address change.
150 WatchForAddressChange(); 162 WatchForAddressChange();
151 } 163 }
152 164
153 void NetworkChangeNotifierWin::WatchForAddressChange() { 165 void NetworkChangeNotifierWin::WatchForAddressChange() {
154 HANDLE handle = NULL; 166 HANDLE handle = NULL;
155 DWORD ret = NotifyAddrChange(&handle, &addr_overlapped_); 167 DWORD ret = NotifyAddrChange(&handle, &addr_overlapped_);
156 CHECK(ret == ERROR_IO_PENDING); 168 CHECK(ret == ERROR_IO_PENDING);
157 addr_watcher_.StartWatching(addr_overlapped_.hEvent, this); 169 addr_watcher_.StartWatching(addr_overlapped_.hEvent, this);
158 } 170 }
159 171
160 } // namespace net 172 } // namespace net
OLDNEW
« no previous file with comments | « net/base/network_change_notifier.cc ('k') | net/proxy/proxy_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698