| 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_stream.h" | 5 #include "net/spdy/spdy_stream.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 // May close the stream. | 583 // May close the stream. |
| 584 DecreaseRecvWindowSize(static_cast<int32_t>(len)); | 584 DecreaseRecvWindowSize(static_cast<int32_t>(len)); |
| 585 if (!weak_this) | 585 if (!weak_this) |
| 586 return; | 586 return; |
| 587 IncreaseRecvWindowSize(static_cast<int32_t>(len)); | 587 IncreaseRecvWindowSize(static_cast<int32_t>(len)); |
| 588 } | 588 } |
| 589 | 589 |
| 590 void SpdyStream::OnFrameWriteComplete(SpdyFrameType frame_type, | 590 void SpdyStream::OnFrameWriteComplete(SpdyFrameType frame_type, |
| 591 size_t frame_size) { | 591 size_t frame_size) { |
| 592 DCHECK_NE(type_, SPDY_PUSH_STREAM); | 592 DCHECK_NE(type_, SPDY_PUSH_STREAM); |
| 593 CHECK(frame_type == HEADERS || frame_type == DATA) << frame_type; | 593 CHECK(frame_type == HEADERS || frame_type == DATA); |
| 594 | 594 |
| 595 int result = | 595 int result = |
| 596 (frame_type == HEADERS) ? OnHeadersSent() : OnDataSent(frame_size); | 596 (frame_type == HEADERS) ? OnHeadersSent() : OnDataSent(frame_size); |
| 597 if (result == ERR_IO_PENDING) { | 597 if (result == ERR_IO_PENDING) { |
| 598 // The write operation hasn't completed yet. | 598 // The write operation hasn't completed yet. |
| 599 return; | 599 return; |
| 600 } | 600 } |
| 601 | 601 |
| 602 if (pending_send_status_ == NO_MORE_DATA_TO_SEND) { | 602 if (pending_send_status_ == NO_MORE_DATA_TO_SEND) { |
| 603 if (io_state_ == STATE_OPEN) { | 603 if (io_state_ == STATE_OPEN) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 630 | 630 |
| 631 int SpdyStream::OnHeadersSent() { | 631 int SpdyStream::OnHeadersSent() { |
| 632 CHECK_EQ(io_state_, STATE_IDLE); | 632 CHECK_EQ(io_state_, STATE_IDLE); |
| 633 CHECK_NE(stream_id_, 0u); | 633 CHECK_NE(stream_id_, 0u); |
| 634 | 634 |
| 635 io_state_ = STATE_OPEN; | 635 io_state_ = STATE_OPEN; |
| 636 return OK; | 636 return OK; |
| 637 } | 637 } |
| 638 | 638 |
| 639 int SpdyStream::OnDataSent(size_t frame_size) { | 639 int SpdyStream::OnDataSent(size_t frame_size) { |
| 640 CHECK(io_state_ == STATE_OPEN || | 640 CHECK(io_state_ == STATE_OPEN || io_state_ == STATE_HALF_CLOSED_REMOTE); |
| 641 io_state_ == STATE_HALF_CLOSED_REMOTE) << io_state_; | |
| 642 | 641 |
| 643 size_t frame_payload_size = frame_size - session_->GetDataFrameMinimumSize(); | 642 size_t frame_payload_size = frame_size - session_->GetDataFrameMinimumSize(); |
| 644 | 643 |
| 645 CHECK_GE(frame_size, session_->GetDataFrameMinimumSize()); | 644 CHECK_GE(frame_size, session_->GetDataFrameMinimumSize()); |
| 646 CHECK_LE(frame_payload_size, session_->GetDataFrameMaximumPayload()); | 645 CHECK_LE(frame_payload_size, session_->GetDataFrameMaximumPayload()); |
| 647 | 646 |
| 648 send_bytes_ += frame_payload_size; | 647 send_bytes_ += frame_payload_size; |
| 649 | 648 |
| 650 // If more data is available to send, dispatch it and | 649 // If more data is available to send, dispatch it and |
| 651 // return that the write operation is still ongoing. | 650 // return that the write operation is still ongoing. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 std::unique_ptr<SpdyBufferProducer>( | 729 std::unique_ptr<SpdyBufferProducer>( |
| 731 new HeadersBufferProducer(GetWeakPtr()))); | 730 new HeadersBufferProducer(GetWeakPtr()))); |
| 732 return ERR_IO_PENDING; | 731 return ERR_IO_PENDING; |
| 733 } | 732 } |
| 734 | 733 |
| 735 void SpdyStream::SendData(IOBuffer* data, | 734 void SpdyStream::SendData(IOBuffer* data, |
| 736 int length, | 735 int length, |
| 737 SpdySendStatus send_status) { | 736 SpdySendStatus send_status) { |
| 738 CHECK_NE(type_, SPDY_PUSH_STREAM); | 737 CHECK_NE(type_, SPDY_PUSH_STREAM); |
| 739 CHECK_EQ(pending_send_status_, MORE_DATA_TO_SEND); | 738 CHECK_EQ(pending_send_status_, MORE_DATA_TO_SEND); |
| 740 CHECK(io_state_ == STATE_OPEN || | 739 CHECK(io_state_ == STATE_OPEN || io_state_ == STATE_HALF_CLOSED_REMOTE); |
| 741 io_state_ == STATE_HALF_CLOSED_REMOTE) << io_state_; | |
| 742 CHECK(!pending_send_data_.get()); | 740 CHECK(!pending_send_data_.get()); |
| 743 pending_send_data_ = new DrainableIOBuffer(data, length); | 741 pending_send_data_ = new DrainableIOBuffer(data, length); |
| 744 pending_send_status_ = send_status; | 742 pending_send_status_ = send_status; |
| 745 QueueNextDataFrame(); | 743 QueueNextDataFrame(); |
| 746 } | 744 } |
| 747 | 745 |
| 748 bool SpdyStream::GetSSLInfo(SSLInfo* ssl_info) const { | 746 bool SpdyStream::GetSSLInfo(SSLInfo* ssl_info) const { |
| 749 return session_->GetSSLInfo(ssl_info); | 747 return session_->GetSSLInfo(ssl_info); |
| 750 } | 748 } |
| 751 | 749 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", | 838 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", |
| 841 recv_last_byte_time_ - effective_send_time); | 839 recv_last_byte_time_ - effective_send_time); |
| 842 | 840 |
| 843 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); | 841 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); |
| 844 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); | 842 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); |
| 845 } | 843 } |
| 846 | 844 |
| 847 void SpdyStream::QueueNextDataFrame() { | 845 void SpdyStream::QueueNextDataFrame() { |
| 848 // Until the request has been completely sent, we cannot be sure | 846 // Until the request has been completely sent, we cannot be sure |
| 849 // that our stream_id is correct. | 847 // that our stream_id is correct. |
| 850 CHECK(io_state_ == STATE_OPEN || | 848 CHECK(io_state_ == STATE_OPEN || io_state_ == STATE_HALF_CLOSED_REMOTE); |
| 851 io_state_ == STATE_HALF_CLOSED_REMOTE) << io_state_; | |
| 852 CHECK_GT(stream_id_, 0u); | 849 CHECK_GT(stream_id_, 0u); |
| 853 CHECK(pending_send_data_.get()); | 850 CHECK(pending_send_data_.get()); |
| 854 // Only the final fame may have a length of 0. | 851 // Only the final fame may have a length of 0. |
| 855 if (pending_send_status_ == NO_MORE_DATA_TO_SEND) { | 852 if (pending_send_status_ == NO_MORE_DATA_TO_SEND) { |
| 856 CHECK_GE(pending_send_data_->BytesRemaining(), 0); | 853 CHECK_GE(pending_send_data_->BytesRemaining(), 0); |
| 857 } else { | 854 } else { |
| 858 CHECK_GT(pending_send_data_->BytesRemaining(), 0); | 855 CHECK_GT(pending_send_data_->BytesRemaining(), 0); |
| 859 } | 856 } |
| 860 | 857 |
| 861 SpdyDataFlags flags = | 858 SpdyDataFlags flags = |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, | 932 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, |
| 936 state); | 933 state); |
| 937 break; | 934 break; |
| 938 } | 935 } |
| 939 return description; | 936 return description; |
| 940 } | 937 } |
| 941 | 938 |
| 942 #undef STATE_CASE | 939 #undef STATE_CASE |
| 943 | 940 |
| 944 } // namespace net | 941 } // namespace net |
| OLD | NEW |