| 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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 ProxyResolverWinHttp::ProxyResolverWinHttp() | 31 ProxyResolverWinHttp::ProxyResolverWinHttp() |
| 32 : ProxyResolver(false /*expects_pac_bytes*/), session_handle_(NULL) { | 32 : ProxyResolver(false /*expects_pac_bytes*/), session_handle_(NULL) { |
| 33 } | 33 } |
| 34 | 34 |
| 35 ProxyResolverWinHttp::~ProxyResolverWinHttp() { | 35 ProxyResolverWinHttp::~ProxyResolverWinHttp() { |
| 36 CloseWinHttpSession(); | 36 CloseWinHttpSession(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 int ProxyResolverWinHttp::GetProxyForURL(const GURL& query_url, | 39 int ProxyResolverWinHttp::GetProxyForURL(const GURL& query_url, |
| 40 ProxyInfo* results, | 40 ProxyInfo* results, |
| 41 OldCompletionCallback* /*callback*/, | 41 const CompletionCallback& /*callback*/, |
| 42 RequestHandle* /*request*/, | 42 RequestHandle* /*request*/, |
| 43 const BoundNetLog& /*net_log*/) { | 43 const BoundNetLog& /*net_log*/) { |
| 44 // If we don't have a WinHTTP session, then create a new one. | 44 // If we don't have a WinHTTP session, then create a new one. |
| 45 if (!session_handle_ && !OpenWinHttpSession()) | 45 if (!session_handle_ && !OpenWinHttpSession()) |
| 46 return ERR_FAILED; | 46 return ERR_FAILED; |
| 47 | 47 |
| 48 // If we have been given an empty PAC url, then use auto-detection. | 48 // If we have been given an empty PAC url, then use auto-detection. |
| 49 // | 49 // |
| 50 // NOTE: We just use DNS-based auto-detection here like Firefox. We do this | 50 // NOTE: We just use DNS-based auto-detection here like Firefox. We do this |
| 51 // to avoid WinHTTP's auto-detection code, which while more featureful (it | 51 // to avoid WinHTTP's auto-detection code, which while more featureful (it |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 RequestHandle request) const { | 133 RequestHandle request) const { |
| 134 return LOAD_STATE_IDLE; | 134 return LOAD_STATE_IDLE; |
| 135 } | 135 } |
| 136 | 136 |
| 137 void ProxyResolverWinHttp::CancelSetPacScript() { | 137 void ProxyResolverWinHttp::CancelSetPacScript() { |
| 138 NOTREACHED(); | 138 NOTREACHED(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 int ProxyResolverWinHttp::SetPacScript( | 141 int ProxyResolverWinHttp::SetPacScript( |
| 142 const scoped_refptr<ProxyResolverScriptData>& script_data, | 142 const scoped_refptr<ProxyResolverScriptData>& script_data, |
| 143 OldCompletionCallback* /*callback*/) { | 143 const CompletionCallback& /*callback*/) { |
| 144 if (script_data->type() == ProxyResolverScriptData::TYPE_AUTO_DETECT) { | 144 if (script_data->type() == ProxyResolverScriptData::TYPE_AUTO_DETECT) { |
| 145 pac_url_ = GURL("http://wpad/wpad.dat"); | 145 pac_url_ = GURL("http://wpad/wpad.dat"); |
| 146 } else { | 146 } else { |
| 147 pac_url_ = script_data->url(); | 147 pac_url_ = script_data->url(); |
| 148 } | 148 } |
| 149 return OK; | 149 return OK; |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool ProxyResolverWinHttp::OpenWinHttpSession() { | 152 bool ProxyResolverWinHttp::OpenWinHttpSession() { |
| 153 DCHECK(!session_handle_); | 153 DCHECK(!session_handle_); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 170 } | 170 } |
| 171 | 171 |
| 172 void ProxyResolverWinHttp::CloseWinHttpSession() { | 172 void ProxyResolverWinHttp::CloseWinHttpSession() { |
| 173 if (session_handle_) { | 173 if (session_handle_) { |
| 174 WinHttpCloseHandle(session_handle_); | 174 WinHttpCloseHandle(session_handle_); |
| 175 session_handle_ = NULL; | 175 session_handle_ = NULL; |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace net | 179 } // namespace net |
| OLD | NEW |