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

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

Issue 1439053002: Change ProxyResolver::GetProxyForURL() to take a scoped_ptr<Request>* rather than a RequestHandle* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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_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/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 class ProxyResolverWinHttp : public ProxyResolver { 54 class ProxyResolverWinHttp : public ProxyResolver {
55 public: 55 public:
56 ProxyResolverWinHttp( 56 ProxyResolverWinHttp(
57 const scoped_refptr<ProxyResolverScriptData>& script_data); 57 const scoped_refptr<ProxyResolverScriptData>& script_data);
58 ~ProxyResolverWinHttp() override; 58 ~ProxyResolverWinHttp() override;
59 59
60 // ProxyResolver implementation: 60 // ProxyResolver implementation:
61 int GetProxyForURL(const GURL& url, 61 int GetProxyForURL(const GURL& url,
62 ProxyInfo* results, 62 ProxyInfo* results,
63 const CompletionCallback& /*callback*/, 63 const CompletionCallback& /*callback*/,
64 RequestHandle* /*request*/, 64 scoped_ptr<Request>* /*request*/,
65 const BoundNetLog& /*net_log*/) override; 65 const BoundNetLog& /*net_log*/) override;
66 void CancelRequest(RequestHandle request) override;
67
68 LoadState GetLoadState(RequestHandle request) const override;
69 66
70 private: 67 private:
71 bool OpenWinHttpSession(); 68 bool OpenWinHttpSession();
72 void CloseWinHttpSession(); 69 void CloseWinHttpSession();
73 70
74 // Proxy configuration is cached on the session handle. 71 // Proxy configuration is cached on the session handle.
75 HINTERNET session_handle_; 72 HINTERNET session_handle_;
76 73
77 const GURL pac_url_; 74 const GURL pac_url_;
78 75
79 DISALLOW_COPY_AND_ASSIGN(ProxyResolverWinHttp); 76 DISALLOW_COPY_AND_ASSIGN(ProxyResolverWinHttp);
80 }; 77 };
81 78
82 ProxyResolverWinHttp::ProxyResolverWinHttp( 79 ProxyResolverWinHttp::ProxyResolverWinHttp(
83 const scoped_refptr<ProxyResolverScriptData>& script_data) 80 const scoped_refptr<ProxyResolverScriptData>& script_data)
84 : session_handle_(NULL), 81 : session_handle_(NULL),
85 pac_url_(script_data->type() == ProxyResolverScriptData::TYPE_AUTO_DETECT 82 pac_url_(script_data->type() == ProxyResolverScriptData::TYPE_AUTO_DETECT
86 ? GURL("http://wpad/wpad.dat") 83 ? GURL("http://wpad/wpad.dat")
87 : script_data->url()) { 84 : script_data->url()) {
88 } 85 }
89 86
90 ProxyResolverWinHttp::~ProxyResolverWinHttp() { 87 ProxyResolverWinHttp::~ProxyResolverWinHttp() {
91 CloseWinHttpSession(); 88 CloseWinHttpSession();
92 } 89 }
93 90
94 int ProxyResolverWinHttp::GetProxyForURL(const GURL& query_url, 91 int ProxyResolverWinHttp::GetProxyForURL(const GURL& query_url,
95 ProxyInfo* results, 92 ProxyInfo* results,
96 const CompletionCallback& /*callback*/, 93 const CompletionCallback& /*callback*/,
97 RequestHandle* /*request*/, 94 scoped_ptr<Request>* /*request*/,
98 const BoundNetLog& /*net_log*/) { 95 const BoundNetLog& /*net_log*/) {
99 // If we don't have a WinHTTP session, then create a new one. 96 // If we don't have a WinHTTP session, then create a new one.
100 if (!session_handle_ && !OpenWinHttpSession()) 97 if (!session_handle_ && !OpenWinHttpSession())
101 return ERR_FAILED; 98 return ERR_FAILED;
102 99
103 // If we have been given an empty PAC url, then use auto-detection. 100 // If we have been given an empty PAC url, then use auto-detection.
104 // 101 //
105 // NOTE: We just use DNS-based auto-detection here like Firefox. We do this 102 // NOTE: We just use DNS-based auto-detection here like Firefox. We do this
106 // to avoid WinHTTP's auto-detection code, which while more featureful (it 103 // to avoid WinHTTP's auto-detection code, which while more featureful (it
107 // supports DHCP based auto-detection) also appears to have issues. 104 // supports DHCP based auto-detection) also appears to have issues.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 break; 164 break;
168 default: 165 default:
169 NOTREACHED(); 166 NOTREACHED();
170 rv = ERR_FAILED; 167 rv = ERR_FAILED;
171 } 168 }
172 169
173 FreeInfo(&info); 170 FreeInfo(&info);
174 return rv; 171 return rv;
175 } 172 }
176 173
177 void ProxyResolverWinHttp::CancelRequest(RequestHandle request) {
178 // This is a synchronous ProxyResolver; no possibility for async requests.
179 NOTREACHED();
180 }
181
182 LoadState ProxyResolverWinHttp::GetLoadState(RequestHandle request) const {
183 NOTREACHED();
184 return LOAD_STATE_IDLE;
185 }
186
187 bool ProxyResolverWinHttp::OpenWinHttpSession() { 174 bool ProxyResolverWinHttp::OpenWinHttpSession() {
188 DCHECK(!session_handle_); 175 DCHECK(!session_handle_);
189 session_handle_ = WinHttpOpen(NULL, 176 session_handle_ = WinHttpOpen(NULL,
190 WINHTTP_ACCESS_TYPE_NO_PROXY, 177 WINHTTP_ACCESS_TYPE_NO_PROXY,
191 WINHTTP_NO_PROXY_NAME, 178 WINHTTP_NO_PROXY_NAME,
192 WINHTTP_NO_PROXY_BYPASS, 179 WINHTTP_NO_PROXY_BYPASS,
193 0); 180 0);
194 if (!session_handle_) 181 if (!session_handle_)
195 return false; 182 return false;
196 183
(...skipping 23 matching lines...) Expand all
220 int ProxyResolverFactoryWinHttp::CreateProxyResolver( 207 int ProxyResolverFactoryWinHttp::CreateProxyResolver(
221 const scoped_refptr<ProxyResolverScriptData>& pac_script, 208 const scoped_refptr<ProxyResolverScriptData>& pac_script,
222 scoped_ptr<ProxyResolver>* resolver, 209 scoped_ptr<ProxyResolver>* resolver,
223 const CompletionCallback& callback, 210 const CompletionCallback& callback,
224 scoped_ptr<Request>* request) { 211 scoped_ptr<Request>* request) {
225 resolver->reset(new ProxyResolverWinHttp(pac_script)); 212 resolver->reset(new ProxyResolverWinHttp(pac_script));
226 return OK; 213 return OK;
227 } 214 }
228 215
229 } // namespace net 216 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698