| 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_MAC_H_ | 5 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_ |
| 6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_ | 6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <SystemConfiguration/SystemConfiguration.h> | 9 #include <SystemConfiguration/SystemConfiguration.h> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/mac/scoped_cftyperef.h" | 13 #include "base/mac/scoped_cftyperef.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/synchronization/condition_variable.h" | 15 #include "base/synchronization/condition_variable.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "net/base/file_path_watcher_callback.h" |
| 17 #include "net/base/network_change_notifier.h" | 18 #include "net/base/network_change_notifier.h" |
| 18 #include "net/base/network_config_watcher_mac.h" | 19 #include "net/base/network_config_watcher_mac.h" |
| 19 | 20 |
| 20 namespace net { | 21 namespace net { |
| 21 | 22 |
| 22 class NetworkChangeNotifierMac: public NetworkChangeNotifier { | 23 class NetworkChangeNotifierMac: public NetworkChangeNotifier { |
| 23 public: | 24 public: |
| 24 NetworkChangeNotifierMac(); | 25 NetworkChangeNotifierMac(); |
| 25 virtual ~NetworkChangeNotifierMac(); | 26 virtual ~NetworkChangeNotifierMac(); |
| 26 | 27 |
| 27 // NetworkChangeNotifier implementation: | 28 // NetworkChangeNotifier: |
| 28 virtual bool IsCurrentlyOffline() const OVERRIDE; | 29 virtual bool IsCurrentlyOffline() const OVERRIDE; |
| 29 | 30 |
| 31 virtual bool IsCurrentlyWatchingDNS() const OVERRIDE; |
| 32 |
| 30 private: | 33 private: |
| 31 enum OnlineState { | 34 enum OnlineState { |
| 32 UNINITIALIZED = -1, | 35 UNINITIALIZED = -1, |
| 33 OFFLINE = 0, | 36 OFFLINE = 0, |
| 34 ONLINE = 1 | 37 ONLINE = 1 |
| 35 }; | 38 }; |
| 36 | 39 |
| 40 class DNSWatcher; |
| 41 |
| 37 // Forwarder just exists to keep the NetworkConfigWatcherMac API out of | 42 // Forwarder just exists to keep the NetworkConfigWatcherMac API out of |
| 38 // NetworkChangeNotifierMac's public API. | 43 // NetworkChangeNotifierMac's public API. |
| 39 class Forwarder : public NetworkConfigWatcherMac::Delegate { | 44 class Forwarder : public NetworkConfigWatcherMac::Delegate { |
| 40 public: | 45 public: |
| 41 explicit Forwarder(NetworkChangeNotifierMac* net_config_watcher) | 46 explicit Forwarder(NetworkChangeNotifierMac* net_config_watcher) |
| 42 : net_config_watcher_(net_config_watcher) {} | 47 : net_config_watcher_(net_config_watcher) {} |
| 43 | 48 |
| 44 // NetworkConfigWatcherMac::Delegate implementation: | 49 // NetworkConfigWatcherMac::Delegate implementation: |
| 45 virtual void Init() OVERRIDE { | 50 virtual void Init() OVERRIDE { |
| 46 net_config_watcher_->SetInitialState(); | 51 net_config_watcher_->SetInitialState(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 76 // the lock is in a valid state when Forwarder::Init is called. | 81 // the lock is in a valid state when Forwarder::Init is called. |
| 77 OnlineState online_state_; | 82 OnlineState online_state_; |
| 78 mutable base::Lock online_state_lock_; | 83 mutable base::Lock online_state_lock_; |
| 79 mutable base::ConditionVariable initial_state_cv_; | 84 mutable base::ConditionVariable initial_state_cv_; |
| 80 base::mac::ScopedCFTypeRef<SCNetworkReachabilityRef> reachability_; | 85 base::mac::ScopedCFTypeRef<SCNetworkReachabilityRef> reachability_; |
| 81 base::mac::ScopedCFTypeRef<CFRunLoopRef> run_loop_; | 86 base::mac::ScopedCFTypeRef<CFRunLoopRef> run_loop_; |
| 82 | 87 |
| 83 Forwarder forwarder_; | 88 Forwarder forwarder_; |
| 84 scoped_ptr<const NetworkConfigWatcherMac> config_watcher_; | 89 scoped_ptr<const NetworkConfigWatcherMac> config_watcher_; |
| 85 | 90 |
| 91 scoped_ptr<DNSWatcher> dns_watcher_; |
| 92 |
| 86 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierMac); | 93 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierMac); |
| 87 }; | 94 }; |
| 88 | 95 |
| 89 } // namespace net | 96 } // namespace net |
| 90 | 97 |
| 91 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_ | 98 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_ |
| OLD | NEW |