summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorzelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-14 20:16:17 +0000
committerzelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-14 20:16:17 +0000
commit047257c5d1cb6ebfa551fb91da587500307a12c4 (patch)
tree43f94e7502b68652c360bfdb08fe7f2d5374f67e /net
parent4cd7adb2f69afcebd5690b10d24cd13f5c05f095 (diff)
downloadchromium_src-047257c5d1cb6ebfa551fb91da587500307a12c4.zip
chromium_src-047257c5d1cb6ebfa551fb91da587500307a12c4.tar.gz
chromium_src-047257c5d1cb6ebfa551fb91da587500307a12c4.tar.bz2
Introduced artificial processing delay to work around the issue of proxy initialization before name resolving
is functional in ChromeOS. This should be removed once this bug chromium-os:3996 is properly fixed. BUG=chromium-os:3996 TEST=check the bug for repro steps Review URL: http://codereview.chromium.org/2796007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49716 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/network_change_notifier_linux.cc26
-rw-r--r--net/base/network_change_notifier_linux.h11
2 files changed, 35 insertions, 2 deletions
diff --git a/net/base/network_change_notifier_linux.cc b/net/base/network_change_notifier_linux.cc
index f5f9bf5..03a098b 100644
--- a/net/base/network_change_notifier_linux.cc
+++ b/net/base/network_change_notifier_linux.cc
@@ -24,6 +24,9 @@ const int kInvalidSocket = -1;
NetworkChangeNotifierLinux::NetworkChangeNotifierLinux()
: netlink_fd_(kInvalidSocket),
+#if defined(OS_CHROMEOS)
+ ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)),
+#endif
loop_(MessageLoopForIO::current()) {
netlink_fd_ = InitializeNetlinkSocket();
if (netlink_fd_ < 0) {
@@ -61,8 +64,23 @@ void NetworkChangeNotifierLinux::ListenForNotifications() {
char buf[4096];
int rv = ReadNotificationMessage(buf, arraysize(buf));
while (rv > 0 ) {
- if (HandleNetlinkMessage(buf, rv))
- FOR_EACH_OBSERVER(Observer, observers_, OnIPAddressChanged());
+ if (HandleNetlinkMessage(buf, rv)) {
+ LOG(INFO) << "Detected IP address changes.";
+
+#if defined(OS_CHROMEOS)
+ // TODO(zelidrag): chromium-os:3996 - introduced artificial delay to
+ // work around the issue of proxy initialization before name resolving
+ // is functional in ChromeOS. This should be removed once this bug
+ // is properly fixed.
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ factory_.NewRunnableMethod(
+ &NetworkChangeNotifierLinux::NotifyObserversIPAddressChanged),
+ 500);
+#else
+ NotifyObserversIPAddressChanged();
+#endif
+ }
rv = ReadNotificationMessage(buf, arraysize(buf));
}
@@ -74,6 +92,10 @@ void NetworkChangeNotifierLinux::ListenForNotifications() {
}
}
+void NetworkChangeNotifierLinux::NotifyObserversIPAddressChanged() {
+ FOR_EACH_OBSERVER(Observer, observers_, OnIPAddressChanged());
+}
+
int NetworkChangeNotifierLinux::ReadNotificationMessage(char* buf, size_t len) {
DCHECK_NE(len, 0u);
DCHECK(buf);
diff --git a/net/base/network_change_notifier_linux.h b/net/base/network_change_notifier_linux.h
index db836da..b2b47a4 100644
--- a/net/base/network_change_notifier_linux.h
+++ b/net/base/network_change_notifier_linux.h
@@ -10,6 +10,10 @@
#include "base/observer_list.h"
#include "net/base/network_change_notifier.h"
+#if defined(OS_CHROMEOS)
+#include "base/task.h"
+#endif
+
namespace net {
class NetworkChangeNotifierLinux
@@ -53,10 +57,17 @@ class NetworkChangeNotifierLinux
// Stops watching the netlink file descriptor.
void StopWatching();
+ void NotifyObserversIPAddressChanged();
+
// http://crbug.com/36890.
ObserverList<Observer, false> observers_;
int netlink_fd_; // This is the netlink socket descriptor.
+
+#if defined(OS_CHROMEOS)
+ ScopedRunnableMethodFactory<NetworkChangeNotifierLinux> factory_;
+#endif
+
MessageLoopForIO* loop_;
MessageLoopForIO::FileDescriptorWatcher netlink_watcher_;