| 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 #include "net/base/address_tracker_linux.h" | 5 #include "net/base/address_tracker_linux.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <linux/if.h> | 8 #include <linux/if.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <sys/ioctl.h> | 10 #include <sys/ioctl.h> |
| 11 | 11 |
| 12 #include "base/files/scoped_file.h" | 12 #include "base/files/scoped_file.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/posix/eintr_wrapper.h" | 14 #include "base/posix/eintr_wrapper.h" |
| 15 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
| 16 #include "base/trace_event/trace_event.h" |
| 16 #include "net/base/network_interfaces_linux.h" | 17 #include "net/base/network_interfaces_linux.h" |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 namespace internal { | 20 namespace internal { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // Some kernel functions such as wireless_send_event and rtnetlink_ifinfo_prep | 24 // Some kernel functions such as wireless_send_event and rtnetlink_ifinfo_prep |
| 24 // may send spurious messages over rtnetlink. RTM_NEWLINK messages where | 25 // may send spurious messages over rtnetlink. RTM_NEWLINK messages where |
| 25 // ifi_change == 0 and rta_type == IFLA_WIRELESS should be ignored. | 26 // ifi_change == 0 and rta_type == IFLA_WIRELESS should be ignored. |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 *tunnel_changed = true; | 407 *tunnel_changed = true; |
| 407 } | 408 } |
| 408 } break; | 409 } break; |
| 409 default: | 410 default: |
| 410 break; | 411 break; |
| 411 } | 412 } |
| 412 } | 413 } |
| 413 } | 414 } |
| 414 | 415 |
| 415 void AddressTrackerLinux::OnFileCanReadWithoutBlocking(int fd) { | 416 void AddressTrackerLinux::OnFileCanReadWithoutBlocking(int fd) { |
| 417 TRACE_EVENT0("net", "AddressTrackerLinux::OnFileCanReadWithoutBlocking"); |
| 416 DCHECK_EQ(netlink_fd_, fd); | 418 DCHECK_EQ(netlink_fd_, fd); |
| 417 bool address_changed; | 419 bool address_changed; |
| 418 bool link_changed; | 420 bool link_changed; |
| 419 bool tunnel_changed; | 421 bool tunnel_changed; |
| 420 ReadMessages(&address_changed, &link_changed, &tunnel_changed); | 422 ReadMessages(&address_changed, &link_changed, &tunnel_changed); |
| 421 if (address_changed) | 423 if (address_changed) |
| 422 address_callback_.Run(); | 424 address_callback_.Run(); |
| 423 if (link_changed) | 425 if (link_changed) |
| 424 link_callback_.Run(); | 426 link_callback_.Run(); |
| 425 if (tunnel_changed) | 427 if (tunnel_changed) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 492 |
| 491 AddressTrackerLinux::AddressTrackerAutoLock::~AddressTrackerAutoLock() { | 493 AddressTrackerLinux::AddressTrackerAutoLock::~AddressTrackerAutoLock() { |
| 492 if (tracker_.tracking_) { | 494 if (tracker_.tracking_) { |
| 493 lock_.AssertAcquired(); | 495 lock_.AssertAcquired(); |
| 494 lock_.Release(); | 496 lock_.Release(); |
| 495 } | 497 } |
| 496 } | 498 } |
| 497 | 499 |
| 498 } // namespace internal | 500 } // namespace internal |
| 499 } // namespace net | 501 } // namespace net |
| OLD | NEW |