Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: net/quic/core/quic_flow_controller.cc

Issue 2591143003: Add QuicStrCat. (Closed)
Patch Set: sync Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/core/quic_crypto_client_stream.cc ('k') | net/quic/core/quic_flow_controller_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <cstdint> 7 #include <cstdint>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "net/quic/core/quic_bug_tracker.h" 10 #include "net/quic/core/quic_bug_tracker.h"
11 #include "net/quic/core/quic_connection.h" 11 #include "net/quic/core/quic_connection.h"
12 #include "net/quic/core/quic_packets.h" 12 #include "net/quic/core/quic_packets.h"
13 #include "net/quic/platform/api/quic_str_cat.h"
13 14
14 namespace net { 15 namespace net {
15 16
16 #define ENDPOINT \ 17 #define ENDPOINT \
17 (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ") 18 (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ")
18 19
19 QuicFlowController::QuicFlowController(QuicConnection* connection, 20 QuicFlowController::QuicFlowController(QuicConnection* connection,
20 QuicStreamId id, 21 QuicStreamId id,
21 Perspective perspective, 22 Perspective perspective,
22 QuicStreamOffset send_window_offset, 23 QuicStreamOffset send_window_offset,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 void QuicFlowController::AddBytesSent(QuicByteCount bytes_sent) { 72 void QuicFlowController::AddBytesSent(QuicByteCount bytes_sent) {
72 if (bytes_sent_ + bytes_sent > send_window_offset_) { 73 if (bytes_sent_ + bytes_sent > send_window_offset_) {
73 QUIC_BUG << ENDPOINT << "Stream " << id_ << " Trying to send an extra " 74 QUIC_BUG << ENDPOINT << "Stream " << id_ << " Trying to send an extra "
74 << bytes_sent << " bytes, when bytes_sent = " << bytes_sent_ 75 << bytes_sent << " bytes, when bytes_sent = " << bytes_sent_
75 << ", and send_window_offset_ = " << send_window_offset_; 76 << ", and send_window_offset_ = " << send_window_offset_;
76 bytes_sent_ = send_window_offset_; 77 bytes_sent_ = send_window_offset_;
77 78
78 // This is an error on our side, close the connection as soon as possible. 79 // This is an error on our side, close the connection as soon as possible.
79 connection_->CloseConnection( 80 connection_->CloseConnection(
80 QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA, 81 QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA,
81 base::StringPrintf( 82 QuicStrCat(send_window_offset_ - (bytes_sent_ + bytes_sent),
82 "%llu bytes over send window offset", 83 "bytes over send window offset"),
83 static_cast<unsigned long long>(send_window_offset_ -
84 (bytes_sent_ + bytes_sent)))
85 .c_str(),
86 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); 84 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
87 return; 85 return;
88 } 86 }
89 87
90 bytes_sent_ += bytes_sent; 88 bytes_sent_ += bytes_sent;
91 DVLOG(1) << ENDPOINT << "Stream " << id_ << " sent: " << bytes_sent_; 89 DVLOG(1) << ENDPOINT << "Stream " << id_ << " sent: " << bytes_sent_;
92 } 90 }
93 91
94 bool QuicFlowController::FlowControlViolation() { 92 bool QuicFlowController::FlowControlViolation() {
95 if (highest_received_byte_offset_ > receive_window_offset_) { 93 if (highest_received_byte_offset_ > receive_window_offset_) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 if (receive_window_size_ != receive_window_offset_) { 246 if (receive_window_size_ != receive_window_offset_) {
249 QUIC_BUG << "receive_window_size_:" << receive_window_size_ 247 QUIC_BUG << "receive_window_size_:" << receive_window_size_
250 << " != receive_window_offset:" << receive_window_offset_; 248 << " != receive_window_offset:" << receive_window_offset_;
251 return; 249 return;
252 } 250 }
253 receive_window_size_ = size; 251 receive_window_size_ = size;
254 receive_window_offset_ = size; 252 receive_window_offset_ = size;
255 } 253 }
256 254
257 } // namespace net 255 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_crypto_client_stream.cc ('k') | net/quic/core/quic_flow_controller_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698