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

Side by Side Diff: net/http/http_proxy_client_socket.cc

Issue 8801005: base::Bind: Convert Socket::Read. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | Annotate | Revision Log
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/http/http_proxy_client_socket.h" 5 #include "net/http/http_proxy_client_socket.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 #include "net/base/auth.h" 10 #include "net/base/auth.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 base::TimeDelta HttpProxyClientSocket::GetConnectTimeMicros() const { 207 base::TimeDelta HttpProxyClientSocket::GetConnectTimeMicros() const {
208 if (transport_.get() && transport_->socket()) { 208 if (transport_.get() && transport_->socket()) {
209 return transport_->socket()->GetConnectTimeMicros(); 209 return transport_->socket()->GetConnectTimeMicros();
210 } 210 }
211 NOTREACHED(); 211 NOTREACHED();
212 return base::TimeDelta::FromMicroseconds(-1); 212 return base::TimeDelta::FromMicroseconds(-1);
213 } 213 }
214 214
215 int HttpProxyClientSocket::Read(IOBuffer* buf, int buf_len, 215 int HttpProxyClientSocket::Read(IOBuffer* buf, int buf_len,
216 OldCompletionCallback* callback) { 216 OldCompletionCallback* callback) {
217 DCHECK(!old_user_callback_); 217 DCHECK(!old_user_callback_);
csilv 2011/12/07 00:03:48 change to match check on line 236
James Hawkins 2011/12/07 00:19:37 Done.
218 if (next_state_ != STATE_DONE) { 218 if (next_state_ != STATE_DONE) {
219 // We're trying to read the body of the response but we're still trying 219 // We're trying to read the body of the response but we're still trying
220 // to establish an SSL tunnel through the proxy. We can't read these 220 // to establish an SSL tunnel through the proxy. We can't read these
221 // bytes when establishing a tunnel because they might be controlled by 221 // bytes when establishing a tunnel because they might be controlled by
222 // an active network attacker. We don't worry about this for HTTP 222 // an active network attacker. We don't worry about this for HTTP
223 // because an active network attacker can already control HTTP sessions. 223 // because an active network attacker can already control HTTP sessions.
224 // We reach this case when the user cancels a 407 proxy auth prompt. 224 // We reach this case when the user cancels a 407 proxy auth prompt.
225 // See http://crbug.com/8473. 225 // See http://crbug.com/8473.
226 DCHECK_EQ(407, response_.headers->response_code()); 226 DCHECK_EQ(407, response_.headers->response_code());
227 LogBlockedTunnelResponse(response_.headers->response_code()); 227 LogBlockedTunnelResponse(response_.headers->response_code());
228 228
229 return ERR_TUNNEL_CONNECTION_FAILED; 229 return ERR_TUNNEL_CONNECTION_FAILED;
230 } 230 }
231 231
232 return transport_->socket()->Read(buf, buf_len, callback); 232 return transport_->socket()->Read(buf, buf_len, callback);
233 } 233 }
234 int HttpProxyClientSocket::Read(IOBuffer* buf, int buf_len,
235 const CompletionCallback& callback) {
236 DCHECK(!old_user_callback_ && user_callback_.is_null());
237 if (next_state_ != STATE_DONE) {
238 // We're trying to read the body of the response but we're still trying
239 // to establish an SSL tunnel through the proxy. We can't read these
240 // bytes when establishing a tunnel because they might be controlled by
241 // an active network attacker. We don't worry about this for HTTP
242 // because an active network attacker can already control HTTP sessions.
243 // We reach this case when the user cancels a 407 proxy auth prompt.
244 // See http://crbug.com/8473.
245 DCHECK_EQ(407, response_.headers->response_code());
246 LogBlockedTunnelResponse(response_.headers->response_code());
247
248 return ERR_TUNNEL_CONNECTION_FAILED;
249 }
250
251 return transport_->socket()->Read(buf, buf_len, callback);
252 }
234 253
235 int HttpProxyClientSocket::Write(IOBuffer* buf, int buf_len, 254 int HttpProxyClientSocket::Write(IOBuffer* buf, int buf_len,
236 OldCompletionCallback* callback) { 255 OldCompletionCallback* callback) {
237 DCHECK_EQ(STATE_DONE, next_state_); 256 DCHECK_EQ(STATE_DONE, next_state_);
238 DCHECK(!old_user_callback_); 257 DCHECK(!old_user_callback_);
239 258
240 return transport_->socket()->Write(buf, buf_len, callback); 259 return transport_->socket()->Write(buf, buf_len, callback);
241 } 260 }
242 261
243 bool HttpProxyClientSocket::SetReceiveBufferSize(int32 size) { 262 bool HttpProxyClientSocket::SetReceiveBufferSize(int32 size) {
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 516
498 if (http_stream_parser_->IsResponseBodyComplete()) 517 if (http_stream_parser_->IsResponseBodyComplete())
499 return DidDrainBodyForAuthRestart(true); 518 return DidDrainBodyForAuthRestart(true);
500 519
501 // Keep draining. 520 // Keep draining.
502 next_state_ = STATE_DRAIN_BODY; 521 next_state_ = STATE_DRAIN_BODY;
503 return OK; 522 return OK;
504 } 523 }
505 524
506 } // namespace net 525 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698