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

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.
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;
81 90
91 // return the current permission state of GetNetworks()
92 virtual NetworkPermissionState network_permission_state() const = 0;
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 return network_permission_state_;
130 }
131
116 protected: 132 protected:
117 typedef std::map<std::string, Network*> NetworkMap; 133 typedef std::map<std::string, Network*> NetworkMap;
118 // Updates |networks_| with the networks listed in |list|. If 134 // Updates |networks_| with the networks listed in |list|. If
119 // |network_map_| already has a Network object for a network listed 135 // |network_map_| already has a Network object for a network listed
120 // in the |list| then it is reused. Accept ownership of the Network 136 // 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 137 // objects in the |list|. |changed| will be set to true if there is
122 // any change in the network list. 138 // any change in the network list.
123 void MergeNetworkList(const NetworkList& list, bool* changed); 139 void MergeNetworkList(const NetworkList& list, bool* changed);
124 140
125 // |stats| will be populated even if |*changed| is false. 141 // |stats| will be populated even if |*changed| is false.
126 void MergeNetworkList(const NetworkList& list, 142 void MergeNetworkList(const NetworkList& list,
127 bool* changed, 143 bool* changed,
128 NetworkManager::Stats* stats); 144 NetworkManager::Stats* stats);
129 145
146 void set_network_permission_state(NetworkPermissionState state) {
147 network_permission_state_ = state;
148 }
149
130 private: 150 private:
131 friend class NetworkTest; 151 friend class NetworkTest;
132 void DoUpdateNetworks(); 152 void DoUpdateNetworks();
133 153
154 NetworkPermissionState network_permission_state_;
155
134 NetworkList networks_; 156 NetworkList networks_;
135 int max_ipv6_networks_; 157 int max_ipv6_networks_;
136 158
137 NetworkMap networks_map_; 159 NetworkMap networks_map_;
138 bool ipv6_enabled_; 160 bool ipv6_enabled_;
139 161
140 rtc::scoped_ptr<rtc::Network> ipv4_any_address_network_; 162 rtc::scoped_ptr<rtc::Network> ipv4_any_address_network_;
141 rtc::scoped_ptr<rtc::Network> ipv6_any_address_network_; 163 rtc::scoped_ptr<rtc::Network> ipv6_any_address_network_;
142 }; 164 };
143 165
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 bool ignored_; 323 bool ignored_;
302 AdapterType type_; 324 AdapterType type_;
303 int preference_; 325 int preference_;
304 326
305 friend class NetworkManager; 327 friend class NetworkManager;
306 }; 328 };
307 329
308 } // namespace rtc 330 } // namespace rtc
309 331
310 #endif // WEBRTC_BASE_NETWORK_H_ 332 #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