| 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" | |
| 8 #include "net/quic/quic_connection.h" | 7 #include "net/quic/quic_connection.h" |
| 9 #include "net/quic/quic_flags.h" | 8 #include "net/quic/quic_flags.h" |
| 10 #include "net/quic/quic_protocol.h" | 9 #include "net/quic/quic_protocol.h" |
| 11 | 10 |
| 12 namespace net { | 11 namespace net { |
| 13 | 12 |
| 14 #define ENDPOINT \ | 13 #define ENDPOINT \ |
| 15 (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ") | 14 (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ") |
| 16 | 15 |
| 17 QuicFlowController::QuicFlowController(QuicConnection* connection, | 16 QuicFlowController::QuicFlowController(QuicConnection* connection, |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 220 |
| 222 const bool blocked = IsBlocked(); | 221 const bool blocked = IsBlocked(); |
| 223 send_window_offset_ = new_send_window_offset; | 222 send_window_offset_ = new_send_window_offset; |
| 224 return blocked; | 223 return blocked; |
| 225 } | 224 } |
| 226 | 225 |
| 227 bool QuicFlowController::IsBlocked() const { | 226 bool QuicFlowController::IsBlocked() const { |
| 228 return SendWindowSize() == 0; | 227 return SendWindowSize() == 0; |
| 229 } | 228 } |
| 230 | 229 |
| 231 uint64 QuicFlowController::SendWindowSize() const { | 230 uint64_t QuicFlowController::SendWindowSize() const { |
| 232 if (bytes_sent_ > send_window_offset_) { | 231 if (bytes_sent_ > send_window_offset_) { |
| 233 return 0; | 232 return 0; |
| 234 } | 233 } |
| 235 return send_window_offset_ - bytes_sent_; | 234 return send_window_offset_ - bytes_sent_; |
| 236 } | 235 } |
| 237 | 236 |
| 238 void QuicFlowController::UpdateReceiveWindowSize(QuicStreamOffset size) { | 237 void QuicFlowController::UpdateReceiveWindowSize(QuicStreamOffset size) { |
| 239 DVLOG(1) << ENDPOINT << "UpdateReceiveWindowSize for stream " << id_ << ": " | 238 DVLOG(1) << ENDPOINT << "UpdateReceiveWindowSize for stream " << id_ << ": " |
| 240 << size; | 239 << size; |
| 241 if (receive_window_size_ != receive_window_offset_) { | 240 if (receive_window_size_ != receive_window_offset_) { |
| 242 LOG(DFATAL) << "receive_window_size_:" << receive_window_size_ | 241 LOG(DFATAL) << "receive_window_size_:" << receive_window_size_ |
| 243 << " != receive_window_offset:" << receive_window_offset_; | 242 << " != receive_window_offset:" << receive_window_offset_; |
| 244 return; | 243 return; |
| 245 } | 244 } |
| 246 receive_window_size_ = size; | 245 receive_window_size_ = size; |
| 247 receive_window_offset_ = size; | 246 receive_window_offset_ = size; |
| 248 } | 247 } |
| 249 | 248 |
| 250 } // namespace net | 249 } // namespace net |
| OLD | NEW |