| 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/core/quic_flow_controller.h" | 5 #include "net/quic/core/quic_flow_controller.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "net/quic/core/quic_bug_tracker.h" | 8 #include "net/quic/core/quic_bug_tracker.h" |
| 9 #include "net/quic/core/quic_connection.h" | 9 #include "net/quic/core/quic_connection.h" |
| 10 #include "net/quic/core/quic_flags.h" | 10 #include "net/quic/core/quic_flags.h" |
| 11 #include "net/quic/core/quic_packets.h" | 11 #include "net/quic/core/quic_packets.h" |
| 12 #include "net/quic/platform/api/quic_str_cat.h" |
| 12 | 13 |
| 13 namespace net { | 14 namespace net { |
| 14 | 15 |
| 15 #define ENDPOINT \ | 16 #define ENDPOINT \ |
| 16 (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ") | 17 (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ") |
| 17 | 18 |
| 18 QuicFlowController::QuicFlowController(QuicConnection* connection, | 19 QuicFlowController::QuicFlowController(QuicConnection* connection, |
| 19 QuicStreamId id, | 20 QuicStreamId id, |
| 20 Perspective perspective, | 21 Perspective perspective, |
| 21 QuicStreamOffset send_window_offset, | 22 QuicStreamOffset send_window_offset, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 void QuicFlowController::AddBytesSent(QuicByteCount bytes_sent) { | 71 void QuicFlowController::AddBytesSent(QuicByteCount bytes_sent) { |
| 71 if (bytes_sent_ + bytes_sent > send_window_offset_) { | 72 if (bytes_sent_ + bytes_sent > send_window_offset_) { |
| 72 QUIC_BUG << ENDPOINT << "Stream " << id_ << " Trying to send an extra " | 73 QUIC_BUG << ENDPOINT << "Stream " << id_ << " Trying to send an extra " |
| 73 << bytes_sent << " bytes, when bytes_sent = " << bytes_sent_ | 74 << bytes_sent << " bytes, when bytes_sent = " << bytes_sent_ |
| 74 << ", and send_window_offset_ = " << send_window_offset_; | 75 << ", and send_window_offset_ = " << send_window_offset_; |
| 75 bytes_sent_ = send_window_offset_; | 76 bytes_sent_ = send_window_offset_; |
| 76 | 77 |
| 77 // This is an error on our side, close the connection as soon as possible. | 78 // This is an error on our side, close the connection as soon as possible. |
| 78 connection_->CloseConnection( | 79 connection_->CloseConnection( |
| 79 QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA, | 80 QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA, |
| 80 base::StringPrintf( | 81 QuicStrCat(send_window_offset_ - (bytes_sent_ + bytes_sent), |
| 81 "%llu bytes over send window offset", | 82 "bytes over send window offset"), |
| 82 static_cast<unsigned long long>(send_window_offset_ - | |
| 83 (bytes_sent_ + bytes_sent))) | |
| 84 .c_str(), | |
| 85 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 83 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 86 return; | 84 return; |
| 87 } | 85 } |
| 88 | 86 |
| 89 bytes_sent_ += bytes_sent; | 87 bytes_sent_ += bytes_sent; |
| 90 DVLOG(1) << ENDPOINT << "Stream " << id_ << " sent: " << bytes_sent_; | 88 DVLOG(1) << ENDPOINT << "Stream " << id_ << " sent: " << bytes_sent_; |
| 91 } | 89 } |
| 92 | 90 |
| 93 bool QuicFlowController::FlowControlViolation() { | 91 bool QuicFlowController::FlowControlViolation() { |
| 94 if (highest_received_byte_offset_ > receive_window_offset_) { | 92 if (highest_received_byte_offset_ > receive_window_offset_) { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 if (receive_window_size_ != receive_window_offset_) { | 245 if (receive_window_size_ != receive_window_offset_) { |
| 248 QUIC_BUG << "receive_window_size_:" << receive_window_size_ | 246 QUIC_BUG << "receive_window_size_:" << receive_window_size_ |
| 249 << " != receive_window_offset:" << receive_window_offset_; | 247 << " != receive_window_offset:" << receive_window_offset_; |
| 250 return; | 248 return; |
| 251 } | 249 } |
| 252 receive_window_size_ = size; | 250 receive_window_size_ = size; |
| 253 receive_window_offset_ = size; | 251 receive_window_offset_ = size; |
| 254 } | 252 } |
| 255 | 253 |
| 256 } // namespace net | 254 } // namespace net |
| OLD | NEW |