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 using std::string; | 15 using std::string; |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 #define ENDPOINT (is_server_ ? "Server: " : " Client: ") | 19 #define ENDPOINT (is_server_ ? "Server: " : " Client: ") |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 struct iovec MakeIovec(StringPiece data) { | 23 struct iovec MakeIovec(StringPiece data) { |
24 struct iovec iov = {const_cast<char*>(data.data()), | 24 struct iovec iov = {const_cast<char*>(data.data()), |
25 static_cast<size_t>(data.size())}; | 25 static_cast<size_t>(data.size())}; |
26 return iov; | 26 return iov; |
27 } | 27 } |
28 | 28 |
29 size_t GetInitialStreamFlowControlWindowToSend(QuicSession* session) { | 29 size_t GetInitialStreamFlowControlWindowToSend(QuicSession* session) { |
30 QuicVersion version = session->connection()->version(); | |
31 if (version <= QUIC_VERSION_19) { | |
32 return session->config()->GetInitialFlowControlWindowToSend(); | |
33 } | |
34 | |
35 return session->config()->GetInitialStreamFlowControlWindowToSend(); | 30 return session->config()->GetInitialStreamFlowControlWindowToSend(); |
36 } | 31 } |
37 | 32 |
38 size_t GetReceivedFlowControlWindow(QuicSession* session) { | 33 size_t GetReceivedFlowControlWindow(QuicSession* session) { |
39 QuicVersion version = session->connection()->version(); | |
40 if (version <= QUIC_VERSION_19) { | |
41 if (session->config()->HasReceivedInitialFlowControlWindowBytes()) { | |
42 return session->config()->ReceivedInitialFlowControlWindowBytes(); | |
43 } | |
44 | |
45 return kMinimumFlowControlSendWindow; | |
46 } | |
47 | |
48 // Version must be >= QUIC_VERSION_21, so we check for stream specific flow | |
49 // control window. | |
50 if (session->config()->HasReceivedInitialStreamFlowControlWindowBytes()) { | 34 if (session->config()->HasReceivedInitialStreamFlowControlWindowBytes()) { |
51 return session->config()->ReceivedInitialStreamFlowControlWindowBytes(); | 35 return session->config()->ReceivedInitialStreamFlowControlWindowBytes(); |
52 } | 36 } |
53 | 37 |
54 return kMinimumFlowControlSendWindow; | 38 return kMinimumFlowControlSendWindow; |
55 } | 39 } |
56 | 40 |
57 } // namespace | 41 } // namespace |
58 | 42 |
59 // Wrapper that aggregates OnAckNotifications for packets sent using | 43 // Wrapper that aggregates OnAckNotifications for packets sent using |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 342 |
359 // How much data we want to write. | 343 // How much data we want to write. |
360 size_t write_length = TotalIovecLength(iov, iov_count); | 344 size_t write_length = TotalIovecLength(iov, iov_count); |
361 | 345 |
362 // A FIN with zero data payload should not be flow control blocked. | 346 // A FIN with zero data payload should not be flow control blocked. |
363 bool fin_with_zero_data = (fin && write_length == 0); | 347 bool fin_with_zero_data = (fin && write_length == 0); |
364 | 348 |
365 if (flow_controller_.IsEnabled()) { | 349 if (flow_controller_.IsEnabled()) { |
366 // How much data we are allowed to write from flow control. | 350 // How much data we are allowed to write from flow control. |
367 QuicByteCount send_window = flow_controller_.SendWindowSize(); | 351 QuicByteCount send_window = flow_controller_.SendWindowSize(); |
368 // TODO(rjshade): Remove connection_flow_controller_->IsEnabled() check when | 352 if (stream_contributes_to_connection_flow_control_) { |
369 // removing QUIC_VERSION_19. | |
370 if (stream_contributes_to_connection_flow_control_ && | |
371 connection_flow_controller_->IsEnabled()) { | |
372 send_window = | 353 send_window = |
373 min(send_window, connection_flow_controller_->SendWindowSize()); | 354 min(send_window, connection_flow_controller_->SendWindowSize()); |
374 } | 355 } |
375 | 356 |
376 if (send_window == 0 && !fin_with_zero_data) { | 357 if (send_window == 0 && !fin_with_zero_data) { |
377 // Quick return if we can't send anything. | 358 // Quick return if we can't send anything. |
378 MaybeSendBlocked(); | 359 MaybeSendBlocked(); |
379 return QuicConsumedData(0, false); | 360 return QuicConsumedData(0, false); |
380 } | 361 } |
381 | 362 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 | 522 |
542 bool ReliableQuicStream::IsFlowControlBlocked() { | 523 bool ReliableQuicStream::IsFlowControlBlocked() { |
543 if (flow_controller_.IsBlocked()) { | 524 if (flow_controller_.IsBlocked()) { |
544 return true; | 525 return true; |
545 } | 526 } |
546 return stream_contributes_to_connection_flow_control_ && | 527 return stream_contributes_to_connection_flow_control_ && |
547 connection_flow_controller_->IsBlocked(); | 528 connection_flow_controller_->IsBlocked(); |
548 } | 529 } |
549 | 530 |
550 } // namespace net | 531 } // namespace net |
OLD | NEW |