Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 // return the current permission state of GetNetworks() | 104 // return the current permission state of GetNetworks() |
| 105 virtual EnumerationPermission enumeration_permission() const; | 105 virtual EnumerationPermission enumeration_permission() const; |
| 106 | 106 |
| 107 // "AnyAddressNetwork" is a network which only contains single "any address" | 107 // "AnyAddressNetwork" is a network which only contains single "any address" |
| 108 // IP address. (i.e. INADDR_ANY for IPv4 or in6addr_any for IPv6). This is | 108 // IP address. (i.e. INADDR_ANY for IPv4 or in6addr_any for IPv6). This is |
| 109 // useful as binding to such interfaces allow default routing behavior like | 109 // useful as binding to such interfaces allow default routing behavior like |
| 110 // http traffic. | 110 // http traffic. |
| 111 // TODO(guoweis): remove this body when chromium implements this. | 111 // TODO(guoweis): remove this body when chromium implements this. |
| 112 virtual void GetAnyAddressNetworks(NetworkList* networks) {} | 112 virtual void GetAnyAddressNetworks(NetworkList* networks) {} |
| 113 | 113 |
| 114 // Dumps the current list of networks in the network manager. | |
| 115 virtual void DumpNetworks() {} | |
| 114 bool GetDefaultLocalAddress(int family, IPAddress* ipaddr) const override; | 116 bool GetDefaultLocalAddress(int family, IPAddress* ipaddr) const override; |
| 115 | 117 |
| 116 // Dumps a list of networks available to LS_INFO. | |
| 117 virtual void DumpNetworks(bool include_ignored) {} | |
| 118 | |
| 119 struct Stats { | 118 struct Stats { |
| 120 int ipv4_network_count; | 119 int ipv4_network_count; |
| 121 int ipv6_network_count; | 120 int ipv6_network_count; |
| 122 Stats() { | 121 Stats() { |
| 123 ipv4_network_count = 0; | 122 ipv4_network_count = 0; |
| 124 ipv6_network_count = 0; | 123 ipv6_network_count = 0; |
| 125 } | 124 } |
| 126 }; | 125 }; |
| 127 }; | 126 }; |
| 128 | 127 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 class BasicNetworkManager : public NetworkManagerBase, | 187 class BasicNetworkManager : public NetworkManagerBase, |
| 189 public MessageHandler, | 188 public MessageHandler, |
| 190 public sigslot::has_slots<> { | 189 public sigslot::has_slots<> { |
| 191 public: | 190 public: |
| 192 BasicNetworkManager(); | 191 BasicNetworkManager(); |
| 193 ~BasicNetworkManager() override; | 192 ~BasicNetworkManager() override; |
| 194 | 193 |
| 195 void StartUpdating() override; | 194 void StartUpdating() override; |
| 196 void StopUpdating() override; | 195 void StopUpdating() override; |
| 197 | 196 |
| 198 // Logs the available networks. | 197 void DumpNetworks() override; |
| 199 void DumpNetworks(bool include_ignored) override; | |
| 200 | 198 |
| 201 // MessageHandler interface. | 199 // MessageHandler interface. |
| 202 void OnMessage(Message* msg) override; | 200 void OnMessage(Message* msg) override; |
| 203 bool started() { return start_count_ > 0; } | 201 bool started() { return start_count_ > 0; } |
| 204 | 202 |
| 205 // Sets the network ignore list, which is empty by default. Any network on the | 203 // Sets the network ignore list, which is empty by default. Any network on the |
| 206 // ignore list will be filtered from network enumeration results. | 204 // ignore list will be filtered from network enumeration results. |
| 207 void set_network_ignore_list(const std::vector<std::string>& list) { | 205 void set_network_ignore_list(const std::vector<std::string>& list) { |
| 208 network_ignore_list_ = list; | 206 network_ignore_list_ = list; |
| 209 } | 207 } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 | 350 |
| 353 // Indicates whether this network should be ignored, perhaps because | 351 // Indicates whether this network should be ignored, perhaps because |
| 354 // the IP is 0, or the interface is one we know is invalid. | 352 // the IP is 0, or the interface is one we know is invalid. |
| 355 bool ignored() const { return ignored_; } | 353 bool ignored() const { return ignored_; } |
| 356 void set_ignored(bool ignored) { ignored_ = ignored; } | 354 void set_ignored(bool ignored) { ignored_ = ignored; } |
| 357 | 355 |
| 358 AdapterType type() const { return type_; } | 356 AdapterType type() const { return type_; } |
| 359 int preference() const { return preference_; } | 357 int preference() const { return preference_; } |
| 360 void set_preference(int preference) { preference_ = preference; } | 358 void set_preference(int preference) { preference_ = preference; } |
| 361 | 359 |
| 360 // When we enumerate networks and find a previously-seen network is missing, | |
| 361 // we do not remove it (because it may be used elsewhere). Instead, we mark | |
| 362 // it inactive, so that we can detect network changes properly. | |
| 363 bool active() const { return active_; } | |
| 364 void set_active(bool active) { active_ = active; } | |
|
pthatcher1
2015/12/18 22:03:39
Does set_active need to be public? Since NetworkM
honghaiz3
2015/12/21 04:30:04
It was used by NetworkManagerBase. So we cannot ma
| |
| 365 | |
| 362 // Debugging description of this network | 366 // Debugging description of this network |
| 363 std::string ToString() const; | 367 std::string ToString() const; |
| 364 | 368 |
| 365 private: | 369 private: |
| 366 const DefaultLocalAddressProvider* default_local_address_provider_ = nullptr; | 370 const DefaultLocalAddressProvider* default_local_address_provider_ = nullptr; |
| 367 std::string name_; | 371 std::string name_; |
| 368 std::string description_; | 372 std::string description_; |
| 369 IPAddress prefix_; | 373 IPAddress prefix_; |
| 370 int prefix_length_; | 374 int prefix_length_; |
| 371 std::string key_; | 375 std::string key_; |
| 372 std::vector<InterfaceAddress> ips_; | 376 std::vector<InterfaceAddress> ips_; |
| 373 int scope_id_; | 377 int scope_id_; |
| 374 bool ignored_; | 378 bool ignored_; |
| 375 AdapterType type_; | 379 AdapterType type_; |
| 376 int preference_; | 380 int preference_; |
| 381 bool active_ = true; | |
| 377 | 382 |
| 378 friend class NetworkManager; | 383 friend class NetworkManager; |
| 379 }; | 384 }; |
| 380 | 385 |
| 381 } // namespace rtc | 386 } // namespace rtc |
| 382 | 387 |
| 383 #endif // WEBRTC_BASE_NETWORK_H_ | 388 #endif // WEBRTC_BASE_NETWORK_H_ |
| OLD | NEW |