| 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/quic/reliable_quic_stream.h" | 5 #include "net/quic/reliable_quic_stream.h" |
| 6 | 6 |
| 7 #include "net/quic/quic_session.h" | 7 #include "net/quic/quic_session.h" |
| 8 #include "net/quic/quic_spdy_decompressor.h" | 8 #include "net/quic/quic_spdy_decompressor.h" |
| 9 | 9 |
| 10 using base::StringPiece; | 10 using base::StringPiece; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 CloseWriteSide(); | 91 CloseWriteSide(); |
| 92 } | 92 } |
| 93 CloseReadSide(); | 93 CloseReadSide(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void ReliableQuicStream::Close(QuicRstStreamErrorCode error) { | 96 void ReliableQuicStream::Close(QuicRstStreamErrorCode error) { |
| 97 stream_error_ = error; | 97 stream_error_ = error; |
| 98 session()->SendRstStream(id(), error); | 98 session()->SendRstStream(id(), error); |
| 99 } | 99 } |
| 100 | 100 |
| 101 int ReliableQuicStream::Readv(const struct iovec* iov, int iov_len) { | 101 int ReliableQuicStream::Readv(const struct iovec* iov, size_t iov_len) { |
| 102 if (headers_decompressed_ && decompressed_headers_.empty()) { | 102 if (headers_decompressed_ && decompressed_headers_.empty()) { |
| 103 return sequencer_.Readv(iov, iov_len); | 103 return sequencer_.Readv(iov, iov_len); |
| 104 } | 104 } |
| 105 size_t bytes_consumed = 0; | 105 size_t bytes_consumed = 0; |
| 106 int iov_index = 0; | 106 size_t iov_index = 0; |
| 107 while (iov_index < iov_len && | 107 while (iov_index < iov_len && |
| 108 decompressed_headers_.length() > bytes_consumed) { | 108 decompressed_headers_.length() > bytes_consumed) { |
| 109 int bytes_to_read = min(iov[iov_index].iov_len, | 109 int bytes_to_read = min(iov[iov_index].iov_len, |
| 110 decompressed_headers_.length() - bytes_consumed); | 110 decompressed_headers_.length() - bytes_consumed); |
| 111 char* iov_ptr = static_cast<char*>(iov[iov_index].iov_base); | 111 char* iov_ptr = static_cast<char*>(iov[iov_index].iov_base); |
| 112 memcpy(iov_ptr, | 112 memcpy(iov_ptr, |
| 113 decompressed_headers_.data() + bytes_consumed, bytes_to_read); | 113 decompressed_headers_.data() + bytes_consumed, bytes_to_read); |
| 114 bytes_consumed += bytes_to_read; | 114 bytes_consumed += bytes_to_read; |
| 115 ++iov_index; | 115 ++iov_index; |
| 116 } | 116 } |
| 117 decompressed_headers_.erase(0, bytes_consumed); | 117 decompressed_headers_.erase(0, bytes_consumed); |
| 118 return bytes_consumed; | 118 return bytes_consumed; |
| 119 } | 119 } |
| 120 | 120 |
| 121 int ReliableQuicStream::GetReadableRegions(iovec* iov, int iov_len) { | 121 int ReliableQuicStream::GetReadableRegions(iovec* iov, size_t iov_len) { |
| 122 if (headers_decompressed_ && decompressed_headers_.empty()) { | 122 if (headers_decompressed_ && decompressed_headers_.empty()) { |
| 123 return sequencer_.GetReadableRegions(iov, iov_len); | 123 return sequencer_.GetReadableRegions(iov, iov_len); |
| 124 } | 124 } |
| 125 if (iov_len == 0) { | 125 if (iov_len == 0) { |
| 126 return 0; | 126 return 0; |
| 127 } | 127 } |
| 128 iov[0].iov_base = static_cast<void*>( | 128 iov[0].iov_base = static_cast<void*>( |
| 129 const_cast<char*>(decompressed_headers_.data())); | 129 const_cast<char*>(decompressed_headers_.data())); |
| 130 iov[0].iov_len = decompressed_headers_.length(); | 130 iov[0].iov_len = decompressed_headers_.length(); |
| 131 return 1; | 131 return 1; |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 if (visitor_) { | 394 if (visitor_) { |
| 395 Visitor* visitor = visitor_; | 395 Visitor* visitor = visitor_; |
| 396 // Calling Visitor::OnClose() may result the destruction of the visitor, | 396 // Calling Visitor::OnClose() may result the destruction of the visitor, |
| 397 // so we need to ensure we don't call it again. | 397 // so we need to ensure we don't call it again. |
| 398 visitor_ = NULL; | 398 visitor_ = NULL; |
| 399 visitor->OnClose(this); | 399 visitor->OnClose(this); |
| 400 } | 400 } |
| 401 } | 401 } |
| 402 | 402 |
| 403 } // namespace net | 403 } // namespace net |
| OLD | NEW |