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

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

Issue 959803004: ProxyResolverMac: invalidate resolver source. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | 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) 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 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // required by CFNetworkExecuteProxyAutoConfigurationURL. 97 // required by CFNetworkExecuteProxyAutoConfigurationURL.
98 98
99 CFArrayRef dummy_result = CFNetworkCopyProxiesForURL(query_url_ref.get(), 99 CFArrayRef dummy_result = CFNetworkCopyProxiesForURL(query_url_ref.get(),
100 NULL); 100 NULL);
101 if (dummy_result) 101 if (dummy_result)
102 CFRelease(dummy_result); 102 CFRelease(dummy_result);
103 103
104 // We cheat here. We need to act as if we were synchronous, so we pump the 104 // We cheat here. We need to act as if we were synchronous, so we pump the
105 // runloop ourselves. Our caller moved us to a new thread anyway, so this is 105 // runloop ourselves. Our caller moved us to a new thread anyway, so this is
106 // OK to do. (BTW, CFNetworkExecuteProxyAutoConfigurationURL returns a 106 // OK to do. (BTW, CFNetworkExecuteProxyAutoConfigurationURL returns a
107 // runloop source we need to release despite its name.) 107 // runloop source we need to release despite its name.)
davidben 2015/02/25 22:38:38 This seems to date to https://crrev.com/4293, befo
davidben 2015/02/25 22:41:24 Looks like the async bits were added in http://cod
108 108
109 CFTypeRef result = NULL; 109 CFTypeRef result = NULL;
110 CFStreamClientContext context = { 0, &result, NULL, NULL, NULL }; 110 CFStreamClientContext context = { 0, &result, NULL, NULL, NULL };
111 base::ScopedCFTypeRef<CFRunLoopSourceRef> runloop_source( 111 base::ScopedCFTypeRef<CFRunLoopSourceRef> runloop_source(
112 CFNetworkExecuteProxyAutoConfigurationURL( 112 CFNetworkExecuteProxyAutoConfigurationURL(
113 pac_url_ref.get(), query_url_ref.get(), ResultCallback, &context)); 113 pac_url_ref.get(), query_url_ref.get(), ResultCallback, &context));
114 if (!runloop_source) 114 if (!runloop_source)
115 return ERR_FAILED; 115 return ERR_FAILED;
116 116
117 const CFStringRef private_runloop_mode = 117 const CFStringRef private_runloop_mode =
118 CFSTR("org.chromium.ProxyResolverMac"); 118 CFSTR("org.chromium.ProxyResolverMac");
119 119
120 CFRunLoopAddSource(CFRunLoopGetCurrent(), runloop_source.get(), 120 CFRunLoopAddSource(CFRunLoopGetCurrent(), runloop_source.get(),
121 private_runloop_mode); 121 private_runloop_mode);
122 CFRunLoopRunInMode(private_runloop_mode, DBL_MAX, false); 122 CFRunLoopRunInMode(private_runloop_mode, DBL_MAX, false);
123 CFRunLoopRemoveSource(CFRunLoopGetCurrent(), runloop_source.get(), 123 CFRunLoopSourceInvalidate(runloop_source.get());
124 private_runloop_mode);
125 DCHECK(result != NULL); 124 DCHECK(result != NULL);
126 125
127 if (CFGetTypeID(result) == CFErrorGetTypeID()) { 126 if (CFGetTypeID(result) == CFErrorGetTypeID()) {
128 // TODO(avi): do something better than this 127 // TODO(avi): do something better than this
129 CFRelease(result); 128 CFRelease(result);
130 return ERR_FAILED; 129 return ERR_FAILED;
131 } 130 }
132 base::ScopedCFTypeRef<CFArrayRef> proxy_array_ref( 131 base::ScopedCFTypeRef<CFArrayRef> proxy_array_ref(
133 base::mac::CFCastStrict<CFArrayRef>(result)); 132 base::mac::CFCastStrict<CFArrayRef>(result));
134 DCHECK(proxy_array_ref != NULL); 133 DCHECK(proxy_array_ref != NULL);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 194 }
196 195
197 int ProxyResolverMac::SetPacScript( 196 int ProxyResolverMac::SetPacScript(
198 const scoped_refptr<ProxyResolverScriptData>& script_data, 197 const scoped_refptr<ProxyResolverScriptData>& script_data,
199 const CompletionCallback& /*callback*/) { 198 const CompletionCallback& /*callback*/) {
200 script_data_ = script_data; 199 script_data_ = script_data;
201 return OK; 200 return OK;
202 } 201 }
203 202
204 } // namespace net 203 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698