Chromium Code Reviews| 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 | 7 |
| 8 #include <SystemConfiguration/SystemConfiguration.h> | 8 #include <SystemConfiguration/SystemConfiguration.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 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/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | |
| 15 #include "base/synchronization/condition_variable.h" | 16 #include "base/synchronization/condition_variable.h" |
| 16 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.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(); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 51 // Methods directly called by the NetworkConfigWatcherMac::Delegate: | 52 // Methods directly called by the NetworkConfigWatcherMac::Delegate: |
| 52 void StartReachabilityNotifications(); | 53 void StartReachabilityNotifications(); |
| 53 void SetDynamicStoreNotificationKeys(SCDynamicStoreRef store); | 54 void SetDynamicStoreNotificationKeys(SCDynamicStoreRef store); |
| 54 void OnNetworkConfigChange(CFArrayRef changed_keys); | 55 void OnNetworkConfigChange(CFArrayRef changed_keys); |
| 55 | 56 |
| 56 void SetInitialConnectionType(); | 57 void SetInitialConnectionType(); |
| 57 | 58 |
| 58 static void ReachabilityCallback(SCNetworkReachabilityRef target, | 59 static void ReachabilityCallback(SCNetworkReachabilityRef target, |
| 59 SCNetworkConnectionFlags flags, | 60 SCNetworkConnectionFlags flags, |
| 60 void* notifier); | 61 void* notifier); |
| 62 void ReachabilityCallbackImpl(ConnectionType new_type); | |
|
pauljensen
2017/05/23 15:10:30
can you add a comment for this function?
jkarlin
2017/05/27 01:06:19
No longer needed.
| |
| 61 | 63 |
| 62 static NetworkChangeCalculatorParams NetworkChangeCalculatorParamsMac(); | 64 static NetworkChangeCalculatorParams NetworkChangeCalculatorParamsMac(); |
| 65 static ConnectionType CalculateConnectionType(SCNetworkConnectionFlags flags); | |
|
pauljensen
2017/05/23 15:10:30
ditto
jkarlin
2017/05/27 01:06:19
No longer needed.
| |
| 63 | 66 |
| 64 // These must be constructed before config_watcher_ to ensure | 67 // These must be constructed before config_watcher_ to ensure |
| 65 // the lock is in a valid state when Forwarder::Init is called. | 68 // the lock is in a valid state when Forwarder::Init is called. |
| 66 ConnectionType connection_type_; | 69 ConnectionType connection_type_; |
| 67 bool connection_type_initialized_; | 70 bool connection_type_initialized_; |
| 68 mutable base::Lock connection_type_lock_; | 71 mutable base::Lock connection_type_lock_; |
| 69 mutable base::ConditionVariable initial_connection_type_cv_; | 72 mutable base::ConditionVariable initial_connection_type_cv_; |
| 70 base::ScopedCFTypeRef<SCNetworkReachabilityRef> reachability_; | 73 base::ScopedCFTypeRef<SCNetworkReachabilityRef> reachability_; |
| 71 base::ScopedCFTypeRef<CFRunLoopRef> run_loop_; | 74 base::ScopedCFTypeRef<CFRunLoopRef> run_loop_; |
| 72 | 75 |
| 73 Forwarder forwarder_; | 76 Forwarder forwarder_; |
| 74 std::unique_ptr<const NetworkConfigWatcherMac> config_watcher_; | 77 std::unique_ptr<const NetworkConfigWatcherMac> config_watcher_; |
| 75 | 78 |
| 76 std::unique_ptr<DnsConfigServiceThread> dns_config_service_thread_; | 79 std::unique_ptr<DnsConfigServiceThread> dns_config_service_thread_; |
| 77 | 80 |
| 81 base::WeakPtrFactory<NetworkChangeNotifierMac> weak_ptr_factory_; | |
| 82 | |
| 78 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierMac); | 83 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierMac); |
| 79 }; | 84 }; |
| 80 | 85 |
| 81 } // namespace net | 86 } // namespace net |
| 82 | 87 |
| 83 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_ | 88 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_ |
| OLD | NEW |