| OLD | NEW |
| 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/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 public: | 185 public: |
| 186 explicit ProxyResolverMac( | 186 explicit ProxyResolverMac( |
| 187 const scoped_refptr<ProxyResolverScriptData>& script_data); | 187 const scoped_refptr<ProxyResolverScriptData>& script_data); |
| 188 ~ProxyResolverMac() override; | 188 ~ProxyResolverMac() override; |
| 189 | 189 |
| 190 // ProxyResolver methods: | 190 // ProxyResolver methods: |
| 191 int GetProxyForURL(const GURL& url, | 191 int GetProxyForURL(const GURL& url, |
| 192 ProxyInfo* results, | 192 ProxyInfo* results, |
| 193 const CompletionCallback& callback, | 193 const CompletionCallback& callback, |
| 194 RequestHandle* request, | 194 RequestHandle* request, |
| 195 const BoundNetLog& net_log) override; | 195 const NetLogWithSource& net_log) override; |
| 196 | 196 |
| 197 void CancelRequest(RequestHandle request) override; | 197 void CancelRequest(RequestHandle request) override; |
| 198 | 198 |
| 199 LoadState GetLoadState(RequestHandle request) const override; | 199 LoadState GetLoadState(RequestHandle request) const override; |
| 200 | 200 |
| 201 private: | 201 private: |
| 202 const scoped_refptr<ProxyResolverScriptData> script_data_; | 202 const scoped_refptr<ProxyResolverScriptData> script_data_; |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 ProxyResolverMac::ProxyResolverMac( | 205 ProxyResolverMac::ProxyResolverMac( |
| 206 const scoped_refptr<ProxyResolverScriptData>& script_data) | 206 const scoped_refptr<ProxyResolverScriptData>& script_data) |
| 207 : script_data_(script_data) { | 207 : script_data_(script_data) { |
| 208 } | 208 } |
| 209 | 209 |
| 210 ProxyResolverMac::~ProxyResolverMac() {} | 210 ProxyResolverMac::~ProxyResolverMac() {} |
| 211 | 211 |
| 212 // Gets the proxy information for a query URL from a PAC. Implementation | 212 // Gets the proxy information for a query URL from a PAC. Implementation |
| 213 // inspired by http://developer.apple.com/samplecode/CFProxySupportTool/ | 213 // inspired by http://developer.apple.com/samplecode/CFProxySupportTool/ |
| 214 int ProxyResolverMac::GetProxyForURL(const GURL& query_url, | 214 int ProxyResolverMac::GetProxyForURL(const GURL& query_url, |
| 215 ProxyInfo* results, | 215 ProxyInfo* results, |
| 216 const CompletionCallback& /*callback*/, | 216 const CompletionCallback& /*callback*/, |
| 217 RequestHandle* /*request*/, | 217 RequestHandle* /*request*/, |
| 218 const BoundNetLog& net_log) { | 218 const NetLogWithSource& net_log) { |
| 219 base::ScopedCFTypeRef<CFStringRef> query_ref( | 219 base::ScopedCFTypeRef<CFStringRef> query_ref( |
| 220 base::SysUTF8ToCFStringRef(query_url.spec())); | 220 base::SysUTF8ToCFStringRef(query_url.spec())); |
| 221 base::ScopedCFTypeRef<CFURLRef> query_url_ref( | 221 base::ScopedCFTypeRef<CFURLRef> query_url_ref( |
| 222 CFURLCreateWithString(kCFAllocatorDefault, query_ref.get(), NULL)); | 222 CFURLCreateWithString(kCFAllocatorDefault, query_ref.get(), NULL)); |
| 223 if (!query_url_ref.get()) | 223 if (!query_url_ref.get()) |
| 224 return ERR_FAILED; | 224 return ERR_FAILED; |
| 225 base::ScopedCFTypeRef<CFStringRef> pac_ref(base::SysUTF8ToCFStringRef( | 225 base::ScopedCFTypeRef<CFStringRef> pac_ref(base::SysUTF8ToCFStringRef( |
| 226 script_data_->type() == ProxyResolverScriptData::TYPE_AUTO_DETECT | 226 script_data_->type() == ProxyResolverScriptData::TYPE_AUTO_DETECT |
| 227 ? std::string() | 227 ? std::string() |
| 228 : script_data_->url().spec())); | 228 : script_data_->url().spec())); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 int ProxyResolverFactoryMac::CreateProxyResolver( | 360 int ProxyResolverFactoryMac::CreateProxyResolver( |
| 361 const scoped_refptr<ProxyResolverScriptData>& pac_script, | 361 const scoped_refptr<ProxyResolverScriptData>& pac_script, |
| 362 std::unique_ptr<ProxyResolver>* resolver, | 362 std::unique_ptr<ProxyResolver>* resolver, |
| 363 const CompletionCallback& callback, | 363 const CompletionCallback& callback, |
| 364 std::unique_ptr<Request>* request) { | 364 std::unique_ptr<Request>* request) { |
| 365 resolver->reset(new ProxyResolverMac(pac_script)); | 365 resolver->reset(new ProxyResolverMac(pac_script)); |
| 366 return OK; | 366 return OK; |
| 367 } | 367 } |
| 368 | 368 |
| 369 } // namespace net | 369 } // namespace net |
| OLD | NEW |