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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 const IPAddress& prefix, | 266 const IPAddress& prefix, |
267 int prefix_length); | 267 int prefix_length); |
268 | 268 |
269 Network(const std::string& name, | 269 Network(const std::string& name, |
270 const std::string& description, | 270 const std::string& description, |
271 const IPAddress& prefix, | 271 const IPAddress& prefix, |
272 int prefix_length, | 272 int prefix_length, |
273 AdapterType type); | 273 AdapterType type); |
274 ~Network(); | 274 ~Network(); |
275 | 275 |
| 276 sigslot::signal1<const Network*> SignalInactive; |
| 277 |
276 const DefaultLocalAddressProvider* default_local_address_provider() { | 278 const DefaultLocalAddressProvider* default_local_address_provider() { |
277 return default_local_address_provider_; | 279 return default_local_address_provider_; |
278 } | 280 } |
279 void set_default_local_address_provider( | 281 void set_default_local_address_provider( |
280 const DefaultLocalAddressProvider* provider) { | 282 const DefaultLocalAddressProvider* provider) { |
281 default_local_address_provider_ = provider; | 283 default_local_address_provider_ = provider; |
282 } | 284 } |
283 | 285 |
284 // Returns the name of the interface this network is associated wtih. | 286 // Returns the name of the interface this network is associated wtih. |
285 const std::string& name() const { return name_; } | 287 const std::string& name() const { return name_; } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 void set_ignored(bool ignored) { ignored_ = ignored; } | 345 void set_ignored(bool ignored) { ignored_ = ignored; } |
344 | 346 |
345 AdapterType type() const { return type_; } | 347 AdapterType type() const { return type_; } |
346 int preference() const { return preference_; } | 348 int preference() const { return preference_; } |
347 void set_preference(int preference) { preference_ = preference; } | 349 void set_preference(int preference) { preference_ = preference; } |
348 | 350 |
349 // When we enumerate networks and find a previously-seen network is missing, | 351 // When we enumerate networks and find a previously-seen network is missing, |
350 // we do not remove it (because it may be used elsewhere). Instead, we mark | 352 // we do not remove it (because it may be used elsewhere). Instead, we mark |
351 // it inactive, so that we can detect network changes properly. | 353 // it inactive, so that we can detect network changes properly. |
352 bool active() const { return active_; } | 354 bool active() const { return active_; } |
353 void set_active(bool active) { active_ = active; } | 355 void set_active(bool active) { |
| 356 if (active_ == active) { |
| 357 return; |
| 358 } |
| 359 active_ = active; |
| 360 if (!active) { |
| 361 SignalInactive(this); |
| 362 } |
| 363 } |
354 | 364 |
355 // Debugging description of this network | 365 // Debugging description of this network |
356 std::string ToString() const; | 366 std::string ToString() const; |
357 | 367 |
358 private: | 368 private: |
359 const DefaultLocalAddressProvider* default_local_address_provider_ = nullptr; | 369 const DefaultLocalAddressProvider* default_local_address_provider_ = nullptr; |
360 std::string name_; | 370 std::string name_; |
361 std::string description_; | 371 std::string description_; |
362 IPAddress prefix_; | 372 IPAddress prefix_; |
363 int prefix_length_; | 373 int prefix_length_; |
364 std::string key_; | 374 std::string key_; |
365 std::vector<InterfaceAddress> ips_; | 375 std::vector<InterfaceAddress> ips_; |
366 int scope_id_; | 376 int scope_id_; |
367 bool ignored_; | 377 bool ignored_; |
368 AdapterType type_; | 378 AdapterType type_; |
369 int preference_; | 379 int preference_; |
370 bool active_ = true; | 380 bool active_ = true; |
371 | 381 |
372 friend class NetworkManager; | 382 friend class NetworkManager; |
373 }; | 383 }; |
374 | 384 |
375 } // namespace rtc | 385 } // namespace rtc |
376 | 386 |
377 #endif // WEBRTC_BASE_NETWORK_H_ | 387 #endif // WEBRTC_BASE_NETWORK_H_ |
OLD | NEW |