| 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 <linux/if.h> | 7 #include <linux/if.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <unordered_set> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/bind.h" | 13 #include "base/bind.h" |
| 13 #include "base/synchronization/spin_wait.h" | 14 #include "base/synchronization/spin_wait.h" |
| 14 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 15 #include "base/threading/simple_thread.h" | 16 #include "base/threading/simple_thread.h" |
| 16 #include "net/base/ip_address.h" | 17 #include "net/base/ip_address.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 #ifndef IFA_F_HOMEADDRESS | 20 #ifndef IFA_F_HOMEADDRESS |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 tracker_->HandleMessage(&writable_buf[0], buf.size(), | 95 tracker_->HandleMessage(&writable_buf[0], buf.size(), |
| 95 &address_changed, &link_changed, &tunnel_changed); | 96 &address_changed, &link_changed, &tunnel_changed); |
| 96 EXPECT_FALSE(address_changed); | 97 EXPECT_FALSE(address_changed); |
| 97 return tunnel_changed; | 98 return tunnel_changed; |
| 98 } | 99 } |
| 99 | 100 |
| 100 AddressTrackerLinux::AddressMap GetAddressMap() { | 101 AddressTrackerLinux::AddressMap GetAddressMap() { |
| 101 return tracker_->GetAddressMap(); | 102 return tracker_->GetAddressMap(); |
| 102 } | 103 } |
| 103 | 104 |
| 104 const base::hash_set<int> GetOnlineLinks() const { | 105 const std::unordered_set<int> GetOnlineLinks() const { |
| 105 return tracker_->GetOnlineLinks(); | 106 return tracker_->GetOnlineLinks(); |
| 106 } | 107 } |
| 107 | 108 |
| 108 void IgnoreInterface(const std::string& interface_name) { | 109 void IgnoreInterface(const std::string& interface_name) { |
| 109 ignored_interfaces_.insert(interface_name); | 110 ignored_interfaces_.insert(interface_name); |
| 110 } | 111 } |
| 111 | 112 |
| 112 int GetThreadsWaitingForConnectionTypeInit() { | 113 int GetThreadsWaitingForConnectionTypeInit() { |
| 113 return tracker_->GetThreadsWaitingForConnectionTypeInitForTesting(); | 114 return tracker_->GetThreadsWaitingForConnectionTypeInitForTesting(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 base::hash_set<std::string> ignored_interfaces_; | 117 std::unordered_set<std::string> ignored_interfaces_; |
| 117 std::unique_ptr<AddressTrackerLinux> tracker_; | 118 std::unique_ptr<AddressTrackerLinux> tracker_; |
| 118 AddressTrackerLinux::GetInterfaceNameFunction original_get_interface_name_; | 119 AddressTrackerLinux::GetInterfaceNameFunction original_get_interface_name_; |
| 119 }; | 120 }; |
| 120 | 121 |
| 121 namespace { | 122 namespace { |
| 122 | 123 |
| 123 class NetlinkMessage { | 124 class NetlinkMessage { |
| 124 public: | 125 public: |
| 125 explicit NetlinkMessage(uint16_t type) : buffer_(NLMSG_HDRLEN) { | 126 explicit NetlinkMessage(uint16_t type) : buffer_(NLMSG_HDRLEN) { |
| 126 header()->nlmsg_type = type; | 127 header()->nlmsg_type = type; |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 tracker_->Init(); | 731 tracker_->Init(); |
| 731 | 732 |
| 732 runner1.VerifyCompletes(); | 733 runner1.VerifyCompletes(); |
| 733 runner2.VerifyCompletes(); | 734 runner2.VerifyCompletes(); |
| 734 } | 735 } |
| 735 | 736 |
| 736 } // namespace | 737 } // namespace |
| 737 | 738 |
| 738 } // namespace internal | 739 } // namespace internal |
| 739 } // namespace net | 740 } // namespace net |
| OLD | NEW |