Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Side by Side Diff: net/quic/reliable_quic_stream.cc

Issue 327393002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/reliable_quic_stream.h ('k') | net/quic/reliable_quic_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "net/quic/iovector.h" 8 #include "net/quic/iovector.h"
9 #include "net/quic/quic_flow_controller.h" 9 #include "net/quic/quic_flow_controller.h"
10 #include "net/quic/quic_session.h" 10 #include "net/quic/quic_session.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 void WroteData(bool last_data) { 73 void WroteData(bool last_data) {
74 DCHECK(!wrote_last_data_); 74 DCHECK(!wrote_last_data_);
75 ++pending_acks_; 75 ++pending_acks_;
76 wrote_last_data_ = last_data; 76 wrote_last_data_ = last_data;
77 } 77 }
78 78
79 protected: 79 protected:
80 // Delegates are ref counted. 80 // Delegates are ref counted.
81 virtual ~ProxyAckNotifierDelegate() { 81 virtual ~ProxyAckNotifierDelegate() OVERRIDE {
82 } 82 }
83 83
84 private: 84 private:
85 // Original delegate. delegate_->OnAckNotification will be called when: 85 // Original delegate. delegate_->OnAckNotification will be called when:
86 // wrote_last_data_ == true and pending_acks_ == 0 86 // wrote_last_data_ == true and pending_acks_ == 0
87 scoped_refptr<DelegateInterface> delegate_; 87 scoped_refptr<DelegateInterface> delegate_;
88 88
89 // Number of outstanding acks. 89 // Number of outstanding acks.
90 int pending_acks_; 90 int pending_acks_;
91 91
(...skipping 22 matching lines...) Expand all
114 id_(id), 114 id_(id),
115 session_(session), 115 session_(session),
116 stream_bytes_read_(0), 116 stream_bytes_read_(0),
117 stream_bytes_written_(0), 117 stream_bytes_written_(0),
118 stream_error_(QUIC_STREAM_NO_ERROR), 118 stream_error_(QUIC_STREAM_NO_ERROR),
119 connection_error_(QUIC_NO_ERROR), 119 connection_error_(QUIC_NO_ERROR),
120 read_side_closed_(false), 120 read_side_closed_(false),
121 write_side_closed_(false), 121 write_side_closed_(false),
122 fin_buffered_(false), 122 fin_buffered_(false),
123 fin_sent_(false), 123 fin_sent_(false),
124 fin_received_(false),
124 rst_sent_(false), 125 rst_sent_(false),
126 rst_received_(false),
125 is_server_(session_->is_server()), 127 is_server_(session_->is_server()),
126 flow_controller_( 128 flow_controller_(
127 session_->connection(), 129 session_->connection(),
128 id_, 130 id_,
129 is_server_, 131 is_server_,
130 session_->config()->HasReceivedInitialFlowControlWindowBytes() ? 132 session_->config()->HasReceivedInitialFlowControlWindowBytes() ?
131 session_->config()->ReceivedInitialFlowControlWindowBytes() : 133 session_->config()->ReceivedInitialFlowControlWindowBytes() :
132 kDefaultFlowControlSendWindow, 134 kDefaultFlowControlSendWindow,
133 session_->max_flow_control_receive_window_bytes(), 135 session_->max_flow_control_receive_window_bytes(),
134 session_->max_flow_control_receive_window_bytes()), 136 session_->max_flow_control_receive_window_bytes()),
135 connection_flow_controller_(session_->flow_controller()) { 137 connection_flow_controller_(session_->flow_controller()) {
136 } 138 }
137 139
138 ReliableQuicStream::~ReliableQuicStream() { 140 ReliableQuicStream::~ReliableQuicStream() {
139 } 141 }
140 142
141 bool ReliableQuicStream::OnStreamFrame(const QuicStreamFrame& frame) { 143 bool ReliableQuicStream::OnStreamFrame(const QuicStreamFrame& frame) {
142 if (read_side_closed_) { 144 if (read_side_closed_) {
143 DVLOG(1) << ENDPOINT << "Ignoring frame " << frame.stream_id; 145 DVLOG(1) << ENDPOINT << "Ignoring frame " << frame.stream_id;
144 // We don't want to be reading: blackhole the data. 146 // We don't want to be reading: blackhole the data.
145 return true; 147 return true;
146 } 148 }
147 149
148 if (frame.stream_id != id_) { 150 if (frame.stream_id != id_) {
149 LOG(ERROR) << "Error!"; 151 LOG(ERROR) << "Error!";
150 return false; 152 return false;
151 } 153 }
152 154
155 if (frame.fin) {
156 fin_received_ = true;
157 }
158
153 // This count include duplicate data received. 159 // This count include duplicate data received.
154 size_t frame_payload_size = frame.data.TotalBufferSize(); 160 size_t frame_payload_size = frame.data.TotalBufferSize();
155 stream_bytes_read_ += frame_payload_size; 161 stream_bytes_read_ += frame_payload_size;
156 162
157 // Flow control is interested in tracking highest received offset. 163 // Flow control is interested in tracking highest received offset.
158 if (MaybeIncreaseHighestReceivedOffset(frame.offset + frame_payload_size)) { 164 if (MaybeIncreaseHighestReceivedOffset(frame.offset + frame_payload_size)) {
159 // As the highest received offset has changed, we should check to see if 165 // As the highest received offset has changed, we should check to see if
160 // this is a violation of flow control. 166 // this is a violation of flow control.
161 if (flow_controller_.FlowControlViolation() || 167 if (flow_controller_.FlowControlViolation() ||
162 connection_flow_controller_->FlowControlViolation()) { 168 connection_flow_controller_->FlowControlViolation()) {
163 session_->connection()->SendConnectionClose( 169 session_->connection()->SendConnectionClose(
164 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA); 170 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA);
165 return false; 171 return false;
166 } 172 }
167 } 173 }
168 174
169 return sequencer_.OnStreamFrame(frame); 175 return sequencer_.OnStreamFrame(frame);
170 } 176 }
171 177
172 int ReliableQuicStream::num_frames_received() const { 178 int ReliableQuicStream::num_frames_received() const {
173 return sequencer_.num_frames_received(); 179 return sequencer_.num_frames_received();
174 } 180 }
175 181
176 int ReliableQuicStream::num_duplicate_frames_received() const { 182 int ReliableQuicStream::num_duplicate_frames_received() const {
177 return sequencer_.num_duplicate_frames_received(); 183 return sequencer_.num_duplicate_frames_received();
178 } 184 }
179 185
180 void ReliableQuicStream::OnStreamReset(const QuicRstStreamFrame& frame) { 186 void ReliableQuicStream::OnStreamReset(const QuicRstStreamFrame& frame) {
187 rst_received_ = true;
181 MaybeIncreaseHighestReceivedOffset(frame.byte_offset); 188 MaybeIncreaseHighestReceivedOffset(frame.byte_offset);
182 189
183 stream_error_ = frame.error_code; 190 stream_error_ = frame.error_code;
184 CloseWriteSide(); 191 CloseWriteSide();
185 CloseReadSide(); 192 CloseReadSide();
186 } 193 }
187 194
188 void ReliableQuicStream::OnConnectionClosed(QuicErrorCode error, 195 void ReliableQuicStream::OnConnectionClosed(QuicErrorCode error,
189 bool from_peer) { 196 bool from_peer) {
190 if (read_side_closed_ && write_side_closed_) { 197 if (read_side_closed_ && write_side_closed_) {
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 connection_flow_controller_->AddBytesConsumed(bytes); 486 connection_flow_controller_->AddBytesConsumed(bytes);
480 } 487 }
481 } 488 }
482 489
483 bool ReliableQuicStream::IsFlowControlBlocked() { 490 bool ReliableQuicStream::IsFlowControlBlocked() {
484 return flow_controller_.IsBlocked() || 491 return flow_controller_.IsBlocked() ||
485 connection_flow_controller_->IsBlocked(); 492 connection_flow_controller_->IsBlocked();
486 } 493 }
487 494
488 } // namespace net 495 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/reliable_quic_stream.h ('k') | net/quic/reliable_quic_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698