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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 return false; | 156 return false; |
157 } | 157 } |
158 | 158 |
159 // Only update if send window has increased. | 159 // Only update if send window has increased. |
160 if (new_send_window_offset <= send_window_offset_) { | 160 if (new_send_window_offset <= send_window_offset_) { |
161 return false; | 161 return false; |
162 } | 162 } |
163 | 163 |
164 DVLOG(1) << ENDPOINT << "UpdateSendWindowOffset for stream " << id_ | 164 DVLOG(1) << ENDPOINT << "UpdateSendWindowOffset for stream " << id_ |
165 << " with new offset " << new_send_window_offset | 165 << " with new offset " << new_send_window_offset |
166 << " , current offset: " << send_window_offset_; | 166 << " current offset: " << send_window_offset_ |
| 167 << " bytes_sent: " << bytes_sent_; |
167 | 168 |
| 169 const bool blocked = IsBlocked(); |
168 send_window_offset_ = new_send_window_offset; | 170 send_window_offset_ = new_send_window_offset; |
169 return true; | 171 return blocked; |
170 } | 172 } |
171 | 173 |
172 void QuicFlowController::Disable() { | 174 void QuicFlowController::Disable() { |
173 is_enabled_ = false; | 175 is_enabled_ = false; |
174 } | 176 } |
175 | 177 |
176 bool QuicFlowController::IsEnabled() const { | 178 bool QuicFlowController::IsEnabled() const { |
177 return is_enabled_; | 179 return is_enabled_; |
178 } | 180 } |
179 | 181 |
180 bool QuicFlowController::IsBlocked() const { | 182 bool QuicFlowController::IsBlocked() const { |
181 return IsEnabled() && SendWindowSize() == 0; | 183 return IsEnabled() && SendWindowSize() == 0; |
182 } | 184 } |
183 | 185 |
184 uint64 QuicFlowController::SendWindowSize() const { | 186 uint64 QuicFlowController::SendWindowSize() const { |
185 if (bytes_sent_ > send_window_offset_) { | 187 if (bytes_sent_ > send_window_offset_) { |
186 return 0; | 188 return 0; |
187 } | 189 } |
188 return send_window_offset_ - bytes_sent_; | 190 return send_window_offset_ - bytes_sent_; |
189 } | 191 } |
190 | 192 |
191 } // namespace net | 193 } // namespace net |
OLD | NEW |