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_config_watcher_mac.h" | 5 #include "net/base/network_config_watcher_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 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/thread.h" | 11 #include "base/thread.h" |
| 12 #include "base/mac/scoped_cftyperef.h" |
12 | 13 |
13 // We only post tasks to a child thread we own, so we don't need refcounting. | 14 // We only post tasks to a child thread we own, so we don't need refcounting. |
14 DISABLE_RUNNABLE_METHOD_REFCOUNT(net::NetworkConfigWatcherMac); | 15 DISABLE_RUNNABLE_METHOD_REFCOUNT(net::NetworkConfigWatcherMac); |
15 | 16 |
16 namespace net { | 17 namespace net { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 // Called back by OS. Calls OnNetworkConfigChange(). | 21 // Called back by OS. Calls OnNetworkConfigChange(). |
21 void DynamicStoreCallback(SCDynamicStoreRef /* store */, | 22 void DynamicStoreCallback(SCDynamicStoreRef /* store */, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 DCHECK_EQ(notifier_thread_->message_loop(), MessageLoop::current()); | 70 DCHECK_EQ(notifier_thread_->message_loop(), MessageLoop::current()); |
70 | 71 |
71 // Add a run loop source for a dynamic store to the current run loop. | 72 // Add a run loop source for a dynamic store to the current run loop. |
72 SCDynamicStoreContext context = { | 73 SCDynamicStoreContext context = { |
73 0, // Version 0. | 74 0, // Version 0. |
74 delegate_, // User data. | 75 delegate_, // User data. |
75 NULL, // This is not reference counted. No retain function. | 76 NULL, // This is not reference counted. No retain function. |
76 NULL, // This is not reference counted. No release function. | 77 NULL, // This is not reference counted. No release function. |
77 NULL, // No description for this. | 78 NULL, // No description for this. |
78 }; | 79 }; |
79 scoped_cftyperef<SCDynamicStoreRef> store(SCDynamicStoreCreate( | 80 base::mac::ScopedCFTypeRef<SCDynamicStoreRef> store(SCDynamicStoreCreate( |
80 NULL, CFSTR("org.chromium"), DynamicStoreCallback, &context)); | 81 NULL, CFSTR("org.chromium"), DynamicStoreCallback, &context)); |
81 run_loop_source_.reset(SCDynamicStoreCreateRunLoopSource( | 82 run_loop_source_.reset(SCDynamicStoreCreateRunLoopSource( |
82 NULL, store.get(), 0)); | 83 NULL, store.get(), 0)); |
83 CFRunLoopAddSource(CFRunLoopGetCurrent(), run_loop_source_.get(), | 84 CFRunLoopAddSource(CFRunLoopGetCurrent(), run_loop_source_.get(), |
84 kCFRunLoopCommonModes); | 85 kCFRunLoopCommonModes); |
85 | 86 |
86 // Set up notifications for interface and IP address changes. | 87 // Set up notifications for interface and IP address changes. |
87 delegate_->SetDynamicStoreNotificationKeys(store.get()); | 88 delegate_->SetDynamicStoreNotificationKeys(store.get()); |
88 | 89 |
89 MessageLoop::current()->AddDestructionObserver(this); | 90 MessageLoop::current()->AddDestructionObserver(this); |
90 } | 91 } |
91 | 92 |
92 } // namespace net | 93 } // namespace net |
OLD | NEW |