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