| 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> |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 strncpy(buf, ifr.ifr_name, IFNAMSIZ - 1); | 109 strncpy(buf, ifr.ifr_name, IFNAMSIZ - 1); |
| 110 return buf; | 110 return buf; |
| 111 } | 111 } |
| 112 | 112 |
| 113 AddressTrackerLinux::AddressTrackerLinux() | 113 AddressTrackerLinux::AddressTrackerLinux() |
| 114 : get_interface_name_(GetInterfaceName), | 114 : get_interface_name_(GetInterfaceName), |
| 115 address_callback_(base::Bind(&base::DoNothing)), | 115 address_callback_(base::Bind(&base::DoNothing)), |
| 116 link_callback_(base::Bind(&base::DoNothing)), | 116 link_callback_(base::Bind(&base::DoNothing)), |
| 117 tunnel_callback_(base::Bind(&base::DoNothing)), | 117 tunnel_callback_(base::Bind(&base::DoNothing)), |
| 118 netlink_fd_(-1), | 118 netlink_fd_(-1), |
| 119 watcher_(FROM_HERE), |
| 119 ignored_interfaces_(), | 120 ignored_interfaces_(), |
| 120 connection_type_initialized_(false), | 121 connection_type_initialized_(false), |
| 121 connection_type_initialized_cv_(&connection_type_lock_), | 122 connection_type_initialized_cv_(&connection_type_lock_), |
| 122 current_connection_type_(NetworkChangeNotifier::CONNECTION_NONE), | 123 current_connection_type_(NetworkChangeNotifier::CONNECTION_NONE), |
| 123 tracking_(false), | 124 tracking_(false), |
| 124 threads_waiting_for_connection_type_initialization_(0) {} | 125 threads_waiting_for_connection_type_initialization_(0) {} |
| 125 | 126 |
| 126 AddressTrackerLinux::AddressTrackerLinux( | 127 AddressTrackerLinux::AddressTrackerLinux( |
| 127 const base::Closure& address_callback, | 128 const base::Closure& address_callback, |
| 128 const base::Closure& link_callback, | 129 const base::Closure& link_callback, |
| 129 const base::Closure& tunnel_callback, | 130 const base::Closure& tunnel_callback, |
| 130 const std::unordered_set<std::string>& ignored_interfaces) | 131 const std::unordered_set<std::string>& ignored_interfaces) |
| 131 : get_interface_name_(GetInterfaceName), | 132 : get_interface_name_(GetInterfaceName), |
| 132 address_callback_(address_callback), | 133 address_callback_(address_callback), |
| 133 link_callback_(link_callback), | 134 link_callback_(link_callback), |
| 134 tunnel_callback_(tunnel_callback), | 135 tunnel_callback_(tunnel_callback), |
| 135 netlink_fd_(-1), | 136 netlink_fd_(-1), |
| 137 watcher_(FROM_HERE), |
| 136 ignored_interfaces_(ignored_interfaces), | 138 ignored_interfaces_(ignored_interfaces), |
| 137 connection_type_initialized_(false), | 139 connection_type_initialized_(false), |
| 138 connection_type_initialized_cv_(&connection_type_lock_), | 140 connection_type_initialized_cv_(&connection_type_lock_), |
| 139 current_connection_type_(NetworkChangeNotifier::CONNECTION_NONE), | 141 current_connection_type_(NetworkChangeNotifier::CONNECTION_NONE), |
| 140 tracking_(true), | 142 tracking_(true), |
| 141 threads_waiting_for_connection_type_initialization_(0) { | 143 threads_waiting_for_connection_type_initialization_(0) { |
| 142 DCHECK(!address_callback.is_null()); | 144 DCHECK(!address_callback.is_null()); |
| 143 DCHECK(!link_callback.is_null()); | 145 DCHECK(!link_callback.is_null()); |
| 144 } | 146 } |
| 145 | 147 |
| (...skipping 344 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 |