| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 133 } |
| 134 }; | 134 }; |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 // Base class for NetworkManager implementations. | 137 // Base class for NetworkManager implementations. |
| 138 class NetworkManagerBase : public NetworkManager { | 138 class NetworkManagerBase : public NetworkManager { |
| 139 public: | 139 public: |
| 140 NetworkManagerBase(); | 140 NetworkManagerBase(); |
| 141 ~NetworkManagerBase() override; | 141 ~NetworkManagerBase() override; |
| 142 | 142 |
| 143 void GetNetworks(std::vector<Network*>* networks) const override; | 143 void GetNetworks(NetworkList* networks) const override; |
| 144 void GetAnyAddressNetworks(NetworkList* networks) override; | 144 void GetAnyAddressNetworks(NetworkList* networks) override; |
| 145 bool ipv6_enabled() const { return ipv6_enabled_; } | 145 bool ipv6_enabled() const { return ipv6_enabled_; } |
| 146 void set_ipv6_enabled(bool enabled) { ipv6_enabled_ = enabled; } | 146 void set_ipv6_enabled(bool enabled) { ipv6_enabled_ = enabled; } |
| 147 | 147 |
| 148 void set_max_ipv6_networks(int networks) { max_ipv6_networks_ = networks; } | 148 void set_max_ipv6_networks(int networks) { max_ipv6_networks_ = networks; } |
| 149 int max_ipv6_networks() { return max_ipv6_networks_; } | 149 int max_ipv6_networks() { return max_ipv6_networks_; } |
| 150 | 150 |
| 151 EnumerationPermission enumeration_permission() const override; | 151 EnumerationPermission enumeration_permission() const override; |
| 152 | 152 |
| 153 bool GetDefaultLocalAddress(int family, IPAddress* ipaddr) const override; | 153 bool GetDefaultLocalAddress(int family, IPAddress* ipaddr) const override; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 const IPAddress& prefix, | 283 const IPAddress& prefix, |
| 284 int prefix_length); | 284 int prefix_length); |
| 285 | 285 |
| 286 Network(const std::string& name, | 286 Network(const std::string& name, |
| 287 const std::string& description, | 287 const std::string& description, |
| 288 const IPAddress& prefix, | 288 const IPAddress& prefix, |
| 289 int prefix_length, | 289 int prefix_length, |
| 290 AdapterType type); | 290 AdapterType type); |
| 291 ~Network(); | 291 ~Network(); |
| 292 | 292 |
| 293 sigslot::signal1<const Network*> SignalInactive; | |
| 294 sigslot::signal1<const Network*> SignalTypeChanged; | 293 sigslot::signal1<const Network*> SignalTypeChanged; |
| 295 | 294 |
| 296 const DefaultLocalAddressProvider* default_local_address_provider() { | 295 const DefaultLocalAddressProvider* default_local_address_provider() { |
| 297 return default_local_address_provider_; | 296 return default_local_address_provider_; |
| 298 } | 297 } |
| 299 void set_default_local_address_provider( | 298 void set_default_local_address_provider( |
| 300 const DefaultLocalAddressProvider* provider) { | 299 const DefaultLocalAddressProvider* provider) { |
| 301 default_local_address_provider_ = provider; | 300 default_local_address_provider_ = provider; |
| 302 } | 301 } |
| 303 | 302 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 void set_id(uint16_t id) { id_ = id; } | 390 void set_id(uint16_t id) { id_ = id; } |
| 392 | 391 |
| 393 int preference() const { return preference_; } | 392 int preference() const { return preference_; } |
| 394 void set_preference(int preference) { preference_ = preference; } | 393 void set_preference(int preference) { preference_ = preference; } |
| 395 | 394 |
| 396 // When we enumerate networks and find a previously-seen network is missing, | 395 // When we enumerate networks and find a previously-seen network is missing, |
| 397 // we do not remove it (because it may be used elsewhere). Instead, we mark | 396 // we do not remove it (because it may be used elsewhere). Instead, we mark |
| 398 // it inactive, so that we can detect network changes properly. | 397 // it inactive, so that we can detect network changes properly. |
| 399 bool active() const { return active_; } | 398 bool active() const { return active_; } |
| 400 void set_active(bool active) { | 399 void set_active(bool active) { |
| 401 if (active_ == active) { | 400 if (active_ != active) { |
| 402 return; | 401 active_ = active; |
| 403 } | |
| 404 active_ = active; | |
| 405 if (!active) { | |
| 406 SignalInactive(this); | |
| 407 } | 402 } |
| 408 } | 403 } |
| 409 | 404 |
| 410 // Debugging description of this network | 405 // Debugging description of this network |
| 411 std::string ToString() const; | 406 std::string ToString() const; |
| 412 | 407 |
| 413 private: | 408 private: |
| 414 const DefaultLocalAddressProvider* default_local_address_provider_ = nullptr; | 409 const DefaultLocalAddressProvider* default_local_address_provider_ = nullptr; |
| 415 std::string name_; | 410 std::string name_; |
| 416 std::string description_; | 411 std::string description_; |
| 417 IPAddress prefix_; | 412 IPAddress prefix_; |
| 418 int prefix_length_; | 413 int prefix_length_; |
| 419 std::string key_; | 414 std::string key_; |
| 420 std::vector<InterfaceAddress> ips_; | 415 std::vector<InterfaceAddress> ips_; |
| 421 int scope_id_; | 416 int scope_id_; |
| 422 bool ignored_; | 417 bool ignored_; |
| 423 AdapterType type_; | 418 AdapterType type_; |
| 424 int preference_; | 419 int preference_; |
| 425 bool active_ = true; | 420 bool active_ = true; |
| 426 uint16_t id_ = 0; | 421 uint16_t id_ = 0; |
| 427 | 422 |
| 428 friend class NetworkManager; | 423 friend class NetworkManager; |
| 429 }; | 424 }; |
| 430 | 425 |
| 431 } // namespace rtc | 426 } // namespace rtc |
| 432 | 427 |
| 433 #endif // WEBRTC_BASE_NETWORK_H_ | 428 #endif // WEBRTC_BASE_NETWORK_H_ |
| OLD | NEW |