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

Side by Side Diff: net/base/network_change_notifier.h

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 | « net/base/net_log_source_type_list.h ('k') | net/base/network_change_notifier.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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ 5 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_H_
6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ 6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/observer_list_threadsafe.h" 9 #include "base/observer_list_threadsafe.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 16 matching lines...) Expand all
27 27
28 // NetworkChangeNotifier monitors the system for network changes, and notifies 28 // NetworkChangeNotifier monitors the system for network changes, and notifies
29 // registered observers of those events. Observers may register on any thread, 29 // registered observers of those events. Observers may register on any thread,
30 // and will be called back on the thread from which they registered. 30 // and will be called back on the thread from which they registered.
31 // NetworkChangeNotifiers are threadsafe, though they must be created and 31 // NetworkChangeNotifiers are threadsafe, though they must be created and
32 // destroyed on the same thread. 32 // destroyed on the same thread.
33 class NET_EXPORT NetworkChangeNotifier { 33 class NET_EXPORT NetworkChangeNotifier {
34 public: 34 public:
35 // This is a superset of the connection types in the NetInfo v3 specification: 35 // This is a superset of the connection types in the NetInfo v3 specification:
36 // http://w3c.github.io/netinfo/. 36 // http://w3c.github.io/netinfo/.
37 //
38 // A Java counterpart will be generated for this enum.
39 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net
37 enum ConnectionType { 40 enum ConnectionType {
38 CONNECTION_UNKNOWN = 0, // A connection exists, but its type is unknown. 41 CONNECTION_UNKNOWN = 0, // A connection exists, but its type is unknown.
39 // Also used as a default value. 42 // Also used as a default value.
40 CONNECTION_ETHERNET = 1, 43 CONNECTION_ETHERNET = 1,
41 CONNECTION_WIFI = 2, 44 CONNECTION_WIFI = 2,
42 CONNECTION_2G = 3, 45 CONNECTION_2G = 3,
43 CONNECTION_3G = 4, 46 CONNECTION_3G = 4,
44 CONNECTION_4G = 5, 47 CONNECTION_4G = 5,
45 CONNECTION_NONE = 6, // No connection. 48 CONNECTION_NONE = 6, // No connection.
46 CONNECTION_BLUETOOTH = 7, 49 CONNECTION_BLUETOOTH = 7,
47 CONNECTION_LAST = CONNECTION_BLUETOOTH 50 CONNECTION_LAST = CONNECTION_BLUETOOTH
48 }; 51 };
49 52
53 // This is the NetInfo v3 set of connection technologies as seen in
54 // http://w3c.github.io/netinfo/. This enum is copied in
55 // NetworkChangeNotifier.java so be sure to change both at once.
56 //
57 // A Java counterpart will be generated for this enum.
58 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.net
59 enum ConnectionSubtype {
60 SUBTYPE_GSM = 0,
61 SUBTYPE_IDEN,
62 SUBTYPE_CDMA,
63 SUBTYPE_1XRTT,
64 SUBTYPE_GPRS,
65 SUBTYPE_EDGE,
66 SUBTYPE_UMTS,
67 SUBTYPE_EVDO_REV_0,
68 SUBTYPE_EVDO_REV_A,
69 SUBTYPE_HSPA,
70 SUBTYPE_EVDO_REV_B,
71 SUBTYPE_HSDPA,
72 SUBTYPE_HSUPA,
73 SUBTYPE_EHRPD,
74 SUBTYPE_HSPAP,
75 SUBTYPE_LTE,
76 SUBTYPE_LTE_ADVANCED,
77 SUBTYPE_BLUETOOTH_1_2,
78 SUBTYPE_BLUETOOTH_2_1,
79 SUBTYPE_BLUETOOTH_3_0,
80 SUBTYPE_BLUETOOTH_4_0,
81 SUBTYPE_ETHERNET,
82 SUBTYPE_FAST_ETHERNET,
83 SUBTYPE_GIGABIT_ETHERNET,
84 SUBTYPE_10_GIGABIT_ETHERNET,
85 SUBTYPE_WIFI_B,
86 SUBTYPE_WIFI_G,
87 SUBTYPE_WIFI_N,
88 SUBTYPE_WIFI_AC,
89 SUBTYPE_WIFI_AD,
90 SUBTYPE_UNKNOWN,
91 SUBTYPE_NONE,
92 SUBTYPE_OTHER,
93 SUBTYPE_LAST = SUBTYPE_OTHER
94 };
95
50 class NET_EXPORT IPAddressObserver { 96 class NET_EXPORT IPAddressObserver {
51 public: 97 public:
52 // Will be called when the IP address of the primary interface changes. 98 // Will be called when the IP address of the primary interface changes.
53 // This includes when the primary interface itself changes. 99 // This includes when the primary interface itself changes.
54 virtual void OnIPAddressChanged() = 0; 100 virtual void OnIPAddressChanged() = 0;
55 101
56 protected: 102 protected:
57 IPAddressObserver() {} 103 IPAddressObserver() {}
58 virtual ~IPAddressObserver() {} 104 virtual ~IPAddressObserver() {}
59 105
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // attempt to a particular remote site will be successful. 201 // attempt to a particular remote site will be successful.
156 // The returned value only describes the connection currently used by the 202 // The returned value only describes the connection currently used by the
157 // device, and does not take into account other machines on the network. For 203 // device, and does not take into account other machines on the network. For
158 // example, if the device is connected using Wifi to a 3G gateway to access 204 // example, if the device is connected using Wifi to a 3G gateway to access
159 // the internet, the connection type is CONNECTION_WIFI. 205 // the internet, the connection type is CONNECTION_WIFI.
160 static ConnectionType GetConnectionType(); 206 static ConnectionType GetConnectionType();
161 207
162 // Returns a theoretical upper limit on download bandwidth, potentially based 208 // Returns a theoretical upper limit on download bandwidth, potentially based
163 // on underlying connection type, signal strength, or some other signal. The 209 // on underlying connection type, signal strength, or some other signal. The
164 // default mapping of connection type to maximum bandwidth is provided in the 210 // default mapping of connection type to maximum bandwidth is provided in the
165 // NetInfo spec: http://w3c.github.io/netinfo/. 211 // NetInfo spec: http://w3c.github.io/netinfo/. Host-specific application
212 // permissions may be required, please see host-specific declaration for more
213 // information.
166 static double GetMaxBandwidth(); 214 static double GetMaxBandwidth();
167 215
168 // Retrieve the last read DnsConfig. This could be expensive if the system has 216 // Retrieve the last read DnsConfig. This could be expensive if the system has
169 // a large HOSTS file. 217 // a large HOSTS file.
170 static void GetDnsConfig(DnsConfig* config); 218 static void GetDnsConfig(DnsConfig* config);
171 219
172 #if defined(OS_LINUX) 220 #if defined(OS_LINUX)
173 // Returns the AddressTrackerLinux if present. 221 // Returns the AddressTrackerLinux if present.
174 static const internal::AddressTrackerLinux* GetAddressTracker(); 222 static const internal::AddressTrackerLinux* GetAddressTracker();
175 #endif 223 #endif
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 // TODO(szym): Retrieve AddressMap from NetworkState. http://crbug.com/144212 347 // TODO(szym): Retrieve AddressMap from NetworkState. http://crbug.com/144212
300 virtual const internal::AddressTrackerLinux* 348 virtual const internal::AddressTrackerLinux*
301 GetAddressTrackerInternal() const; 349 GetAddressTrackerInternal() const;
302 #endif 350 #endif
303 351
304 // See the description of NetworkChangeNotifier::GetMaxBandwidth(). 352 // See the description of NetworkChangeNotifier::GetMaxBandwidth().
305 // Implementations must be thread-safe. Implementations must also be 353 // Implementations must be thread-safe. Implementations must also be
306 // cheap as it is called often. 354 // cheap as it is called often.
307 virtual double GetCurrentMaxBandwidth() const; 355 virtual double GetCurrentMaxBandwidth() const;
308 356
357 // Returns a theoretical upper limit on download bandwidth given a connection
358 // subtype. The mapping of connection type to maximum bandwidth is provided in
359 // the NetInfo spec: http://w3c.github.io/netinfo/.
360 static double GetMaxBandwidthForConnectionSubtype(ConnectionSubtype subtype);
361
309 // Broadcasts a notification to all registered observers. Note that this 362 // Broadcasts a notification to all registered observers. Note that this
310 // happens asynchronously, even for observers on the current thread, even in 363 // happens asynchronously, even for observers on the current thread, even in
311 // tests. 364 // tests.
312 static void NotifyObserversOfIPAddressChange(); 365 static void NotifyObserversOfIPAddressChange();
313 static void NotifyObserversOfConnectionTypeChange(); 366 static void NotifyObserversOfConnectionTypeChange();
314 static void NotifyObserversOfDNSChange(); 367 static void NotifyObserversOfDNSChange();
315 static void NotifyObserversOfNetworkChange(ConnectionType type); 368 static void NotifyObserversOfNetworkChange(ConnectionType type);
316 369
317 // Stores |config| in NetworkState and notifies observers. 370 // Stores |config| in NetworkState and notifies observers.
318 static void SetDnsConfig(const DnsConfig& config); 371 static void SetDnsConfig(const DnsConfig& config);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 404
352 // Set true to disable non-test notifications (to prevent flakes in tests). 405 // Set true to disable non-test notifications (to prevent flakes in tests).
353 bool test_notifications_only_; 406 bool test_notifications_only_;
354 407
355 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); 408 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier);
356 }; 409 };
357 410
358 } // namespace net 411 } // namespace net
359 412
360 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ 413 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_
OLDNEW
« no previous file with comments | « net/base/net_log_source_type_list.h ('k') | net/base/network_change_notifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698