OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "net/base/network_change_notifier_mac.h" | 5 #include "net/base/network_change_notifier_mac.h" |
6 | 6 |
7 #include <SystemConfiguration/SCDynamicStoreKey.h> | 7 #include <SystemConfiguration/SCDynamicStoreKey.h> |
8 #include <SystemConfiguration/SCSchemaDefinitions.h> | 8 #include <SystemConfiguration/SCSchemaDefinitions.h> |
9 | 9 |
| 10 #include "base/mac/scoped_cftyperef.h" |
| 11 |
10 namespace net { | 12 namespace net { |
11 | 13 |
12 NetworkChangeNotifierMac::NetworkChangeNotifierMac() | 14 NetworkChangeNotifierMac::NetworkChangeNotifierMac() |
13 : forwarder_(this), | 15 : forwarder_(this), |
14 config_watcher_(&forwarder_) {} | 16 config_watcher_(&forwarder_) {} |
15 NetworkChangeNotifierMac::~NetworkChangeNotifierMac() {} | 17 NetworkChangeNotifierMac::~NetworkChangeNotifierMac() {} |
16 | 18 |
17 bool NetworkChangeNotifierMac::IsCurrentlyOffline() const { | 19 bool NetworkChangeNotifierMac::IsCurrentlyOffline() const { |
18 // TODO(eroman): http://crbug.com/53473 | 20 // TODO(eroman): http://crbug.com/53473 |
19 return false; | 21 return false; |
20 } | 22 } |
21 | 23 |
22 void NetworkChangeNotifierMac::SetDynamicStoreNotificationKeys( | 24 void NetworkChangeNotifierMac::SetDynamicStoreNotificationKeys( |
23 SCDynamicStoreRef store) { | 25 SCDynamicStoreRef store) { |
24 // Called on notifier thread. | 26 // Called on notifier thread. |
25 scoped_cftyperef<CFMutableArrayRef> notification_keys( | 27 base::mac::ScopedCFTypeRef<CFMutableArrayRef> notification_keys( |
26 CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); | 28 CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); |
27 scoped_cftyperef<CFStringRef> key(SCDynamicStoreKeyCreateNetworkGlobalEntity( | 29 base::mac::ScopedCFTypeRef<CFStringRef> key( |
28 NULL, kSCDynamicStoreDomainState, kSCEntNetInterface)); | 30 SCDynamicStoreKeyCreateNetworkGlobalEntity( |
| 31 NULL, kSCDynamicStoreDomainState, kSCEntNetInterface)); |
29 CFArrayAppendValue(notification_keys.get(), key.get()); | 32 CFArrayAppendValue(notification_keys.get(), key.get()); |
30 key.reset(SCDynamicStoreKeyCreateNetworkGlobalEntity( | 33 key.reset(SCDynamicStoreKeyCreateNetworkGlobalEntity( |
31 NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4)); | 34 NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4)); |
32 CFArrayAppendValue(notification_keys.get(), key.get()); | 35 CFArrayAppendValue(notification_keys.get(), key.get()); |
33 key.reset(SCDynamicStoreKeyCreateNetworkGlobalEntity( | 36 key.reset(SCDynamicStoreKeyCreateNetworkGlobalEntity( |
34 NULL, kSCDynamicStoreDomainState, kSCEntNetIPv6)); | 37 NULL, kSCDynamicStoreDomainState, kSCEntNetIPv6)); |
35 CFArrayAppendValue(notification_keys.get(), key.get()); | 38 CFArrayAppendValue(notification_keys.get(), key.get()); |
36 | 39 |
37 // Set the notification keys. This starts us receiving notifications. | 40 // Set the notification keys. This starts us receiving notifications. |
38 bool ret = SCDynamicStoreSetNotificationKeys( | 41 bool ret = SCDynamicStoreSetNotificationKeys( |
(...skipping 16 matching lines...) Expand all Loading... |
55 if (CFStringHasSuffix(key, kSCEntNetInterface)) { | 58 if (CFStringHasSuffix(key, kSCEntNetInterface)) { |
56 // TODO(willchan): Does not appear to be working. Look into this. | 59 // TODO(willchan): Does not appear to be working. Look into this. |
57 // Perhaps this isn't needed anyway. | 60 // Perhaps this isn't needed anyway. |
58 } else { | 61 } else { |
59 NOTREACHED(); | 62 NOTREACHED(); |
60 } | 63 } |
61 } | 64 } |
62 } | 65 } |
63 | 66 |
64 } // namespace net | 67 } // namespace net |
OLD | NEW |