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 "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" |
11 #include "net/quic/quic_write_blocked_list.h" | 11 #include "net/quic/quic_write_blocked_list.h" |
12 | 12 |
13 using base::StringPiece; | 13 using base::StringPiece; |
14 using std::min; | 14 using std::min; |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 #define ENDPOINT (is_server_ ? "Server: " : " Client: ") | 18 #define ENDPOINT (is_server_ ? "Server: " : " Client: ") |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 struct iovec MakeIovec(StringPiece data) { | 22 struct iovec MakeIovec(StringPiece data) { |
23 struct iovec iov = {const_cast<char*>(data.data()), | 23 struct iovec iov = {const_cast<char*>(data.data()), |
24 static_cast<size_t>(data.size())}; | 24 static_cast<size_t>(data.size())}; |
25 return iov; | 25 return iov; |
26 } | 26 } |
27 | 27 |
| 28 size_t GetInitialStreamFlowControlWindowToSend(QuicSession* session) { |
| 29 QuicVersion version = session->connection()->version(); |
| 30 if (version <= QUIC_VERSION_19) { |
| 31 return session->config()->GetInitialFlowControlWindowToSend(); |
| 32 } |
| 33 |
| 34 return session->config()->GetInitialStreamFlowControlWindowToSend(); |
| 35 } |
| 36 |
| 37 size_t GetReceivedFlowControlWindow(QuicSession* session) { |
| 38 QuicVersion version = session->connection()->version(); |
| 39 if (version <= QUIC_VERSION_19) { |
| 40 if (session->config()->HasReceivedInitialFlowControlWindowBytes()) { |
| 41 return session->config()->ReceivedInitialFlowControlWindowBytes(); |
| 42 } |
| 43 |
| 44 return kDefaultFlowControlSendWindow; |
| 45 } |
| 46 |
| 47 // Version must be >= QUIC_VERSION_20, so we check for stream specific flow |
| 48 // control window. |
| 49 if (session->config()->HasReceivedInitialStreamFlowControlWindowBytes()) { |
| 50 return session->config()->ReceivedInitialStreamFlowControlWindowBytes(); |
| 51 } |
| 52 |
| 53 return kDefaultFlowControlSendWindow; |
| 54 } |
| 55 |
28 } // namespace | 56 } // namespace |
29 | 57 |
30 // Wrapper that aggregates OnAckNotifications for packets sent using | 58 // Wrapper that aggregates OnAckNotifications for packets sent using |
31 // WriteOrBufferData and delivers them to the original | 59 // WriteOrBufferData and delivers them to the original |
32 // QuicAckNotifier::DelegateInterface after all bytes written using | 60 // QuicAckNotifier::DelegateInterface after all bytes written using |
33 // WriteOrBufferData are acked. This level of indirection is | 61 // WriteOrBufferData are acked. This level of indirection is |
34 // necessary because the delegate interface provides no mechanism that | 62 // necessary because the delegate interface provides no mechanism that |
35 // WriteOrBufferData can use to inform it that the write required | 63 // WriteOrBufferData can use to inform it that the write required |
36 // multiple WritevData calls or that only part of the data has been | 64 // multiple WritevData calls or that only part of the data has been |
37 // sent out by the time ACKs start arriving. | 65 // sent out by the time ACKs start arriving. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 read_side_closed_(false), | 148 read_side_closed_(false), |
121 write_side_closed_(false), | 149 write_side_closed_(false), |
122 fin_buffered_(false), | 150 fin_buffered_(false), |
123 fin_sent_(false), | 151 fin_sent_(false), |
124 fin_received_(false), | 152 fin_received_(false), |
125 rst_sent_(false), | 153 rst_sent_(false), |
126 rst_received_(false), | 154 rst_received_(false), |
127 fec_policy_(FEC_PROTECT_OPTIONAL), | 155 fec_policy_(FEC_PROTECT_OPTIONAL), |
128 is_server_(session_->is_server()), | 156 is_server_(session_->is_server()), |
129 flow_controller_( | 157 flow_controller_( |
130 session_->connection(), | 158 session_->connection(), id_, is_server_, |
131 id_, | 159 GetReceivedFlowControlWindow(session), |
132 is_server_, | 160 GetInitialStreamFlowControlWindowToSend(session), |
133 session_->config()->HasReceivedInitialFlowControlWindowBytes() ? | 161 GetInitialStreamFlowControlWindowToSend(session)), |
134 session_->config()->ReceivedInitialFlowControlWindowBytes() : | |
135 kDefaultFlowControlSendWindow, | |
136 session_->config()->GetInitialFlowControlWindowToSend(), | |
137 session_->config()->GetInitialFlowControlWindowToSend()), | |
138 connection_flow_controller_(session_->flow_controller()) { | 162 connection_flow_controller_(session_->flow_controller()) { |
139 } | 163 } |
140 | 164 |
141 ReliableQuicStream::~ReliableQuicStream() { | 165 ReliableQuicStream::~ReliableQuicStream() { |
142 } | 166 } |
143 | 167 |
144 bool ReliableQuicStream::OnStreamFrame(const QuicStreamFrame& frame) { | 168 bool ReliableQuicStream::OnStreamFrame(const QuicStreamFrame& frame) { |
145 if (read_side_closed_) { | 169 if (read_side_closed_) { |
146 DVLOG(1) << ENDPOINT << "Ignoring frame " << frame.stream_id; | 170 DVLOG(1) << ENDPOINT << "Ignoring frame " << frame.stream_id; |
147 // We don't want to be reading: blackhole the data. | 171 // We don't want to be reading: blackhole the data. |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 connection_flow_controller_->AddBytesConsumed(bytes); | 516 connection_flow_controller_->AddBytesConsumed(bytes); |
493 } | 517 } |
494 } | 518 } |
495 | 519 |
496 bool ReliableQuicStream::IsFlowControlBlocked() { | 520 bool ReliableQuicStream::IsFlowControlBlocked() { |
497 return flow_controller_.IsBlocked() || | 521 return flow_controller_.IsBlocked() || |
498 connection_flow_controller_->IsBlocked(); | 522 connection_flow_controller_->IsBlocked(); |
499 } | 523 } |
500 | 524 |
501 } // namespace net | 525 } // namespace net |
OLD | NEW |