| OLD | NEW |
| 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_linux.h" | 5 #include "net/base/network_change_notifier_linux.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/eintr_wrapper.h" | 11 #include "base/eintr_wrapper.h" |
| 12 #include "base/task.h" | 12 #include "base/task.h" |
| 13 #include "base/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "net/base/network_change_notifier_netlink_linux.h" | 15 #include "net/base/network_change_notifier_netlink_linux.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 const int kInvalidSocket = -1; | 21 const int kInvalidSocket = -1; |
| 22 | 22 |
| 23 } // namespace | 23 } // namespace |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 netlink_fd_ = kInvalidSocket; | 84 netlink_fd_ = kInvalidSocket; |
| 85 netlink_watcher_.StopWatchingFileDescriptor(); | 85 netlink_watcher_.StopWatchingFileDescriptor(); |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 void NetworkChangeNotifierLinux::Thread::OnFileCanReadWithoutBlocking(int fd) { | 89 void NetworkChangeNotifierLinux::Thread::OnFileCanReadWithoutBlocking(int fd) { |
| 90 DCHECK_EQ(fd, netlink_fd_); | 90 DCHECK_EQ(fd, netlink_fd_); |
| 91 ListenForNotifications(); | 91 ListenForNotifications(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void NetworkChangeNotifierLinux::Thread::OnFileCanWriteWithoutBlocking(int /* fd
*/) { | 94 void NetworkChangeNotifierLinux::Thread::OnFileCanWriteWithoutBlocking( |
| 95 int /* fd */) { |
| 95 NOTREACHED(); | 96 NOTREACHED(); |
| 96 } | 97 } |
| 97 | 98 |
| 98 void NetworkChangeNotifierLinux::Thread::ListenForNotifications() { | 99 void NetworkChangeNotifierLinux::Thread::ListenForNotifications() { |
| 99 char buf[4096]; | 100 char buf[4096]; |
| 100 int rv = ReadNotificationMessage(buf, arraysize(buf)); | 101 int rv = ReadNotificationMessage(buf, arraysize(buf)); |
| 101 while (rv > 0) { | 102 while (rv > 0) { |
| 102 if (HandleNetlinkMessage(buf, rv)) { | 103 if (HandleNetlinkMessage(buf, rv)) { |
| 103 VLOG(1) << "Detected IP address changes."; | 104 VLOG(1) << "Detected IP address changes."; |
| 104 #if defined(OS_CHROMEOS) | 105 #if defined(OS_CHROMEOS) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // check that the notifier thread shut down properly. | 160 // check that the notifier thread shut down properly. |
| 160 notifier_thread_->Stop(); | 161 notifier_thread_->Stop(); |
| 161 } | 162 } |
| 162 | 163 |
| 163 bool NetworkChangeNotifierLinux::IsCurrentlyOffline() const { | 164 bool NetworkChangeNotifierLinux::IsCurrentlyOffline() const { |
| 164 // TODO(eroman): http://crbug.com/53473 | 165 // TODO(eroman): http://crbug.com/53473 |
| 165 return false; | 166 return false; |
| 166 } | 167 } |
| 167 | 168 |
| 168 } // namespace net | 169 } // namespace net |
| OLD | NEW |