OLD | NEW |
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 17 matching lines...) Expand all Loading... |
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 // Using the terminology of the Network Information API: | 35 // Using the terminology of the Network Information API: |
36 // http://www.w3.org/TR/netinfo-api. | 36 // http://www.w3.org/TR/netinfo-api. |
37 enum ConnectionType { | 37 enum ConnectionType { |
38 CONNECTION_UNKNOWN = 0, // A connection exists, but its type is unknown. | 38 CONNECTION_UNKNOWN = 0, // A connection exists, but its type is unknown. |
| 39 // Also used as a default value. |
39 CONNECTION_ETHERNET = 1, | 40 CONNECTION_ETHERNET = 1, |
40 CONNECTION_WIFI = 2, | 41 CONNECTION_WIFI = 2, |
41 CONNECTION_2G = 3, | 42 CONNECTION_2G = 3, |
42 CONNECTION_3G = 4, | 43 CONNECTION_3G = 4, |
43 CONNECTION_4G = 5, | 44 CONNECTION_4G = 5, |
44 CONNECTION_NONE = 6 // No connection. | 45 CONNECTION_NONE = 6, // No connection. |
| 46 CONNECTION_LAST = CONNECTION_NONE |
45 }; | 47 }; |
46 | 48 |
47 class NET_EXPORT IPAddressObserver { | 49 class NET_EXPORT IPAddressObserver { |
48 public: | 50 public: |
49 // Will be called when the IP address of the primary interface changes. | 51 // Will be called when the IP address of the primary interface changes. |
50 // This includes when the primary interface itself changes. | 52 // This includes when the primary interface itself changes. |
51 virtual void OnIPAddressChanged() = 0; | 53 virtual void OnIPAddressChanged() = 0; |
52 | 54 |
53 protected: | 55 protected: |
54 IPAddressObserver() {} | 56 IPAddressObserver() {} |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 325 |
324 // Computes NetworkChange signal from IPAddress and ConnectionType signals. | 326 // Computes NetworkChange signal from IPAddress and ConnectionType signals. |
325 scoped_ptr<NetworkChangeCalculator> network_change_calculator_; | 327 scoped_ptr<NetworkChangeCalculator> network_change_calculator_; |
326 | 328 |
327 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); | 329 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); |
328 }; | 330 }; |
329 | 331 |
330 } // namespace net | 332 } // namespace net |
331 | 333 |
332 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ | 334 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ |
OLD | NEW |