| 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 |
| 11 #ifndef WEBRTC_BASE_FAKENETWORK_H_ | 11 #ifndef WEBRTC_BASE_FAKENETWORK_H_ |
| 12 #define WEBRTC_BASE_FAKENETWORK_H_ | 12 #define WEBRTC_BASE_FAKENETWORK_H_ |
| 13 | 13 |
| 14 #include <memory> |
| 14 #include <string> | 15 #include <string> |
| 15 #include <utility> | 16 #include <utility> |
| 16 #include <vector> | 17 #include <vector> |
| 17 | 18 |
| 18 #include "webrtc/base/network.h" | 19 #include "webrtc/base/network.h" |
| 19 #include "webrtc/base/messagehandler.h" | 20 #include "webrtc/base/messagehandler.h" |
| 20 #include "webrtc/base/socketaddress.h" | 21 #include "webrtc/base/socketaddress.h" |
| 21 #include "webrtc/base/stringencode.h" | 22 #include "webrtc/base/stringencode.h" |
| 22 #include "webrtc/base/thread.h" | 23 #include "webrtc/base/thread.h" |
| 23 | 24 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 std::vector<Network*> networks; | 93 std::vector<Network*> networks; |
| 93 for (IfaceList::iterator it = ifaces_.begin(); | 94 for (IfaceList::iterator it = ifaces_.begin(); |
| 94 it != ifaces_.end(); ++it) { | 95 it != ifaces_.end(); ++it) { |
| 95 int prefix_length = 0; | 96 int prefix_length = 0; |
| 96 if (it->first.ipaddr().family() == AF_INET) { | 97 if (it->first.ipaddr().family() == AF_INET) { |
| 97 prefix_length = kFakeIPv4NetworkPrefixLength; | 98 prefix_length = kFakeIPv4NetworkPrefixLength; |
| 98 } else if (it->first.ipaddr().family() == AF_INET6) { | 99 } else if (it->first.ipaddr().family() == AF_INET6) { |
| 99 prefix_length = kFakeIPv6NetworkPrefixLength; | 100 prefix_length = kFakeIPv6NetworkPrefixLength; |
| 100 } | 101 } |
| 101 IPAddress prefix = TruncateIP(it->first.ipaddr(), prefix_length); | 102 IPAddress prefix = TruncateIP(it->first.ipaddr(), prefix_length); |
| 102 scoped_ptr<Network> net(new Network(it->first.hostname(), | 103 std::unique_ptr<Network> net(new Network(it->first.hostname(), |
| 103 it->first.hostname(), prefix, | 104 it->first.hostname(), prefix, |
| 104 prefix_length, it->second)); | 105 prefix_length, it->second)); |
| 105 net->set_default_local_address_provider(this); | 106 net->set_default_local_address_provider(this); |
| 106 net->AddIP(it->first.ipaddr()); | 107 net->AddIP(it->first.ipaddr()); |
| 107 networks.push_back(net.release()); | 108 networks.push_back(net.release()); |
| 108 } | 109 } |
| 109 bool changed; | 110 bool changed; |
| 110 MergeNetworkList(networks, &changed); | 111 MergeNetworkList(networks, &changed); |
| 111 if (changed || !sent_first_update_) { | 112 if (changed || !sent_first_update_) { |
| 112 SignalNetworksChanged(); | 113 SignalNetworksChanged(); |
| 113 sent_first_update_ = true; | 114 sent_first_update_ = true; |
| 114 } | 115 } |
| 115 } | 116 } |
| 116 | 117 |
| 117 Thread* thread_; | 118 Thread* thread_; |
| 118 IfaceList ifaces_; | 119 IfaceList ifaces_; |
| 119 int next_index_ = 0; | 120 int next_index_ = 0; |
| 120 int start_count_ = 0; | 121 int start_count_ = 0; |
| 121 bool sent_first_update_ = false; | 122 bool sent_first_update_ = false; |
| 122 | 123 |
| 123 IPAddress default_local_ipv4_address_; | 124 IPAddress default_local_ipv4_address_; |
| 124 IPAddress default_local_ipv6_address_; | 125 IPAddress default_local_ipv6_address_; |
| 125 }; | 126 }; |
| 126 | 127 |
| 127 } // namespace rtc | 128 } // namespace rtc |
| 128 | 129 |
| 129 #endif // WEBRTC_BASE_FAKENETWORK_H_ | 130 #endif // WEBRTC_BASE_FAKENETWORK_H_ |
| OLD | NEW |