 Chromium Code Reviews
 Chromium Code Reviews Issue 1284113003:
  Move the concept of multiple route into Network  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc@master
    
  
    Issue 1284113003:
  Move the concept of multiple route into Network  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc@master| Index: webrtc/base/network.h | 
| diff --git a/webrtc/base/network.h b/webrtc/base/network.h | 
| index 8e5c8f0fb70e196acb1bab84321f1aa63812bf96..825b6d47535bb4a4c060c1a4f8d69b10fbc4566a 100644 | 
| --- a/webrtc/base/network.h | 
| +++ b/webrtc/base/network.h | 
| @@ -56,6 +56,15 @@ class NetworkManager { | 
| public: | 
| typedef std::vector<Network*> NetworkList; | 
| + // This enum indicates the state of GetNetworks. | 
| + enum NetworkPermissionState { | 
| + STATE_UNKNOWN, // SignalNetworksChanged is not fired yet. | 
| + STATE_ALLOWED, // Adapter enumeration is allowed. Getting 0 network from | 
| + // GetNetworks means that there is no network available. | 
| + STATE_BLOCKED // Adapter enumeration is disabled. GetAnyAddressNetworks() | 
| + // 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
 | 
| + }; | 
| + | 
| NetworkManager(); | 
| virtual ~NetworkManager(); | 
| @@ -73,12 +82,15 @@ class NetworkManager { | 
| virtual void StopUpdating() = 0; | 
| // Returns the current list of networks available on this machine. | 
| - // UpdateNetworks() must be called before this method is called. | 
| + // StartUpdating() must be called before this method is called. | 
| // It makes sure that repeated calls return the same object for a | 
| // given network, so that quality is tracked appropriately. Does not | 
| // include ignored networks. | 
| virtual void GetNetworks(NetworkList* networks) const = 0; | 
| 
pthatcher1
2015/08/18 18:34:20
We might consider calling this EnumerateNetworks.
 | 
| + // return the current permission state of GetNetworks() | 
| + virtual NetworkPermissionState network_permission_state() const = 0; | 
| 
pthatcher1
2015/08/18 18:34:19
enumeration_permission() would work well here as a
 | 
| + | 
| // "AnyAddressNetwork" is a network which only contains single "any address" | 
| // IP address. (i.e. INADDR_ANY for IPv4 or in6addr_any for IPv6). This is | 
| // useful as binding to such interfaces allow default routing behavior like | 
| @@ -113,6 +125,8 @@ class NetworkManagerBase : public NetworkManager { | 
| void set_max_ipv6_networks(int networks) { max_ipv6_networks_ = networks; } | 
| int max_ipv6_networks() { return max_ipv6_networks_; } | 
| + NetworkPermissionState network_permission_state() const override; | 
| + | 
| protected: | 
| typedef std::map<std::string, Network*> NetworkMap; | 
| // Updates |networks_| with the networks listed in |list|. If | 
| @@ -127,10 +141,16 @@ class NetworkManagerBase : public NetworkManager { | 
| bool* changed, | 
| NetworkManager::Stats* stats); | 
| + void set_network_permission_state(NetworkPermissionState state) { | 
| + network_permission_state_ = state; | 
| + } | 
| + | 
| private: | 
| friend class NetworkTest; | 
| void DoUpdateNetworks(); | 
| + NetworkPermissionState network_permission_state_; | 
| + | 
| NetworkList networks_; | 
| int max_ipv6_networks_; |