| 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/quic_stream_sequencer.h" | 5 #include "net/quic/quic_stream_sequencer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 num_duplicate_frames_received_(0), | 35 num_duplicate_frames_received_(0), |
| 36 num_early_frames_received_(0), | 36 num_early_frames_received_(0), |
| 37 clock_(clock), | 37 clock_(clock), |
| 38 ignore_read_data_(false) {} | 38 ignore_read_data_(false) {} |
| 39 | 39 |
| 40 QuicStreamSequencer::~QuicStreamSequencer() {} | 40 QuicStreamSequencer::~QuicStreamSequencer() {} |
| 41 | 41 |
| 42 void QuicStreamSequencer::OnStreamFrame(const QuicStreamFrame& frame) { | 42 void QuicStreamSequencer::OnStreamFrame(const QuicStreamFrame& frame) { |
| 43 ++num_frames_received_; | 43 ++num_frames_received_; |
| 44 const QuicStreamOffset byte_offset = frame.offset; | 44 const QuicStreamOffset byte_offset = frame.offset; |
| 45 const size_t data_len = frame.frame_length; | 45 const size_t data_len = frame.data_length; |
| 46 | 46 |
| 47 if (frame.fin) { | 47 if (frame.fin) { |
| 48 CloseStreamAtOffset(frame.offset + data_len); | 48 CloseStreamAtOffset(frame.offset + data_len); |
| 49 if (data_len == 0) { | 49 if (data_len == 0) { |
| 50 return; | 50 return; |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 size_t bytes_written; | 53 size_t bytes_written; |
| 54 string error_details; | 54 string error_details; |
| 55 QuicErrorCode result = buffered_frames_.OnStreamData( | 55 QuicErrorCode result = buffered_frames_.OnStreamData( |
| 56 byte_offset, StringPiece(frame.frame_buffer, frame.frame_length), | 56 byte_offset, StringPiece(frame.data_buffer, frame.data_length), |
| 57 clock_->ApproximateNow(), &bytes_written, &error_details); | 57 clock_->ApproximateNow(), &bytes_written, &error_details); |
| 58 if (result != QUIC_NO_ERROR) { | 58 if (result != QUIC_NO_ERROR) { |
| 59 DLOG(WARNING) << QuicUtils::ErrorToString(result); | 59 DLOG(WARNING) << QuicUtils::ErrorToString(result); |
| 60 DLOG(WARNING) << error_details; | 60 DLOG(WARNING) << error_details; |
| 61 stream_->CloseConnectionWithDetails(result, error_details); | 61 stream_->CloseConnectionWithDetails(result, error_details); |
| 62 return; | 62 return; |
| 63 } | 63 } |
| 64 | 64 |
| 65 if (bytes_written == 0) { | 65 if (bytes_written == 0) { |
| 66 ++num_duplicate_frames_received_; | 66 ++num_duplicate_frames_received_; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 191 |
| 192 size_t QuicStreamSequencer::NumBytesBuffered() const { | 192 size_t QuicStreamSequencer::NumBytesBuffered() const { |
| 193 return buffered_frames_.BytesBuffered(); | 193 return buffered_frames_.BytesBuffered(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 QuicStreamOffset QuicStreamSequencer::NumBytesConsumed() const { | 196 QuicStreamOffset QuicStreamSequencer::NumBytesConsumed() const { |
| 197 return buffered_frames_.BytesConsumed(); | 197 return buffered_frames_.BytesConsumed(); |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace net | 200 } // namespace net |
| OLD | NEW |