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 #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/bind.h" | 10 #include "base/bind.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/mac/foundation_util.h" | 12 #include "base/mac/foundation_util.h" |
13 #include "base/mac/scoped_cftyperef.h" | 13 #include "base/mac/scoped_cftyperef.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
17 #include "net/proxy/proxy_config.h" | 17 #include "net/proxy/proxy_config.h" |
18 #include "net/proxy/proxy_info.h" | 18 #include "net/proxy/proxy_info.h" |
19 #include "net/proxy/proxy_server.h" | 19 #include "net/proxy/proxy_server.h" |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 const int kPollIntervalSec = 5; | |
26 | |
27 // Utility function to pull out a boolean value from a dictionary and return it, | 25 // Utility function to pull out a boolean value from a dictionary and return it, |
28 // returning a default value if the key is not present. | 26 // returning a default value if the key is not present. |
29 bool GetBoolFromDictionary(CFDictionaryRef dict, | 27 bool GetBoolFromDictionary(CFDictionaryRef dict, |
30 CFStringRef key, | 28 CFStringRef key, |
31 bool default_value) { | 29 bool default_value) { |
32 CFNumberRef number = base::mac::GetValueFromDictionary<CFNumberRef>(dict, | 30 CFNumberRef number = base::mac::GetValueFromDictionary<CFNumberRef>(dict, |
33 key); | 31 key); |
34 if (!number) | 32 if (!number) |
35 return default_value; | 33 return default_value; |
36 | 34 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // Keep track of the last value we have seen. | 275 // Keep track of the last value we have seen. |
278 has_fetched_config_ = true; | 276 has_fetched_config_ = true; |
279 last_config_fetched_ = new_config; | 277 last_config_fetched_ = new_config; |
280 | 278 |
281 // Notify all the observers. | 279 // Notify all the observers. |
282 FOR_EACH_OBSERVER(Observer, observers_, | 280 FOR_EACH_OBSERVER(Observer, observers_, |
283 OnProxyConfigChanged(new_config, CONFIG_VALID)); | 281 OnProxyConfigChanged(new_config, CONFIG_VALID)); |
284 } | 282 } |
285 | 283 |
286 } // namespace net | 284 } // namespace net |
OLD | NEW |