| 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_winhttp.h" | 5 #include "net/proxy/proxy_resolver_winhttp.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <winhttp.h> | 8 #include <winhttp.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 public: | 54 public: |
| 55 ProxyResolverWinHttp( | 55 ProxyResolverWinHttp( |
| 56 const scoped_refptr<ProxyResolverScriptData>& script_data); | 56 const scoped_refptr<ProxyResolverScriptData>& script_data); |
| 57 ~ProxyResolverWinHttp() override; | 57 ~ProxyResolverWinHttp() override; |
| 58 | 58 |
| 59 // ProxyResolver implementation: | 59 // ProxyResolver implementation: |
| 60 int GetProxyForURL(const GURL& url, | 60 int GetProxyForURL(const GURL& url, |
| 61 ProxyInfo* results, | 61 ProxyInfo* results, |
| 62 const CompletionCallback& /*callback*/, | 62 const CompletionCallback& /*callback*/, |
| 63 RequestHandle* /*request*/, | 63 RequestHandle* /*request*/, |
| 64 const BoundNetLog& /*net_log*/) override; | 64 const NetLogWithSource& /*net_log*/) override; |
| 65 void CancelRequest(RequestHandle request) override; | 65 void CancelRequest(RequestHandle request) override; |
| 66 | 66 |
| 67 LoadState GetLoadState(RequestHandle request) const override; | 67 LoadState GetLoadState(RequestHandle request) const override; |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 bool OpenWinHttpSession(); | 70 bool OpenWinHttpSession(); |
| 71 void CloseWinHttpSession(); | 71 void CloseWinHttpSession(); |
| 72 | 72 |
| 73 // Proxy configuration is cached on the session handle. | 73 // Proxy configuration is cached on the session handle. |
| 74 HINTERNET session_handle_; | 74 HINTERNET session_handle_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 87 } | 87 } |
| 88 | 88 |
| 89 ProxyResolverWinHttp::~ProxyResolverWinHttp() { | 89 ProxyResolverWinHttp::~ProxyResolverWinHttp() { |
| 90 CloseWinHttpSession(); | 90 CloseWinHttpSession(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 int ProxyResolverWinHttp::GetProxyForURL(const GURL& query_url, | 93 int ProxyResolverWinHttp::GetProxyForURL(const GURL& query_url, |
| 94 ProxyInfo* results, | 94 ProxyInfo* results, |
| 95 const CompletionCallback& /*callback*/, | 95 const CompletionCallback& /*callback*/, |
| 96 RequestHandle* /*request*/, | 96 RequestHandle* /*request*/, |
| 97 const BoundNetLog& /*net_log*/) { | 97 const NetLogWithSource& /*net_log*/) { |
| 98 // If we don't have a WinHTTP session, then create a new one. | 98 // If we don't have a WinHTTP session, then create a new one. |
| 99 if (!session_handle_ && !OpenWinHttpSession()) | 99 if (!session_handle_ && !OpenWinHttpSession()) |
| 100 return ERR_FAILED; | 100 return ERR_FAILED; |
| 101 | 101 |
| 102 // If we have been given an empty PAC url, then use auto-detection. | 102 // If we have been given an empty PAC url, then use auto-detection. |
| 103 // | 103 // |
| 104 // NOTE: We just use DNS-based auto-detection here like Firefox. We do this | 104 // NOTE: We just use DNS-based auto-detection here like Firefox. We do this |
| 105 // to avoid WinHTTP's auto-detection code, which while more featureful (it | 105 // to avoid WinHTTP's auto-detection code, which while more featureful (it |
| 106 // supports DHCP based auto-detection) also appears to have issues. | 106 // supports DHCP based auto-detection) also appears to have issues. |
| 107 // | 107 // |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 int ProxyResolverFactoryWinHttp::CreateProxyResolver( | 219 int ProxyResolverFactoryWinHttp::CreateProxyResolver( |
| 220 const scoped_refptr<ProxyResolverScriptData>& pac_script, | 220 const scoped_refptr<ProxyResolverScriptData>& pac_script, |
| 221 std::unique_ptr<ProxyResolver>* resolver, | 221 std::unique_ptr<ProxyResolver>* resolver, |
| 222 const CompletionCallback& callback, | 222 const CompletionCallback& callback, |
| 223 std::unique_ptr<Request>* request) { | 223 std::unique_ptr<Request>* request) { |
| 224 resolver->reset(new ProxyResolverWinHttp(pac_script)); | 224 resolver->reset(new ProxyResolverWinHttp(pac_script)); |
| 225 return OK; | 225 return OK; |
| 226 } | 226 } |
| 227 | 227 |
| 228 } // namespace net | 228 } // namespace net |
| OLD | NEW |