Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: webrtc/base/network.h

Issue 1284113003: Move the concept of multiple route into Network (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/base/network.cc » ('j') | webrtc/base/network.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // length of that prefix. 49 // length of that prefix.
50 std::string MakeNetworkKey(const std::string& name, const IPAddress& prefix, 50 std::string MakeNetworkKey(const std::string& name, const IPAddress& prefix,
51 int prefix_length); 51 int prefix_length);
52 52
53 // Generic network manager interface. It provides list of local 53 // Generic network manager interface. It provides list of local
54 // networks. 54 // networks.
55 class NetworkManager { 55 class NetworkManager {
56 public: 56 public:
57 typedef std::vector<Network*> NetworkList; 57 typedef std::vector<Network*> NetworkList;
58 58
59 // This enum indicates the state of GetNetworks.
60 enum NetworkPermissionState {
61 STATE_UNKNOWN, // SignalNetworksChanged is not fired yet.
62 STATE_ALLOWED, // Adapter enumeration is allowed. Getting 0 network from
63 // GetNetworks means that there is no network available.
64 STATE_BLOCKED // Adapter enumeration is disabled. GetAnyAddressNetworks()
65 // should be used instead.
pthatcher1 2015/08/18 18:34:19 I think a better name might be: enum EnumerationP
juberti1 2015/08/20 06:31:04 Peter, we (and Chrome) use old-style enum macros e
pthatcher1 2015/08/20 06:43:37 We switched back to old-style enums? I wasn't awa
66 };
67
59 NetworkManager(); 68 NetworkManager();
60 virtual ~NetworkManager(); 69 virtual ~NetworkManager();
61 70
62 // Called when network list is updated. 71 // Called when network list is updated.
63 sigslot::signal0<> SignalNetworksChanged; 72 sigslot::signal0<> SignalNetworksChanged;
64 73
65 // Indicates a failure when getting list of network interfaces. 74 // Indicates a failure when getting list of network interfaces.
66 sigslot::signal0<> SignalError; 75 sigslot::signal0<> SignalError;
67 76
68 // Start/Stop monitoring of network interfaces 77 // Start/Stop monitoring of network interfaces
69 // list. SignalNetworksChanged or SignalError is emitted immediately 78 // list. SignalNetworksChanged or SignalError is emitted immediately
70 // after StartUpdating() is called. After that SignalNetworksChanged 79 // after StartUpdating() is called. After that SignalNetworksChanged
71 // is emitted whenever list of networks changes. 80 // is emitted whenever list of networks changes.
72 virtual void StartUpdating() = 0; 81 virtual void StartUpdating() = 0;
73 virtual void StopUpdating() = 0; 82 virtual void StopUpdating() = 0;
74 83
75 // Returns the current list of networks available on this machine. 84 // Returns the current list of networks available on this machine.
76 // UpdateNetworks() must be called before this method is called. 85 // StartUpdating() must be called before this method is called.
77 // It makes sure that repeated calls return the same object for a 86 // It makes sure that repeated calls return the same object for a
78 // given network, so that quality is tracked appropriately. Does not 87 // given network, so that quality is tracked appropriately. Does not
79 // include ignored networks. 88 // include ignored networks.
80 virtual void GetNetworks(NetworkList* networks) const = 0; 89 virtual void GetNetworks(NetworkList* networks) const = 0;
pthatcher1 2015/08/18 18:34:20 We might consider calling this EnumerateNetworks.
81 90
91 // return the current permission state of GetNetworks()
92 virtual NetworkPermissionState network_permission_state() const = 0;
pthatcher1 2015/08/18 18:34:19 enumeration_permission() would work well here as a
93
82 // "AnyAddressNetwork" is a network which only contains single "any address" 94 // "AnyAddressNetwork" is a network which only contains single "any address"
83 // IP address. (i.e. INADDR_ANY for IPv4 or in6addr_any for IPv6). This is 95 // IP address. (i.e. INADDR_ANY for IPv4 or in6addr_any for IPv6). This is
84 // useful as binding to such interfaces allow default routing behavior like 96 // useful as binding to such interfaces allow default routing behavior like
85 // http traffic. 97 // http traffic.
86 // TODO(guoweis): remove this body when chromium implements this. 98 // TODO(guoweis): remove this body when chromium implements this.
87 virtual void GetAnyAddressNetworks(NetworkList* networks) {} 99 virtual void GetAnyAddressNetworks(NetworkList* networks) {}
88 100
89 // Dumps a list of networks available to LS_INFO. 101 // Dumps a list of networks available to LS_INFO.
90 virtual void DumpNetworks(bool include_ignored) {} 102 virtual void DumpNetworks(bool include_ignored) {}
91 103
(...skipping 14 matching lines...) Expand all
106 ~NetworkManagerBase() override; 118 ~NetworkManagerBase() override;
107 119
108 void GetNetworks(std::vector<Network*>* networks) const override; 120 void GetNetworks(std::vector<Network*>* networks) const override;
109 void GetAnyAddressNetworks(NetworkList* networks) override; 121 void GetAnyAddressNetworks(NetworkList* networks) override;
110 bool ipv6_enabled() const { return ipv6_enabled_; } 122 bool ipv6_enabled() const { return ipv6_enabled_; }
111 void set_ipv6_enabled(bool enabled) { ipv6_enabled_ = enabled; } 123 void set_ipv6_enabled(bool enabled) { ipv6_enabled_ = enabled; }
112 124
113 void set_max_ipv6_networks(int networks) { max_ipv6_networks_ = networks; } 125 void set_max_ipv6_networks(int networks) { max_ipv6_networks_ = networks; }
114 int max_ipv6_networks() { return max_ipv6_networks_; } 126 int max_ipv6_networks() { return max_ipv6_networks_; }
115 127
128 NetworkPermissionState network_permission_state() const override;
129
116 protected: 130 protected:
117 typedef std::map<std::string, Network*> NetworkMap; 131 typedef std::map<std::string, Network*> NetworkMap;
118 // Updates |networks_| with the networks listed in |list|. If 132 // Updates |networks_| with the networks listed in |list|. If
119 // |network_map_| already has a Network object for a network listed 133 // |network_map_| already has a Network object for a network listed
120 // in the |list| then it is reused. Accept ownership of the Network 134 // in the |list| then it is reused. Accept ownership of the Network
121 // objects in the |list|. |changed| will be set to true if there is 135 // objects in the |list|. |changed| will be set to true if there is
122 // any change in the network list. 136 // any change in the network list.
123 void MergeNetworkList(const NetworkList& list, bool* changed); 137 void MergeNetworkList(const NetworkList& list, bool* changed);
124 138
125 // |stats| will be populated even if |*changed| is false. 139 // |stats| will be populated even if |*changed| is false.
126 void MergeNetworkList(const NetworkList& list, 140 void MergeNetworkList(const NetworkList& list,
127 bool* changed, 141 bool* changed,
128 NetworkManager::Stats* stats); 142 NetworkManager::Stats* stats);
129 143
144 void set_network_permission_state(NetworkPermissionState state) {
145 network_permission_state_ = state;
146 }
147
130 private: 148 private:
131 friend class NetworkTest; 149 friend class NetworkTest;
132 void DoUpdateNetworks(); 150 void DoUpdateNetworks();
133 151
152 NetworkPermissionState network_permission_state_;
153
134 NetworkList networks_; 154 NetworkList networks_;
135 int max_ipv6_networks_; 155 int max_ipv6_networks_;
136 156
137 NetworkMap networks_map_; 157 NetworkMap networks_map_;
138 bool ipv6_enabled_; 158 bool ipv6_enabled_;
139 159
140 rtc::scoped_ptr<rtc::Network> ipv4_any_address_network_; 160 rtc::scoped_ptr<rtc::Network> ipv4_any_address_network_;
141 rtc::scoped_ptr<rtc::Network> ipv6_any_address_network_; 161 rtc::scoped_ptr<rtc::Network> ipv6_any_address_network_;
142 }; 162 };
143 163
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 bool ignored_; 321 bool ignored_;
302 AdapterType type_; 322 AdapterType type_;
303 int preference_; 323 int preference_;
304 324
305 friend class NetworkManager; 325 friend class NetworkManager;
306 }; 326 };
307 327
308 } // namespace rtc 328 } // namespace rtc
309 329
310 #endif // WEBRTC_BASE_NETWORK_H_ 330 #endif // WEBRTC_BASE_NETWORK_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/network.cc » ('j') | webrtc/base/network.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698