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

Unified 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: Appease the C++ type system 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/network_change_notifier_win.h ('k') | net/proxy/proxy_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: 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 bc906cb8a61c32e115d9e7e1c665b83882f14680..718e40bb9faa7629998f4a607cb3c569b1754307 100644
--- a/net/base/network_change_notifier_win.cc
+++ b/net/base/network_change_notifier_win.cc
@@ -8,6 +8,7 @@
#include <winsock2.h>
#include "base/logging.h"
+#include "base/time.h"
#include "net/base/winsock_init.h"
#pragma comment(lib, "iphlpapi.lib")
@@ -146,6 +147,15 @@ bool NetworkChangeNotifierWin::IsCurrentlyOffline() const {
void NetworkChangeNotifierWin::OnObjectSignaled(HANDLE object) {
NotifyObserversOfIPAddressChange();
+ // Calling IsOffline() at this very moment is likely to give
+ // the wrong result, so we delay that until a little bit later.
+ //
+ // The one second delay chosen here was determined experimentally
+ // by adamk on Windows 7.
+ timer_.Stop(); // cancel any already waiting notification
+ timer_.Start(base::TimeDelta::FromSeconds(1), this,
+ &NetworkChangeNotifierWin::NotifyParentOfOnlineStateChange);
+
// Start watching for the next address change.
WatchForAddressChange();
}
@@ -157,4 +167,8 @@ void NetworkChangeNotifierWin::WatchForAddressChange() {
addr_watcher_.StartWatching(addr_overlapped_.hEvent, this);
}
+void NetworkChangeNotifierWin::NotifyParentOfOnlineStateChange() {
+ NotifyObserversOfOnlineStateChange();
+}
+
} // namespace net
« no previous file with comments | « net/base/network_change_notifier_win.h ('k') | net/proxy/proxy_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698