Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: net/proxy/proxy_config_service_mac.cc

Issue 6597070: Allow ProxyConfigService to report "no configuration set" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Eric's comments. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/proxy/proxy_config_service_mac.h ('k') | net/proxy/proxy_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 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 #include "net/proxy/proxy_config_service_mac.h" 5 #include "net/proxy/proxy_config_service_mac.h"
6 6
7 #include <CoreFoundation/CoreFoundation.h> 7 #include <CoreFoundation/CoreFoundation.h>
8 #include <SystemConfiguration/SystemConfiguration.h> 8 #include <SystemConfiguration/SystemConfiguration.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/mac/mac_util.h" 11 #include "base/mac/mac_util.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 void ProxyConfigServiceMac::AddObserver(Observer* observer) { 203 void ProxyConfigServiceMac::AddObserver(Observer* observer) {
204 DCHECK_EQ(io_loop_, MessageLoop::current()); 204 DCHECK_EQ(io_loop_, MessageLoop::current());
205 observers_.AddObserver(observer); 205 observers_.AddObserver(observer);
206 } 206 }
207 207
208 void ProxyConfigServiceMac::RemoveObserver(Observer* observer) { 208 void ProxyConfigServiceMac::RemoveObserver(Observer* observer) {
209 DCHECK_EQ(io_loop_, MessageLoop::current()); 209 DCHECK_EQ(io_loop_, MessageLoop::current());
210 observers_.RemoveObserver(observer); 210 observers_.RemoveObserver(observer);
211 } 211 }
212 212
213 bool ProxyConfigServiceMac::GetLatestProxyConfig(ProxyConfig* config) { 213 net::ProxyConfigService::ConfigAvailability
214 ProxyConfigServiceMac::GetLatestProxyConfig(ProxyConfig* config) {
214 DCHECK_EQ(io_loop_, MessageLoop::current()); 215 DCHECK_EQ(io_loop_, MessageLoop::current());
215 216
216 // Lazy-initialize by fetching the proxy setting from this thread. 217 // Lazy-initialize by fetching the proxy setting from this thread.
217 if (!has_fetched_config_) { 218 if (!has_fetched_config_) {
218 GetCurrentProxyConfig(&last_config_fetched_); 219 GetCurrentProxyConfig(&last_config_fetched_);
219 has_fetched_config_ = true; 220 has_fetched_config_ = true;
220 } 221 }
221 222
222 *config = last_config_fetched_; 223 *config = last_config_fetched_;
223 return has_fetched_config_; 224 return has_fetched_config_ ? CONFIG_VALID : CONFIG_PENDING;
224 } 225 }
225 226
226 void ProxyConfigServiceMac::SetDynamicStoreNotificationKeys( 227 void ProxyConfigServiceMac::SetDynamicStoreNotificationKeys(
227 SCDynamicStoreRef store) { 228 SCDynamicStoreRef store) {
228 // Called on notifier thread. 229 // Called on notifier thread.
229 230
230 CFStringRef proxies_key = SCDynamicStoreKeyCreateProxies(NULL); 231 CFStringRef proxies_key = SCDynamicStoreKeyCreateProxies(NULL);
231 CFArrayRef key_array = CFArrayCreate( 232 CFArrayRef key_array = CFArrayCreate(
232 NULL, (const void **)(&proxies_key), 1, &kCFTypeArrayCallBacks); 233 NULL, (const void **)(&proxies_key), 1, &kCFTypeArrayCallBacks);
233 234
(...skipping 21 matching lines...) Expand all
255 256
256 void ProxyConfigServiceMac::OnProxyConfigChanged( 257 void ProxyConfigServiceMac::OnProxyConfigChanged(
257 const ProxyConfig& new_config) { 258 const ProxyConfig& new_config) {
258 DCHECK_EQ(io_loop_, MessageLoop::current()); 259 DCHECK_EQ(io_loop_, MessageLoop::current());
259 260
260 // Keep track of the last value we have seen. 261 // Keep track of the last value we have seen.
261 has_fetched_config_ = true; 262 has_fetched_config_ = true;
262 last_config_fetched_ = new_config; 263 last_config_fetched_ = new_config;
263 264
264 // Notify all the observers. 265 // Notify all the observers.
265 FOR_EACH_OBSERVER(Observer, observers_, OnProxyConfigChanged(new_config)); 266 FOR_EACH_OBSERVER(Observer, observers_,
267 OnProxyConfigChanged(new_config, CONFIG_VALID));
266 } 268 }
267 269
268 } // namespace net 270 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_config_service_mac.h ('k') | net/proxy/proxy_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698