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...) Expand 10 before | Expand all | Expand 10 after 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 // This class can be constructed on any thread, but every other method | |
68 // (including the destructor) should be called on the same thread. | |
pthatcher1
2016/06/23 23:41:35
Now it sounds like it should be on the same thread
Taylor Brandstetter
2016/06/24 00:43:07
Given the word "but" and the sentence below I thin
| |
69 // This allows constructing a NetworkManager subclass on one thread and | |
70 // passing it into an object that uses it on a different thread. | |
66 class NetworkManager : public DefaultLocalAddressProvider { | 71 class NetworkManager : public DefaultLocalAddressProvider { |
67 public: | 72 public: |
68 typedef std::vector<Network*> NetworkList; | 73 typedef std::vector<Network*> NetworkList; |
69 | 74 |
70 // This enum indicates whether adapter enumeration is allowed. | 75 // This enum indicates whether adapter enumeration is allowed. |
71 enum EnumerationPermission { | 76 enum EnumerationPermission { |
72 ENUMERATION_ALLOWED, // Adapter enumeration is allowed. Getting 0 network | 77 ENUMERATION_ALLOWED, // Adapter enumeration is allowed. Getting 0 network |
73 // from GetNetworks means that there is no network | 78 // from GetNetworks means that there is no network |
74 // available. | 79 // available. |
75 ENUMERATION_BLOCKED, // Adapter enumeration is disabled. | 80 ENUMERATION_BLOCKED, // Adapter enumeration is disabled. |
76 // GetAnyAddressNetworks() should be used instead. | 81 // GetAnyAddressNetworks() should be used instead. |
77 }; | 82 }; |
78 | 83 |
79 NetworkManager(); | 84 NetworkManager(); |
80 ~NetworkManager() override; | 85 ~NetworkManager() override; |
81 | 86 |
82 // Called when network list is updated. | 87 // Called when network list is updated. |
83 sigslot::signal0<> SignalNetworksChanged; | 88 sigslot::signal0<> SignalNetworksChanged; |
84 | 89 |
85 // Indicates a failure when getting list of network interfaces. | 90 // Indicates a failure when getting list of network interfaces. |
86 sigslot::signal0<> SignalError; | 91 sigslot::signal0<> SignalError; |
87 | 92 |
93 // This should be called on the NetworkManager's thread before the | |
94 // NetworkManager is used. Subclasses may override this if necessary. | |
95 virtual void Initialize() {} | |
96 | |
88 // Start/Stop monitoring of network interfaces | 97 // Start/Stop monitoring of network interfaces |
89 // list. SignalNetworksChanged or SignalError is emitted immediately | 98 // list. SignalNetworksChanged or SignalError is emitted immediately |
90 // after StartUpdating() is called. After that SignalNetworksChanged | 99 // after StartUpdating() is called. After that SignalNetworksChanged |
91 // is emitted whenever list of networks changes. | 100 // is emitted whenever list of networks changes. |
92 virtual void StartUpdating() = 0; | 101 virtual void StartUpdating() = 0; |
93 virtual void StopUpdating() = 0; | 102 virtual void StopUpdating() = 0; |
94 | 103 |
95 // Returns the current list of networks available on this machine. | 104 // Returns the current list of networks available on this machine. |
96 // StartUpdating() must be called before this method is called. | 105 // StartUpdating() must be called before this method is called. |
97 // It makes sure that repeated calls return the same object for a | 106 // It makes sure that repeated calls return the same object for a |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 int preference_; | 422 int preference_; |
414 bool active_ = true; | 423 bool active_ = true; |
415 uint16_t id_ = 0; | 424 uint16_t id_ = 0; |
416 | 425 |
417 friend class NetworkManager; | 426 friend class NetworkManager; |
418 }; | 427 }; |
419 | 428 |
420 } // namespace rtc | 429 } // namespace rtc |
421 | 430 |
422 #endif // WEBRTC_BASE_NETWORK_H_ | 431 #endif // WEBRTC_BASE_NETWORK_H_ |
OLD | NEW |