| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/observer_list_threadsafe.h" | 10 #include "base/observer_list_threadsafe.h" |
| 11 #include "net/base/net_api.h" | 11 #include "net/base/net_export.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 class NetworkChangeNotifierFactory; | 15 class NetworkChangeNotifierFactory; |
| 16 | 16 |
| 17 // NetworkChangeNotifier monitors the system for network changes, and notifies | 17 // NetworkChangeNotifier monitors the system for network changes, and notifies |
| 18 // registered observers of those events. Observers may register on any thread, | 18 // registered observers of those events. Observers may register on any thread, |
| 19 // and will be called back on the thread from which they registered. | 19 // and will be called back on the thread from which they registered. |
| 20 class NET_API NetworkChangeNotifier { | 20 class NET_EXPORT NetworkChangeNotifier { |
| 21 public: | 21 public: |
| 22 class NET_API IPAddressObserver { | 22 class NET_EXPORT IPAddressObserver { |
| 23 public: | 23 public: |
| 24 virtual ~IPAddressObserver() {} | 24 virtual ~IPAddressObserver() {} |
| 25 | 25 |
| 26 // Will be called when the IP address of the primary interface changes. | 26 // Will be called when the IP address of the primary interface changes. |
| 27 // This includes when the primary interface itself changes. | 27 // This includes when the primary interface itself changes. |
| 28 virtual void OnIPAddressChanged() = 0; | 28 virtual void OnIPAddressChanged() = 0; |
| 29 | 29 |
| 30 protected: | 30 protected: |
| 31 IPAddressObserver() {} | 31 IPAddressObserver() {} |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 DISALLOW_COPY_AND_ASSIGN(IPAddressObserver); | 34 DISALLOW_COPY_AND_ASSIGN(IPAddressObserver); |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 class NET_API OnlineStateObserver { | 37 class NET_EXPORT OnlineStateObserver { |
| 38 public: | 38 public: |
| 39 virtual ~OnlineStateObserver() {} | 39 virtual ~OnlineStateObserver() {} |
| 40 | 40 |
| 41 // Will be called when the online state of the system may have changed. | 41 // Will be called when the online state of the system may have changed. |
| 42 // See NetworkChangeNotifier::IsOffline() for important caveats about | 42 // See NetworkChangeNotifier::IsOffline() for important caveats about |
| 43 // the unreliability of this signal. | 43 // the unreliability of this signal. |
| 44 virtual void OnOnlineStateChanged(bool online) = 0; | 44 virtual void OnOnlineStateChanged(bool online) = 0; |
| 45 | 45 |
| 46 protected: | 46 protected: |
| 47 OnlineStateObserver() {} | 47 OnlineStateObserver() {} |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 ip_address_observer_list_; | 119 ip_address_observer_list_; |
| 120 const scoped_refptr<ObserverListThreadSafe<OnlineStateObserver> > | 120 const scoped_refptr<ObserverListThreadSafe<OnlineStateObserver> > |
| 121 online_state_observer_list_; | 121 online_state_observer_list_; |
| 122 | 122 |
| 123 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); | 123 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 } // namespace net | 126 } // namespace net |
| 127 | 127 |
| 128 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ | 128 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ |
| OLD | NEW |