OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_flow_controller.h" | 5 #include "net/quic/quic_flow_controller.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "net/quic/quic_connection.h" | 8 #include "net/quic/quic_connection.h" |
9 #include "net/quic/quic_flags.h" | 9 #include "net/quic/quic_flags.h" |
10 #include "net/quic/quic_protocol.h" | 10 #include "net/quic/quic_protocol.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 return true; | 85 return true; |
86 } | 86 } |
87 return false; | 87 return false; |
88 } | 88 } |
89 | 89 |
90 void QuicFlowController::MaybeSendWindowUpdate() { | 90 void QuicFlowController::MaybeSendWindowUpdate() { |
91 // Send WindowUpdate to increase receive window if | 91 // Send WindowUpdate to increase receive window if |
92 // (receive window offset - consumed bytes) < (max window / 2). | 92 // (receive window offset - consumed bytes) < (max window / 2). |
93 // This is behaviour copied from SPDY. | 93 // This is behaviour copied from SPDY. |
94 DCHECK_LT(bytes_consumed_, receive_window_offset_); | 94 DCHECK_LT(bytes_consumed_, receive_window_offset_); |
95 QuicStreamOffset consumed_window = receive_window_offset_ - bytes_consumed_; | 95 QuicStreamOffset available_window = receive_window_offset_ - bytes_consumed_; |
96 QuicByteCount threshold = (max_receive_window_ / 2); | 96 QuicByteCount threshold = (max_receive_window_ / 2); |
97 | 97 |
98 if (consumed_window < threshold) { | 98 if (available_window < threshold) { |
99 // Update our receive window. | 99 // Update our receive window. |
100 receive_window_offset_ += (max_receive_window_ - consumed_window); | 100 receive_window_offset_ += (max_receive_window_ - available_window); |
101 | 101 |
102 DVLOG(1) << ENDPOINT << "Sending WindowUpdate frame for stream " << id_ | 102 DVLOG(1) << ENDPOINT << "Sending WindowUpdate frame for stream " << id_ |
103 << ", consumed bytes: " << bytes_consumed_ | 103 << ", consumed bytes: " << bytes_consumed_ |
104 << ", consumed window: " << consumed_window | 104 << ", available window: " << available_window |
105 << ", and threshold: " << threshold | 105 << ", and threshold: " << threshold |
106 << ", and max recvw: " << max_receive_window_ | 106 << ", and max recvw: " << max_receive_window_ |
107 << ". New receive window offset is: " << receive_window_offset_; | 107 << ". New receive window offset is: " << receive_window_offset_; |
108 | 108 |
109 // Inform the peer of our new receive window. | 109 // Inform the peer of our new receive window. |
110 connection_->SendWindowUpdate(id_, receive_window_offset_); | 110 connection_->SendWindowUpdate(id_, receive_window_offset_); |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 void QuicFlowController::MaybeSendBlocked() { | 114 void QuicFlowController::MaybeSendBlocked() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 150 } |
151 | 151 |
152 uint64 QuicFlowController::SendWindowSize() const { | 152 uint64 QuicFlowController::SendWindowSize() const { |
153 if (bytes_sent_ > send_window_offset_) { | 153 if (bytes_sent_ > send_window_offset_) { |
154 return 0; | 154 return 0; |
155 } | 155 } |
156 return send_window_offset_ - bytes_sent_; | 156 return send_window_offset_ - bytes_sent_; |
157 } | 157 } |
158 | 158 |
159 } // namespace net | 159 } // namespace net |
OLD | NEW |