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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 | 434 |
435 // SpdyStream::Delegate methods: | 435 // SpdyStream::Delegate methods: |
436 // Called when SYN frame has been sent. | 436 // Called when SYN frame has been sent. |
437 // Returns true if no more data to be sent after SYN frame. | 437 // Returns true if no more data to be sent after SYN frame. |
438 void SpdyProxyClientSocket::OnRequestHeadersSent() { | 438 void SpdyProxyClientSocket::OnRequestHeadersSent() { |
439 DCHECK_EQ(next_state_, STATE_SEND_REQUEST_COMPLETE); | 439 DCHECK_EQ(next_state_, STATE_SEND_REQUEST_COMPLETE); |
440 | 440 |
441 OnIOComplete(OK); | 441 OnIOComplete(OK); |
442 } | 442 } |
443 | 443 |
444 int SpdyProxyClientSocket::OnResponseHeadersReceived( | 444 int SpdyProxyClientSocket::OnResponseHeadersUpdated( |
445 const SpdyHeaderBlock& response, | 445 const SpdyHeaderBlock& response_headers) { |
446 base::Time response_time, | |
447 int status) { | |
448 // If we've already received the reply, existing headers are too late. | 446 // If we've already received the reply, existing headers are too late. |
449 // TODO(mbelshe): figure out a way to make HEADERS frames useful after the | 447 // TODO(mbelshe): figure out a way to make HEADERS frames useful after the |
450 // initial response. | 448 // initial response. |
451 if (next_state_ != STATE_READ_REPLY_COMPLETE) | 449 if (next_state_ != STATE_READ_REPLY_COMPLETE) |
452 return OK; | 450 return OK; |
453 | 451 |
454 // Save the response | 452 // Save the response |
455 if (!SpdyHeadersToHttpResponse( | 453 if (!SpdyHeadersToHttpResponse( |
456 response, spdy_stream_->GetProtocolVersion(), &response_)) | 454 response_headers, spdy_stream_->GetProtocolVersion(), &response_)) |
457 return ERR_INCOMPLETE_SPDY_HEADERS; | 455 return ERR_INCOMPLETE_SPDY_HEADERS; |
458 | 456 |
459 OnIOComplete(status); | 457 OnIOComplete(OK); |
460 return OK; | 458 return OK; |
461 } | 459 } |
462 | 460 |
463 // Called when data is received or on EOF (if |buffer| is NULL). | 461 // Called when data is received or on EOF (if |buffer| is NULL). |
464 int SpdyProxyClientSocket::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) { | 462 int SpdyProxyClientSocket::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) { |
465 if (buffer) { | 463 if (buffer) { |
466 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, | 464 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, |
467 buffer->GetRemainingSize(), | 465 buffer->GetRemainingSize(), |
468 buffer->GetRemainingData()); | 466 buffer->GetRemainingData()); |
469 read_buffer_queue_.Enqueue(buffer.Pass()); | 467 read_buffer_queue_.Enqueue(buffer.Pass()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 } else if (!read_callback_.is_null()) { | 514 } else if (!read_callback_.is_null()) { |
517 // If we have a read_callback_, the we need to make sure we call it back. | 515 // If we have a read_callback_, the we need to make sure we call it back. |
518 OnDataReceived(scoped_ptr<SpdyBuffer>()); | 516 OnDataReceived(scoped_ptr<SpdyBuffer>()); |
519 } | 517 } |
520 // This may have been deleted by read_callback_, so check first. | 518 // This may have been deleted by read_callback_, so check first. |
521 if (weak_ptr.get() && !write_callback.is_null()) | 519 if (weak_ptr.get() && !write_callback.is_null()) |
522 write_callback.Run(ERR_CONNECTION_CLOSED); | 520 write_callback.Run(ERR_CONNECTION_CLOSED); |
523 } | 521 } |
524 | 522 |
525 } // namespace net | 523 } // namespace net |
OLD | NEW |