summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorkushi.p@gmail.com <kushi.p@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-15 21:24:48 +0000
committerkushi.p@gmail.com <kushi.p@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-15 21:24:48 +0000
commit685db3600fcb1c2e55ce1be39814449726752d3c (patch)
tree74dea972a74705ac8ab6592e91cd945cf1cdefa5 /net
parent1cb44aac5589554d1c0d3c966c8657eb612885a6 (diff)
downloadchromium_src-685db3600fcb1c2e55ce1be39814449726752d3c.zip
chromium_src-685db3600fcb1c2e55ce1be39814449726752d3c.tar.gz
chromium_src-685db3600fcb1c2e55ce1be39814449726752d3c.tar.bz2
Convert plain C-style casts to use CFCastStrict and GetValueFromDictionary template.
These updates keep CF casts between CFTypeRef and specific CoreFoundation types consistent across the project. BUG=104200 Review URL: http://codereview.chromium.org/8528013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110173 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/proxy/proxy_config_service_mac.cc24
-rw-r--r--net/proxy/proxy_resolver_mac.cc17
-rw-r--r--net/proxy/proxy_server_mac.cc6
3 files changed, 20 insertions, 27 deletions
diff --git a/net/proxy/proxy_config_service_mac.cc b/net/proxy/proxy_config_service_mac.cc
index 2fd6ee0..d06a833 100644
--- a/net/proxy/proxy_config_service_mac.cc
+++ b/net/proxy/proxy_config_service_mac.cc
@@ -8,6 +8,7 @@
#include <SystemConfiguration/SystemConfiguration.h>
#include "base/logging.h"
+#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/message_loop.h"
@@ -28,8 +29,8 @@ const int kPollIntervalSec = 5;
bool GetBoolFromDictionary(CFDictionaryRef dict,
CFStringRef key,
bool default_value) {
- CFNumberRef number = (CFNumberRef)base::mac::GetValueFromDictionary(
- dict, key, CFNumberGetTypeID());
+ CFNumberRef number = base::mac::GetValueFromDictionary<CFNumberRef>(dict,
+ key);
if (!number)
return default_value;
@@ -60,10 +61,8 @@ void GetCurrentProxyConfig(ProxyConfig* config) {
if (GetBoolFromDictionary(config_dict.get(),
kSCPropNetProxiesProxyAutoConfigEnable,
false)) {
- CFStringRef pac_url_ref = (CFStringRef)base::mac::GetValueFromDictionary(
- config_dict.get(),
- kSCPropNetProxiesProxyAutoConfigURLString,
- CFStringGetTypeID());
+ CFStringRef pac_url_ref = base::mac::GetValueFromDictionary<CFStringRef>(
+ config_dict.get(), kSCPropNetProxiesProxyAutoConfigURLString);
if (pac_url_ref)
config->set_pac_url(GURL(base::SysCFStringRefToUTF8(pac_url_ref)));
}
@@ -129,17 +128,14 @@ void GetCurrentProxyConfig(ProxyConfig* config) {
// proxy bypass list
- CFArrayRef bypass_array_ref =
- (CFArrayRef)base::mac::GetValueFromDictionary(
- config_dict.get(),
- kSCPropNetProxiesExceptionsList,
- CFArrayGetTypeID());
+ CFArrayRef bypass_array_ref = base::mac::GetValueFromDictionary<CFArrayRef>(
+ config_dict.get(), kSCPropNetProxiesExceptionsList);
if (bypass_array_ref) {
CFIndex bypass_array_count = CFArrayGetCount(bypass_array_ref);
for (CFIndex i = 0; i < bypass_array_count; ++i) {
- CFStringRef bypass_item_ref =
- (CFStringRef)CFArrayGetValueAtIndex(bypass_array_ref, i);
- if (CFGetTypeID(bypass_item_ref) != CFStringGetTypeID()) {
+ CFStringRef bypass_item_ref = base::mac::CFCast<CFStringRef>(
+ CFArrayGetValueAtIndex(bypass_array_ref, i));
+ if (!bypass_item_ref) {
LOG(WARNING) << "Expected value for item " << i
<< " in the kSCPropNetProxiesExceptionsList"
" to be a CFStringRef but it was not";
diff --git a/net/proxy/proxy_resolver_mac.cc b/net/proxy/proxy_resolver_mac.cc
index 6c5946c..3f28876 100644
--- a/net/proxy/proxy_resolver_mac.cc
+++ b/net/proxy/proxy_resolver_mac.cc
@@ -130,8 +130,9 @@ int ProxyResolverMac::GetProxyForURL(const GURL& query_url,
CFRelease(result);
return ERR_FAILED;
}
- DCHECK(CFGetTypeID(result) == CFArrayGetTypeID());
- base::mac::ScopedCFTypeRef<CFArrayRef> proxy_array_ref((CFArrayRef)result);
+ base::mac::ScopedCFTypeRef<CFArrayRef> proxy_array_ref(
+ base::mac::CFCastStrict<CFArrayRef>(result));
+ DCHECK(proxy_array_ref != NULL);
// This string will be an ordered list of <proxy-uri> entries, separated by
// semi-colons. It is the format that ProxyInfo::UseNamedProxy() expects.
@@ -141,9 +142,9 @@ int ProxyResolverMac::GetProxyForURL(const GURL& query_url,
CFIndex proxy_array_count = CFArrayGetCount(proxy_array_ref.get());
for (CFIndex i = 0; i < proxy_array_count; ++i) {
- CFDictionaryRef proxy_dictionary =
- (CFDictionaryRef)CFArrayGetValueAtIndex(proxy_array_ref.get(), i);
- DCHECK(CFGetTypeID(proxy_dictionary) == CFDictionaryGetTypeID());
+ CFDictionaryRef proxy_dictionary = base::mac::CFCastStrict<CFDictionaryRef>(
+ CFArrayGetValueAtIndex(proxy_array_ref.get(), i));
+ DCHECK(proxy_dictionary != NULL);
// The dictionary may have the following keys:
// - kCFProxyTypeKey : The type of the proxy
@@ -159,10 +160,8 @@ int ProxyResolverMac::GetProxyForURL(const GURL& query_url,
// - kCFProxyAutoConfigurationURLKey : If the PAC file specifies another
// PAC file, I'm going home.
- CFStringRef proxy_type =
- (CFStringRef)base::mac::GetValueFromDictionary(proxy_dictionary,
- kCFProxyTypeKey,
- CFStringGetTypeID());
+ CFStringRef proxy_type = base::mac::GetValueFromDictionary<CFStringRef>(
+ proxy_dictionary, kCFProxyTypeKey);
ProxyServer proxy_server = ProxyServer::FromDictionary(
GetProxyServerScheme(proxy_type),
proxy_dictionary,
diff --git a/net/proxy/proxy_server_mac.cc b/net/proxy/proxy_server_mac.cc
index 4df37a4..b9849ff 100644
--- a/net/proxy/proxy_server_mac.cc
+++ b/net/proxy/proxy_server_mac.cc
@@ -25,8 +25,7 @@ ProxyServer ProxyServer::FromDictionary(Scheme scheme,
}
CFStringRef host_ref =
- (CFStringRef)base::mac::GetValueFromDictionary(dict, host_key,
- CFStringGetTypeID());
+ base::mac::GetValueFromDictionary<CFStringRef>(dict, host_key);
if (!host_ref) {
LOG(WARNING) << "Could not find expected key "
<< base::SysCFStringRefToUTF8(host_key)
@@ -36,8 +35,7 @@ ProxyServer ProxyServer::FromDictionary(Scheme scheme,
std::string host = base::SysCFStringRefToUTF8(host_ref);
CFNumberRef port_ref =
- (CFNumberRef)base::mac::GetValueFromDictionary(dict, port_key,
- CFNumberGetTypeID());
+ base::mac::GetValueFromDictionary<CFNumberRef>(dict, port_key);
int port;
if (port_ref) {
CFNumberGetValue(port_ref, kCFNumberIntType, &port);