| 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 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 namespace rtc { | 25 namespace rtc { |
| 26 | 26 |
| 27 const int kFakeIPv4NetworkPrefixLength = 24; | 27 const int kFakeIPv4NetworkPrefixLength = 24; |
| 28 const int kFakeIPv6NetworkPrefixLength = 64; | 28 const int kFakeIPv6NetworkPrefixLength = 64; |
| 29 | 29 |
| 30 // Fake network manager that allows us to manually specify the IPs to use. | 30 // Fake network manager that allows us to manually specify the IPs to use. |
| 31 class FakeNetworkManager : public NetworkManagerBase, | 31 class FakeNetworkManager : public NetworkManagerBase, |
| 32 public MessageHandler { | 32 public MessageHandler { |
| 33 public: | 33 public: |
| 34 FakeNetworkManager() : thread_(Thread::Current()) {} | 34 FakeNetworkManager() {} |
| 35 | 35 |
| 36 typedef std::vector<std::pair<SocketAddress, AdapterType>> IfaceList; | 36 typedef std::vector<std::pair<SocketAddress, AdapterType>> IfaceList; |
| 37 | 37 |
| 38 void AddInterface(const SocketAddress& iface) { | 38 void AddInterface(const SocketAddress& iface) { |
| 39 // Ensure a unique name for the interface if its name is not given. | 39 // Ensure a unique name for the interface if its name is not given. |
| 40 AddInterface(iface, "test" + rtc::ToString(next_index_++)); | 40 AddInterface(iface, "test" + rtc::ToString(next_index_++)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void AddInterface(const SocketAddress& iface, const std::string& if_name) { | 43 void AddInterface(const SocketAddress& iface, const std::string& if_name) { |
| 44 AddInterface(iface, if_name, ADAPTER_TYPE_UNKNOWN); | 44 AddInterface(iface, if_name, ADAPTER_TYPE_UNKNOWN); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 61 break; | 61 break; |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 DoUpdateNetworks(); | 64 DoUpdateNetworks(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 virtual void StartUpdating() { | 67 virtual void StartUpdating() { |
| 68 ++start_count_; | 68 ++start_count_; |
| 69 if (start_count_ == 1) { | 69 if (start_count_ == 1) { |
| 70 sent_first_update_ = false; | 70 sent_first_update_ = false; |
| 71 thread_->Post(RTC_FROM_HERE, this); | 71 rtc::Thread::Current()->Post(RTC_FROM_HERE, this); |
| 72 } else { | 72 } else { |
| 73 if (sent_first_update_) { | 73 if (sent_first_update_) { |
| 74 SignalNetworksChanged(); | 74 SignalNetworksChanged(); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 virtual void StopUpdating() { --start_count_; } | 79 virtual void StopUpdating() { --start_count_; } |
| 80 | 80 |
| 81 // MessageHandler interface. | 81 // MessageHandler interface. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 108 networks.push_back(net.release()); | 108 networks.push_back(net.release()); |
| 109 } | 109 } |
| 110 bool changed; | 110 bool changed; |
| 111 MergeNetworkList(networks, &changed); | 111 MergeNetworkList(networks, &changed); |
| 112 if (changed || !sent_first_update_) { | 112 if (changed || !sent_first_update_) { |
| 113 SignalNetworksChanged(); | 113 SignalNetworksChanged(); |
| 114 sent_first_update_ = true; | 114 sent_first_update_ = true; |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 Thread* thread_; | |
| 119 IfaceList ifaces_; | 118 IfaceList ifaces_; |
| 120 int next_index_ = 0; | 119 int next_index_ = 0; |
| 121 int start_count_ = 0; | 120 int start_count_ = 0; |
| 122 bool sent_first_update_ = false; | 121 bool sent_first_update_ = false; |
| 123 | 122 |
| 124 IPAddress default_local_ipv4_address_; | 123 IPAddress default_local_ipv4_address_; |
| 125 IPAddress default_local_ipv6_address_; | 124 IPAddress default_local_ipv6_address_; |
| 126 }; | 125 }; |
| 127 | 126 |
| 128 } // namespace rtc | 127 } // namespace rtc |
| 129 | 128 |
| 130 #endif // WEBRTC_BASE_FAKENETWORK_H_ | 129 #endif // WEBRTC_BASE_FAKENETWORK_H_ |
| OLD | NEW |