OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 // Fake network manager that allows us to manually specify the IPs to use. | 28 // Fake network manager that allows us to manually specify the IPs to use. |
29 class FakeNetworkManager : public NetworkManagerBase, | 29 class FakeNetworkManager : public NetworkManagerBase, |
30 public MessageHandler { | 30 public MessageHandler { |
31 public: | 31 public: |
32 FakeNetworkManager() : thread_(Thread::Current()) {} | 32 FakeNetworkManager() : thread_(Thread::Current()) {} |
33 | 33 |
34 typedef std::vector<SocketAddress> IfaceList; | 34 typedef std::vector<SocketAddress> IfaceList; |
35 | 35 |
36 void AddInterface(const SocketAddress& iface) { | 36 void AddInterface(const SocketAddress& iface) { |
37 // ensure a unique name for the interface | 37 // Ensure a unique name for the interface if its name is not given. |
38 SocketAddress address("test" + rtc::ToString(next_index_++), 0); | 38 AddInterface(iface, "test" + rtc::ToString(next_index_++)); |
| 39 } |
| 40 |
| 41 void AddInterface(const SocketAddress& iface, const std::string& if_name) { |
| 42 SocketAddress address(if_name, 0); |
39 address.SetResolvedIP(iface.ipaddr()); | 43 address.SetResolvedIP(iface.ipaddr()); |
40 ifaces_.push_back(address); | 44 ifaces_.push_back(address); |
41 DoUpdateNetworks(); | 45 DoUpdateNetworks(); |
42 } | 46 } |
43 | 47 |
44 void RemoveInterface(const SocketAddress& iface) { | 48 void RemoveInterface(const SocketAddress& iface) { |
45 for (IfaceList::iterator it = ifaces_.begin(); | 49 for (IfaceList::iterator it = ifaces_.begin(); |
46 it != ifaces_.end(); ++it) { | 50 it != ifaces_.end(); ++it) { |
47 if (it->EqualIPs(iface)) { | 51 if (it->EqualIPs(iface)) { |
48 ifaces_.erase(it); | 52 ifaces_.erase(it); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 Thread* thread_; | 109 Thread* thread_; |
106 IfaceList ifaces_; | 110 IfaceList ifaces_; |
107 int next_index_ = 0; | 111 int next_index_ = 0; |
108 int start_count_ = 0; | 112 int start_count_ = 0; |
109 bool sent_first_update_ = false; | 113 bool sent_first_update_ = false; |
110 }; | 114 }; |
111 | 115 |
112 } // namespace rtc | 116 } // namespace rtc |
113 | 117 |
114 #endif // WEBRTC_BASE_FAKENETWORK_H_ | 118 #endif // WEBRTC_BASE_FAKENETWORK_H_ |
OLD | NEW |