OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This implementation of NetworkChangeNotifier's offline state detection | 5 // This implementation of NetworkChangeNotifier's offline state detection |
6 // depends on D-Bus and NetworkManager, and is known to work on at least | 6 // depends on D-Bus and NetworkManager, and is known to work on at least |
7 // GNOME version 2.30. If D-Bus or NetworkManager are unavailable, this | 7 // GNOME version 2.30. If D-Bus or NetworkManager are unavailable, this |
8 // implementation will always behave as if it is online. | 8 // implementation will always behave as if it is online. |
9 | 9 |
10 #include "net/base/network_change_notifier_linux.h" | 10 #include "net/base/network_change_notifier_linux.h" |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 int /* fd */) { | 377 int /* fd */) { |
378 NOTREACHED(); | 378 NOTREACHED(); |
379 } | 379 } |
380 | 380 |
381 void NetworkChangeNotifierLinux::Thread::ListenForNotifications() { | 381 void NetworkChangeNotifierLinux::Thread::ListenForNotifications() { |
382 char buf[4096]; | 382 char buf[4096]; |
383 int rv = ReadNotificationMessage(buf, arraysize(buf)); | 383 int rv = ReadNotificationMessage(buf, arraysize(buf)); |
384 while (rv > 0) { | 384 while (rv > 0) { |
385 if (HandleNetlinkMessage(buf, rv)) { | 385 if (HandleNetlinkMessage(buf, rv)) { |
386 VLOG(1) << "Detected IP address changes."; | 386 VLOG(1) << "Detected IP address changes."; |
387 #if defined(OS_CHROMEOS) | |
388 // TODO(oshima): chromium-os:8285 - introduced artificial delay to | |
389 // work around the issue of network load issue after connection | |
390 // restored. See the bug for more details. | |
391 // This should be removed once this bug is properly fixed. | |
392 const int kObserverNotificationDelayMS = 200; | |
393 message_loop()->PostDelayedTask( | |
394 FROM_HERE, | |
395 base::Bind(&NetworkChangeNotifier::NotifyObserversOfIPAddressChange), | |
396 kObserverNotificationDelayMS); | |
397 #else | |
398 NotifyObserversOfIPAddressChange(); | 387 NotifyObserversOfIPAddressChange(); |
399 #endif | |
400 } | 388 } |
401 rv = ReadNotificationMessage(buf, arraysize(buf)); | 389 rv = ReadNotificationMessage(buf, arraysize(buf)); |
402 } | 390 } |
403 | 391 |
404 if (rv == ERR_IO_PENDING) { | 392 if (rv == ERR_IO_PENDING) { |
405 rv = MessageLoopForIO::current()->WatchFileDescriptor(netlink_fd_, false, | 393 rv = MessageLoopForIO::current()->WatchFileDescriptor(netlink_fd_, false, |
406 MessageLoopForIO::WATCH_READ, &netlink_watcher_, this); | 394 MessageLoopForIO::WATCH_READ, &netlink_watcher_, this); |
407 LOG_IF(ERROR, !rv) << "Failed to watch netlink socket: " << netlink_fd_; | 395 LOG_IF(ERROR, !rv) << "Failed to watch netlink socket: " << netlink_fd_; |
408 } | 396 } |
409 } | 397 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 // Stopping from here allows us to sanity- check that the notifier | 437 // Stopping from here allows us to sanity- check that the notifier |
450 // thread shut down properly. | 438 // thread shut down properly. |
451 notifier_thread_->Stop(); | 439 notifier_thread_->Stop(); |
452 } | 440 } |
453 | 441 |
454 bool NetworkChangeNotifierLinux::IsCurrentlyOffline() const { | 442 bool NetworkChangeNotifierLinux::IsCurrentlyOffline() const { |
455 return notifier_thread_->IsCurrentlyOffline(); | 443 return notifier_thread_->IsCurrentlyOffline(); |
456 } | 444 } |
457 | 445 |
458 } // namespace net | 446 } // namespace net |
OLD | NEW |