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

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: Merge from master and address Justin's comments. 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') | no next file with comments »
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 NetworkPermissionState network_permission_state() const {
93 return network_permission_state_;
94 }
95
82 // "AnyAddressNetwork" is a network which only contains single "any address" 96 // "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 97 // 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 98 // useful as binding to such interfaces allow default routing behavior like
85 // http traffic. 99 // http traffic.
86 // TODO(guoweis): remove this body when chromium implements this. 100 // TODO(guoweis): remove this body when chromium implements this.
87 virtual void GetAnyAddressNetworks(NetworkList* networks) {} 101 virtual void GetAnyAddressNetworks(NetworkList* networks) {}
88 102
89 // Dumps a list of networks available to LS_INFO. 103 // Dumps a list of networks available to LS_INFO.
90 virtual void DumpNetworks(bool include_ignored) {} 104 virtual void DumpNetworks(bool include_ignored) {}
91 105
92 struct Stats { 106 struct Stats {
93 int ipv4_network_count; 107 int ipv4_network_count;
94 int ipv6_network_count; 108 int ipv6_network_count;
95 Stats() { 109 Stats() {
96 ipv4_network_count = 0; 110 ipv4_network_count = 0;
97 ipv6_network_count = 0; 111 ipv6_network_count = 0;
98 } 112 }
99 }; 113 };
114
115 protected:
juberti1 2015/08/14 20:58:39 Can this go down into NetworkManagerBase? This cla
116 NetworkPermissionState network_permission_state_ = STATE_UNKNOWN;
100 }; 117 };
101 118
102 // Base class for NetworkManager implementations. 119 // Base class for NetworkManager implementations.
103 class NetworkManagerBase : public NetworkManager { 120 class NetworkManagerBase : public NetworkManager {
104 public: 121 public:
105 NetworkManagerBase(); 122 NetworkManagerBase();
106 ~NetworkManagerBase() override; 123 ~NetworkManagerBase() override;
107 124
108 void GetNetworks(std::vector<Network*>* networks) const override; 125 void GetNetworks(std::vector<Network*>* networks) const override;
109 void GetAnyAddressNetworks(NetworkList* networks) override; 126 void GetAnyAddressNetworks(NetworkList* networks) override;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 bool ignored_; 318 bool ignored_;
302 AdapterType type_; 319 AdapterType type_;
303 int preference_; 320 int preference_;
304 321
305 friend class NetworkManager; 322 friend class NetworkManager;
306 }; 323 };
307 324
308 } // namespace rtc 325 } // namespace rtc
309 326
310 #endif // WEBRTC_BASE_NETWORK_H_ 327 #endif // WEBRTC_BASE_NETWORK_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/network.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698