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/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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 | 117 |
118 next_state_ = STATE_DISCONNECTED; | 118 next_state_ = STATE_DISCONNECTED; |
119 | 119 |
120 if (spdy_stream_) | 120 if (spdy_stream_) |
121 // This will cause OnClose to be invoked, which takes care of | 121 // This will cause OnClose to be invoked, which takes care of |
122 // cleaning up all the internal state. | 122 // cleaning up all the internal state. |
123 spdy_stream_->Cancel(); | 123 spdy_stream_->Cancel(); |
124 } | 124 } |
125 | 125 |
126 bool SpdyProxyClientSocket::IsConnected() const { | 126 bool SpdyProxyClientSocket::IsConnected() const { |
127 return next_state_ == STATE_OPEN || next_state_ == STATE_CLOSED; | 127 return next_state_ == STATE_OPEN || next_state_ == STATE_CLOSED; |
wtc
2011/12/01 22:22:15
It seems that IsConnected() should return false if
Ryan Hamilton
2011/12/02 22:24:13
Done.
| |
128 } | 128 } |
129 | 129 |
130 bool SpdyProxyClientSocket::IsConnectedAndIdle() const { | 130 bool SpdyProxyClientSocket::IsConnectedAndIdle() const { |
131 return IsConnected() && spdy_stream_.get() != NULL && | 131 return IsConnected() && spdy_stream_ && !spdy_stream_->is_idle(); |
132 !spdy_stream_->is_idle(); | |
133 } | 132 } |
134 | 133 |
135 const BoundNetLog& SpdyProxyClientSocket::NetLog() const { | 134 const BoundNetLog& SpdyProxyClientSocket::NetLog() const { |
136 return net_log_; | 135 return net_log_; |
137 } | 136 } |
138 | 137 |
139 void SpdyProxyClientSocket::SetSubresourceSpeculation() { | 138 void SpdyProxyClientSocket::SetSubresourceSpeculation() { |
140 // TODO(rch): what should this implementation be? | 139 // TODO(rch): what should this implementation be? |
141 } | 140 } |
142 | 141 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 | 257 |
259 bool SpdyProxyClientSocket::SetSendBufferSize(int32 size) { | 258 bool SpdyProxyClientSocket::SetSendBufferSize(int32 size) { |
260 // Since this StreamSocket sits on top of a shared SpdySession, it | 259 // Since this StreamSocket sits on top of a shared SpdySession, it |
261 // is not safe for callers to set change this underlying socket. | 260 // is not safe for callers to set change this underlying socket. |
262 return false; | 261 return false; |
263 } | 262 } |
264 | 263 |
265 int SpdyProxyClientSocket::GetPeerAddress(AddressList* address) const { | 264 int SpdyProxyClientSocket::GetPeerAddress(AddressList* address) const { |
266 if (!IsConnected()) | 265 if (!IsConnected()) |
267 return ERR_SOCKET_NOT_CONNECTED; | 266 return ERR_SOCKET_NOT_CONNECTED; |
268 return spdy_stream_->GetPeerAddress(address); | 267 *address = peer_address_; |
wtc
2011/12/01 22:22:15
Is it normal for spdy_stream_ to become NULL when
Ryan Hamilton
2011/12/02 22:24:13
It was, but because of the change you suggested th
| |
268 return OK; | |
269 } | 269 } |
270 | 270 |
271 int SpdyProxyClientSocket::GetLocalAddress(IPEndPoint* address) const { | 271 int SpdyProxyClientSocket::GetLocalAddress(IPEndPoint* address) const { |
272 if (!IsConnected()) | 272 if (!IsConnected()) |
273 return ERR_SOCKET_NOT_CONNECTED; | 273 return ERR_SOCKET_NOT_CONNECTED; |
274 return spdy_stream_->GetLocalAddress(address); | 274 *address = local_address_; |
275 return OK; | |
275 } | 276 } |
276 | 277 |
277 void SpdyProxyClientSocket::OnIOComplete(int result) { | 278 void SpdyProxyClientSocket::OnIOComplete(int result) { |
278 DCHECK_NE(STATE_DISCONNECTED, next_state_); | 279 DCHECK_NE(STATE_DISCONNECTED, next_state_); |
279 int rv = DoLoop(result); | 280 int rv = DoLoop(result); |
280 if (rv != ERR_IO_PENDING) { | 281 if (rv != ERR_IO_PENDING) { |
281 OldCompletionCallback* c = read_callback_; | 282 OldCompletionCallback* c = read_callback_; |
282 read_callback_ = NULL; | 283 read_callback_ = NULL; |
283 c->Run(rv); | 284 c->Run(rv); |
284 } | 285 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 // we are notified by a callback when the SYN_REPLY frame arrives | 383 // we are notified by a callback when the SYN_REPLY frame arrives |
383 | 384 |
384 if (result < 0) | 385 if (result < 0) |
385 return result; | 386 return result; |
386 | 387 |
387 // Require the "HTTP/1.x" status line for SSL CONNECT. | 388 // Require the "HTTP/1.x" status line for SSL CONNECT. |
388 if (response_.headers->GetParsedHttpVersion() < HttpVersion(1, 0)) | 389 if (response_.headers->GetParsedHttpVersion() < HttpVersion(1, 0)) |
389 return ERR_TUNNEL_CONNECTION_FAILED; | 390 return ERR_TUNNEL_CONNECTION_FAILED; |
390 | 391 |
391 next_state_ = STATE_OPEN; | 392 next_state_ = STATE_OPEN; |
393 spdy_stream_->GetPeerAddress(&peer_address_); | |
394 spdy_stream_->GetLocalAddress(&local_address_); | |
395 | |
392 if (net_log_.IsLoggingAllEvents()) { | 396 if (net_log_.IsLoggingAllEvents()) { |
393 net_log_.AddEvent( | 397 net_log_.AddEvent( |
394 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 398 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
395 make_scoped_refptr(new NetLogHttpResponseParameter(response_.headers))); | 399 make_scoped_refptr(new NetLogHttpResponseParameter(response_.headers))); |
396 } | 400 } |
397 | 401 |
398 if (response_.headers->response_code() == 200) { | 402 if (response_.headers->response_code() == 200) { |
399 return OK; | 403 return OK; |
400 } else if (response_.headers->response_code() == 407) { | 404 } else if (response_.headers->response_code() == 407) { |
401 int rv = HandleAuthChallenge(auth_, &response_, net_log_); | 405 int rv = HandleAuthChallenge(auth_, &response_, net_log_); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
536 } | 540 } |
537 // This may have been deleted by read_callback_, so check first. | 541 // This may have been deleted by read_callback_, so check first. |
538 if (weak_ptr && write_callback) | 542 if (weak_ptr && write_callback) |
539 write_callback->Run(ERR_CONNECTION_CLOSED); | 543 write_callback->Run(ERR_CONNECTION_CLOSED); |
540 } | 544 } |
541 | 545 |
542 void SpdyProxyClientSocket::set_chunk_callback(ChunkCallback* /*callback*/) { | 546 void SpdyProxyClientSocket::set_chunk_callback(ChunkCallback* /*callback*/) { |
543 } | 547 } |
544 | 548 |
545 } // namespace net | 549 } // namespace net |
OLD | NEW |