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

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

Issue 8528013: Convert plain C-style casts to use CFCastStrict and GetValueFromDictionary template (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Line alignment + Switching strict cases to normal. Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 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_resolver_mac.h" 5 #include "net/proxy/proxy_resolver_mac.h"
6 6
7 #include <CoreFoundation/CoreFoundation.h> 7 #include <CoreFoundation/CoreFoundation.h>
8 #include <CoreServices/CoreServices.h> 8 #include <CoreServices/CoreServices.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 CFRunLoopRunInMode(private_runloop_mode, DBL_MAX, false); 123 CFRunLoopRunInMode(private_runloop_mode, DBL_MAX, false);
124 CFRunLoopRemoveSource(CFRunLoopGetCurrent(), runloop_source.get(), 124 CFRunLoopRemoveSource(CFRunLoopGetCurrent(), runloop_source.get(),
125 private_runloop_mode); 125 private_runloop_mode);
126 DCHECK(result != NULL); 126 DCHECK(result != NULL);
127 127
128 if (CFGetTypeID(result) == CFErrorGetTypeID()) { 128 if (CFGetTypeID(result) == CFErrorGetTypeID()) {
129 // TODO(avi): do something better than this 129 // TODO(avi): do something better than this
130 CFRelease(result); 130 CFRelease(result);
131 return ERR_FAILED; 131 return ERR_FAILED;
132 } 132 }
133 DCHECK(CFGetTypeID(result) == CFArrayGetTypeID()); 133 base::mac::ScopedCFTypeRef<CFArrayRef> proxy_array_ref(
134 base::mac::ScopedCFTypeRef<CFArrayRef> proxy_array_ref((CFArrayRef)result); 134 base::mac::CFCastStrict<CFArrayRef>(result));
Mark Mentovai 2011/11/11 17:31:50 The old code has this as a DCHECK, but you’ve used
135 135
136 // This string will be an ordered list of <proxy-uri> entries, separated by 136 // This string will be an ordered list of <proxy-uri> entries, separated by
137 // semi-colons. It is the format that ProxyInfo::UseNamedProxy() expects. 137 // semi-colons. It is the format that ProxyInfo::UseNamedProxy() expects.
138 // proxy-uri = [<proxy-scheme>"://"]<proxy-host>":"<proxy-port> 138 // proxy-uri = [<proxy-scheme>"://"]<proxy-host>":"<proxy-port>
139 // (This also includes entries for direct connection, as "direct://"). 139 // (This also includes entries for direct connection, as "direct://").
140 std::string proxy_uri_list; 140 std::string proxy_uri_list;
141 141
142 CFIndex proxy_array_count = CFArrayGetCount(proxy_array_ref.get()); 142 CFIndex proxy_array_count = CFArrayGetCount(proxy_array_ref.get());
143 for (CFIndex i = 0; i < proxy_array_count; ++i) { 143 for (CFIndex i = 0; i < proxy_array_count; ++i) {
144 CFDictionaryRef proxy_dictionary = 144 CFDictionaryRef proxy_dictionary = base::mac::CFCastStrict<CFDictionaryRef>(
145 (CFDictionaryRef)CFArrayGetValueAtIndex(proxy_array_ref.get(), i); 145 CFArrayGetValueAtIndex(proxy_array_ref.get(), i));
Mark Mentovai 2011/11/11 17:31:50 Same.
146 DCHECK(CFGetTypeID(proxy_dictionary) == CFDictionaryGetTypeID());
147 146
148 // The dictionary may have the following keys: 147 // The dictionary may have the following keys:
149 // - kCFProxyTypeKey : The type of the proxy 148 // - kCFProxyTypeKey : The type of the proxy
150 // - kCFProxyHostNameKey 149 // - kCFProxyHostNameKey
151 // - kCFProxyPortNumberKey : The meat we're after. 150 // - kCFProxyPortNumberKey : The meat we're after.
152 // - kCFProxyUsernameKey 151 // - kCFProxyUsernameKey
153 // - kCFProxyPasswordKey : Despite the existence of these keys in the 152 // - kCFProxyPasswordKey : Despite the existence of these keys in the
154 // documentation, they're never populated. Even if a 153 // documentation, they're never populated. Even if a
155 // username/password were to be set in the network 154 // username/password were to be set in the network
156 // proxy system preferences, we'd need to fetch it 155 // proxy system preferences, we'd need to fetch it
157 // from the Keychain ourselves. CFProxy is such a 156 // from the Keychain ourselves. CFProxy is such a
158 // tease. 157 // tease.
159 // - kCFProxyAutoConfigurationURLKey : If the PAC file specifies another 158 // - kCFProxyAutoConfigurationURLKey : If the PAC file specifies another
160 // PAC file, I'm going home. 159 // PAC file, I'm going home.
161 160
162 CFStringRef proxy_type = 161 CFStringRef proxy_type = base::mac::CFCastStrict<CFStringRef>(
Mark Mentovai 2011/11/11 17:31:50 And in this case, the old code didn’t even have a
163 (CFStringRef)base::mac::GetValueFromDictionary(proxy_dictionary, 162 base::mac::GetValueFromDictionary(proxy_dictionary,
164 kCFProxyTypeKey, 163 kCFProxyTypeKey,
165 CFStringGetTypeID()); 164 CFStringGetTypeID()));
166 ProxyServer proxy_server = ProxyServer::FromDictionary( 165 ProxyServer proxy_server = ProxyServer::FromDictionary(
167 GetProxyServerScheme(proxy_type), 166 GetProxyServerScheme(proxy_type),
168 proxy_dictionary, 167 proxy_dictionary,
169 kCFProxyHostNameKey, 168 kCFProxyHostNameKey,
170 kCFProxyPortNumberKey); 169 kCFProxyPortNumberKey);
171 if (!proxy_server.is_valid()) 170 if (!proxy_server.is_valid())
172 continue; 171 continue;
173 172
174 if (!proxy_uri_list.empty()) 173 if (!proxy_uri_list.empty())
175 proxy_uri_list += ";"; 174 proxy_uri_list += ";";
(...skipping 26 matching lines...) Expand all
202 } 201 }
203 202
204 int ProxyResolverMac::SetPacScript( 203 int ProxyResolverMac::SetPacScript(
205 const scoped_refptr<ProxyResolverScriptData>& script_data, 204 const scoped_refptr<ProxyResolverScriptData>& script_data,
206 OldCompletionCallback* /*callback*/) { 205 OldCompletionCallback* /*callback*/) {
207 script_data_ = script_data; 206 script_data_ = script_data;
208 return OK; 207 return OK;
209 } 208 }
210 209
211 } // namespace net 210 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698