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 "net/base/network_interfaces_linux.h" | 16 #include "net/base/network_interfaces_linux.h" |
17 | 17 |
| 18 #include "base/trace_event/trace_event.h" |
| 19 |
18 namespace net { | 20 namespace net { |
19 namespace internal { | 21 namespace internal { |
20 | 22 |
21 namespace { | 23 namespace { |
22 | 24 |
23 // Some kernel functions such as wireless_send_event and rtnetlink_ifinfo_prep | 25 // Some kernel functions such as wireless_send_event and rtnetlink_ifinfo_prep |
24 // may send spurious messages over rtnetlink. RTM_NEWLINK messages where | 26 // may send spurious messages over rtnetlink. RTM_NEWLINK messages where |
25 // ifi_change == 0 and rta_type == IFLA_WIRELESS should be ignored. | 27 // ifi_change == 0 and rta_type == IFLA_WIRELESS should be ignored. |
26 bool IgnoreWirelessChange(const struct nlmsghdr* header, | 28 bool IgnoreWirelessChange(const struct nlmsghdr* header, |
27 const struct ifinfomsg* msg) { | 29 const struct ifinfomsg* msg) { |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 *tunnel_changed = true; | 408 *tunnel_changed = true; |
407 } | 409 } |
408 } break; | 410 } break; |
409 default: | 411 default: |
410 break; | 412 break; |
411 } | 413 } |
412 } | 414 } |
413 } | 415 } |
414 | 416 |
415 void AddressTrackerLinux::OnFileCanReadWithoutBlocking(int fd) { | 417 void AddressTrackerLinux::OnFileCanReadWithoutBlocking(int fd) { |
| 418 TRACE_EVENT0("net", "net::AddressTrackerLinux::OnFileCanReadWithoutBlocking"); |
416 DCHECK_EQ(netlink_fd_, fd); | 419 DCHECK_EQ(netlink_fd_, fd); |
417 bool address_changed; | 420 bool address_changed; |
418 bool link_changed; | 421 bool link_changed; |
419 bool tunnel_changed; | 422 bool tunnel_changed; |
420 ReadMessages(&address_changed, &link_changed, &tunnel_changed); | 423 ReadMessages(&address_changed, &link_changed, &tunnel_changed); |
421 if (address_changed) | 424 if (address_changed) |
422 address_callback_.Run(); | 425 address_callback_.Run(); |
423 if (link_changed) | 426 if (link_changed) |
424 link_callback_.Run(); | 427 link_callback_.Run(); |
425 if (tunnel_changed) | 428 if (tunnel_changed) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 | 493 |
491 AddressTrackerLinux::AddressTrackerAutoLock::~AddressTrackerAutoLock() { | 494 AddressTrackerLinux::AddressTrackerAutoLock::~AddressTrackerAutoLock() { |
492 if (tracker_.tracking_) { | 495 if (tracker_.tracking_) { |
493 lock_.AssertAcquired(); | 496 lock_.AssertAcquired(); |
494 lock_.Release(); | 497 lock_.Release(); |
495 } | 498 } |
496 } | 499 } |
497 | 500 |
498 } // namespace internal | 501 } // namespace internal |
499 } // namespace net | 502 } // namespace net |
OLD | NEW |