OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/spdy/spdy_proxy_client_socket.h" | 5 #include "net/spdy/spdy_proxy_client_socket.h" |
6 | 6 |
7 #include <algorithm> // min | 7 #include <algorithm> // min |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 spdy_stream_->SetDelegate(this); | 60 spdy_stream_->SetDelegate(this); |
61 was_ever_used_ = spdy_stream_->WasEverUsed(); | 61 was_ever_used_ = spdy_stream_->WasEverUsed(); |
62 } | 62 } |
63 | 63 |
64 SpdyProxyClientSocket::~SpdyProxyClientSocket() { | 64 SpdyProxyClientSocket::~SpdyProxyClientSocket() { |
65 Disconnect(); | 65 Disconnect(); |
66 net_log_.EndEvent(NetLog::TYPE_SOCKET_ALIVE); | 66 net_log_.EndEvent(NetLog::TYPE_SOCKET_ALIVE); |
67 } | 67 } |
68 | 68 |
69 const HttpResponseInfo* SpdyProxyClientSocket::GetConnectResponseInfo() const { | 69 const HttpResponseInfo* SpdyProxyClientSocket::GetConnectResponseInfo() const { |
70 return response_.headers ? &response_ : NULL; | 70 return response_.headers.get() ? &response_ : NULL; |
71 } | 71 } |
72 | 72 |
73 const scoped_refptr<HttpAuthController>& | 73 const scoped_refptr<HttpAuthController>& |
74 SpdyProxyClientSocket::GetAuthController() const { | 74 SpdyProxyClientSocket::GetAuthController() const { |
75 return auth_; | 75 return auth_; |
76 } | 76 } |
77 | 77 |
78 int SpdyProxyClientSocket::RestartWithAuth(const CompletionCallback& callback) { | 78 int SpdyProxyClientSocket::RestartWithAuth(const CompletionCallback& callback) { |
79 // A SPDY Stream can only handle a single request, so the underlying | 79 // A SPDY Stream can only handle a single request, so the underlying |
80 // stream may not be reused and a new SpdyProxyClientSocket must be | 80 // stream may not be reused and a new SpdyProxyClientSocket must be |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 bool SpdyProxyClientSocket::GetSSLInfo(SSLInfo* ssl_info) { | 185 bool SpdyProxyClientSocket::GetSSLInfo(SSLInfo* ssl_info) { |
186 bool was_npn_negotiated; | 186 bool was_npn_negotiated; |
187 NextProto protocol_negotiated; | 187 NextProto protocol_negotiated; |
188 return spdy_stream_->GetSSLInfo(ssl_info, &was_npn_negotiated, | 188 return spdy_stream_->GetSSLInfo(ssl_info, &was_npn_negotiated, |
189 &protocol_negotiated); | 189 &protocol_negotiated); |
190 } | 190 } |
191 | 191 |
192 int SpdyProxyClientSocket::Read(IOBuffer* buf, int buf_len, | 192 int SpdyProxyClientSocket::Read(IOBuffer* buf, int buf_len, |
193 const CompletionCallback& callback) { | 193 const CompletionCallback& callback) { |
194 DCHECK(read_callback_.is_null()); | 194 DCHECK(read_callback_.is_null()); |
195 DCHECK(!user_buffer_); | 195 DCHECK(!user_buffer_.get()); |
196 | 196 |
197 if (next_state_ == STATE_DISCONNECTED) | 197 if (next_state_ == STATE_DISCONNECTED) |
198 return ERR_SOCKET_NOT_CONNECTED; | 198 return ERR_SOCKET_NOT_CONNECTED; |
199 | 199 |
200 if (next_state_ == STATE_CLOSED && read_buffer_queue_.IsEmpty()) { | 200 if (next_state_ == STATE_CLOSED && read_buffer_queue_.IsEmpty()) { |
201 return 0; | 201 return 0; |
202 } | 202 } |
203 | 203 |
204 DCHECK(next_state_ == STATE_OPEN || next_state_ == STATE_CLOSED); | 204 DCHECK(next_state_ == STATE_OPEN || next_state_ == STATE_CLOSED); |
205 DCHECK(buf); | 205 DCHECK(buf); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 response_stream_->InitializeWithExistingStream(stream); | 415 response_stream_->InitializeWithExistingStream(stream); |
416 next_state_ = STATE_DISCONNECTED; | 416 next_state_ = STATE_DISCONNECTED; |
417 return ERR_HTTPS_PROXY_TUNNEL_RESPONSE; | 417 return ERR_HTTPS_PROXY_TUNNEL_RESPONSE; |
418 } else { | 418 } else { |
419 LogBlockedTunnelResponse(); | 419 LogBlockedTunnelResponse(); |
420 return ERR_TUNNEL_CONNECTION_FAILED; | 420 return ERR_TUNNEL_CONNECTION_FAILED; |
421 } | 421 } |
422 | 422 |
423 case 407: // Proxy Authentication Required | 423 case 407: // Proxy Authentication Required |
424 next_state_ = STATE_OPEN; | 424 next_state_ = STATE_OPEN; |
425 return HandleProxyAuthChallenge(auth_, &response_, net_log_); | 425 return HandleProxyAuthChallenge(auth_.get(), &response_, net_log_); |
426 | 426 |
427 default: | 427 default: |
428 // Ignore response to avoid letting the proxy impersonate the target | 428 // Ignore response to avoid letting the proxy impersonate the target |
429 // server. (See http://crbug.com/137891.) | 429 // server. (See http://crbug.com/137891.) |
430 LogBlockedTunnelResponse(); | 430 LogBlockedTunnelResponse(); |
431 return ERR_TUNNEL_CONNECTION_FAILED; | 431 return ERR_TUNNEL_CONNECTION_FAILED; |
432 } | 432 } |
433 } | 433 } |
434 | 434 |
435 // SpdyStream::Delegate methods: | 435 // SpdyStream::Delegate methods: |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 } else if (!read_callback_.is_null()) { | 516 } else if (!read_callback_.is_null()) { |
517 // If we have a read_callback_, the we need to make sure we call it back. | 517 // If we have a read_callback_, the we need to make sure we call it back. |
518 OnDataReceived(scoped_ptr<SpdyBuffer>()); | 518 OnDataReceived(scoped_ptr<SpdyBuffer>()); |
519 } | 519 } |
520 // This may have been deleted by read_callback_, so check first. | 520 // This may have been deleted by read_callback_, so check first. |
521 if (weak_ptr && !write_callback.is_null()) | 521 if (weak_ptr && !write_callback.is_null()) |
522 write_callback.Run(ERR_CONNECTION_CLOSED); | 522 write_callback.Run(ERR_CONNECTION_CLOSED); |
523 } | 523 } |
524 | 524 |
525 } // namespace net | 525 } // namespace net |
OLD | NEW |