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 45 matching lines...) Loading... |
56 public: | 56 public: |
57 virtual ~DefaultLocalAddressProvider() = default; | 57 virtual ~DefaultLocalAddressProvider() = default; |
58 // The default local address is the local address used in multi-homed endpoint | 58 // The default local address is the local address used in multi-homed endpoint |
59 // when the any address (0.0.0.0 or ::) is used as the local address. It's | 59 // when the any address (0.0.0.0 or ::) is used as the local address. It's |
60 // important to check the return value as a IP family may not be enabled. | 60 // important to check the return value as a IP family may not be enabled. |
61 virtual bool GetDefaultLocalAddress(int family, IPAddress* ipaddr) const = 0; | 61 virtual bool GetDefaultLocalAddress(int family, IPAddress* ipaddr) const = 0; |
62 }; | 62 }; |
63 | 63 |
64 // Generic network manager interface. It provides list of local | 64 // Generic network manager interface. It provides list of local |
65 // networks. | 65 // networks. |
66 // | |
67 // Every method of NetworkManager (including the destructor) must be called on | |
68 // the same thread, except for the constructor which may be called on any | |
69 // thread. | |
70 // | |
71 // This allows constructing a NetworkManager subclass on one thread and | |
72 // passing it into an object that uses it on a different thread. | |
73 class NetworkManager : public DefaultLocalAddressProvider { | 66 class NetworkManager : public DefaultLocalAddressProvider { |
74 public: | 67 public: |
75 typedef std::vector<Network*> NetworkList; | 68 typedef std::vector<Network*> NetworkList; |
76 | 69 |
77 // This enum indicates whether adapter enumeration is allowed. | 70 // This enum indicates whether adapter enumeration is allowed. |
78 enum EnumerationPermission { | 71 enum EnumerationPermission { |
79 ENUMERATION_ALLOWED, // Adapter enumeration is allowed. Getting 0 network | 72 ENUMERATION_ALLOWED, // Adapter enumeration is allowed. Getting 0 network |
80 // from GetNetworks means that there is no network | 73 // from GetNetworks means that there is no network |
81 // available. | 74 // available. |
82 ENUMERATION_BLOCKED, // Adapter enumeration is disabled. | 75 ENUMERATION_BLOCKED, // Adapter enumeration is disabled. |
83 // GetAnyAddressNetworks() should be used instead. | 76 // GetAnyAddressNetworks() should be used instead. |
84 }; | 77 }; |
85 | 78 |
86 NetworkManager(); | 79 NetworkManager(); |
87 ~NetworkManager() override; | 80 ~NetworkManager() override; |
88 | 81 |
89 // Called when network list is updated. | 82 // Called when network list is updated. |
90 sigslot::signal0<> SignalNetworksChanged; | 83 sigslot::signal0<> SignalNetworksChanged; |
91 | 84 |
92 // Indicates a failure when getting list of network interfaces. | 85 // Indicates a failure when getting list of network interfaces. |
93 sigslot::signal0<> SignalError; | 86 sigslot::signal0<> SignalError; |
94 | 87 |
95 // This should be called on the NetworkManager's thread before the | |
96 // NetworkManager is used. Subclasses may override this if necessary. | |
97 virtual void Initialize() {} | |
98 | |
99 // Start/Stop monitoring of network interfaces | 88 // Start/Stop monitoring of network interfaces |
100 // list. SignalNetworksChanged or SignalError is emitted immediately | 89 // list. SignalNetworksChanged or SignalError is emitted immediately |
101 // after StartUpdating() is called. After that SignalNetworksChanged | 90 // after StartUpdating() is called. After that SignalNetworksChanged |
102 // is emitted whenever list of networks changes. | 91 // is emitted whenever list of networks changes. |
103 virtual void StartUpdating() = 0; | 92 virtual void StartUpdating() = 0; |
104 virtual void StopUpdating() = 0; | 93 virtual void StopUpdating() = 0; |
105 | 94 |
106 // Returns the current list of networks available on this machine. | 95 // Returns the current list of networks available on this machine. |
107 // StartUpdating() must be called before this method is called. | 96 // StartUpdating() must be called before this method is called. |
108 // It makes sure that repeated calls return the same object for a | 97 // It makes sure that repeated calls return the same object for a |
(...skipping 315 matching lines...) Loading... |
424 int preference_; | 413 int preference_; |
425 bool active_ = true; | 414 bool active_ = true; |
426 uint16_t id_ = 0; | 415 uint16_t id_ = 0; |
427 | 416 |
428 friend class NetworkManager; | 417 friend class NetworkManager; |
429 }; | 418 }; |
430 | 419 |
431 } // namespace rtc | 420 } // namespace rtc |
432 | 421 |
433 #endif // WEBRTC_BASE_NETWORK_H_ | 422 #endif // WEBRTC_BASE_NETWORK_H_ |
OLD | NEW |