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

Side by Side Diff: net/quic/reliable_quic_stream.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/reliable_quic_stream.h" 5 #include "net/quic/reliable_quic_stream.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "net/quic/iovector.h" 8 #include "net/quic/iovector.h"
9 #include "net/quic/quic_flow_controller.h" 9 #include "net/quic/quic_flow_controller.h"
10 #include "net/quic/quic_session.h" 10 #include "net/quic/quic_session.h"
(...skipping 27 matching lines...) Expand all
38 class ReliableQuicStream::ProxyAckNotifierDelegate 38 class ReliableQuicStream::ProxyAckNotifierDelegate
39 : public QuicAckNotifier::DelegateInterface { 39 : public QuicAckNotifier::DelegateInterface {
40 public: 40 public:
41 explicit ProxyAckNotifierDelegate(DelegateInterface* delegate) 41 explicit ProxyAckNotifierDelegate(DelegateInterface* delegate)
42 : delegate_(delegate), 42 : delegate_(delegate),
43 pending_acks_(0), 43 pending_acks_(0),
44 wrote_last_data_(false), 44 wrote_last_data_(false),
45 num_original_packets_(0), 45 num_original_packets_(0),
46 num_original_bytes_(0), 46 num_original_bytes_(0),
47 num_retransmitted_packets_(0), 47 num_retransmitted_packets_(0),
48 num_retransmitted_bytes_(0) { 48 num_retransmitted_bytes_(0) {}
49 }
50 49
51 virtual void OnAckNotification(int num_original_packets, 50 virtual void OnAckNotification(
52 int num_original_bytes, 51 int num_original_packets,
53 int num_retransmitted_packets, 52 int num_original_bytes,
54 int num_retransmitted_bytes, 53 int num_retransmitted_packets,
55 QuicTime::Delta delta_largest_observed) 54 int num_retransmitted_bytes,
56 OVERRIDE { 55 QuicTime::Delta delta_largest_observed) OVERRIDE {
57 DCHECK_LT(0, pending_acks_); 56 DCHECK_LT(0, pending_acks_);
58 --pending_acks_; 57 --pending_acks_;
59 num_original_packets_ += num_original_packets; 58 num_original_packets_ += num_original_packets;
60 num_original_bytes_ += num_original_bytes; 59 num_original_bytes_ += num_original_bytes;
61 num_retransmitted_packets_ += num_retransmitted_packets; 60 num_retransmitted_packets_ += num_retransmitted_packets;
62 num_retransmitted_bytes_ += num_retransmitted_bytes; 61 num_retransmitted_bytes_ += num_retransmitted_bytes;
63 62
64 if (wrote_last_data_ && pending_acks_ == 0) { 63 if (wrote_last_data_ && pending_acks_ == 0) {
65 delegate_->OnAckNotification(num_original_packets_, 64 delegate_->OnAckNotification(num_original_packets_,
66 num_original_bytes_, 65 num_original_bytes_,
67 num_retransmitted_packets_, 66 num_retransmitted_packets_,
68 num_retransmitted_bytes_, 67 num_retransmitted_bytes_,
69 delta_largest_observed); 68 delta_largest_observed);
70 } 69 }
71 } 70 }
72 71
73 void WroteData(bool last_data) { 72 void WroteData(bool last_data) {
74 DCHECK(!wrote_last_data_); 73 DCHECK(!wrote_last_data_);
75 ++pending_acks_; 74 ++pending_acks_;
76 wrote_last_data_ = last_data; 75 wrote_last_data_ = last_data;
77 } 76 }
78 77
79 protected: 78 protected:
80 // Delegates are ref counted. 79 // Delegates are ref counted.
81 virtual ~ProxyAckNotifierDelegate() { 80 virtual ~ProxyAckNotifierDelegate() {}
82 }
83 81
84 private: 82 private:
85 // Original delegate. delegate_->OnAckNotification will be called when: 83 // Original delegate. delegate_->OnAckNotification will be called when:
86 // wrote_last_data_ == true and pending_acks_ == 0 84 // wrote_last_data_ == true and pending_acks_ == 0
87 scoped_refptr<DelegateInterface> delegate_; 85 scoped_refptr<DelegateInterface> delegate_;
88 86
89 // Number of outstanding acks. 87 // Number of outstanding acks.
90 int pending_acks_; 88 int pending_acks_;
91 89
92 // True if no pending writes remain. 90 // True if no pending writes remain.
93 bool wrote_last_data_; 91 bool wrote_last_data_;
94 92
95 // Accumulators. 93 // Accumulators.
96 int num_original_packets_; 94 int num_original_packets_;
97 int num_original_bytes_; 95 int num_original_bytes_;
98 int num_retransmitted_packets_; 96 int num_retransmitted_packets_;
99 int num_retransmitted_bytes_; 97 int num_retransmitted_bytes_;
100 98
101 DISALLOW_COPY_AND_ASSIGN(ProxyAckNotifierDelegate); 99 DISALLOW_COPY_AND_ASSIGN(ProxyAckNotifierDelegate);
102 }; 100 };
103 101
104 ReliableQuicStream::PendingData::PendingData( 102 ReliableQuicStream::PendingData::PendingData(
105 string data_in, scoped_refptr<ProxyAckNotifierDelegate> delegate_in) 103 string data_in,
104 scoped_refptr<ProxyAckNotifierDelegate> delegate_in)
106 : data(data_in), delegate(delegate_in) { 105 : data(data_in), delegate(delegate_in) {
107 } 106 }
108 107
109 ReliableQuicStream::PendingData::~PendingData() { 108 ReliableQuicStream::PendingData::~PendingData() {
110 } 109 }
111 110
112 ReliableQuicStream::ReliableQuicStream(QuicStreamId id, QuicSession* session) 111 ReliableQuicStream::ReliableQuicStream(QuicStreamId id, QuicSession* session)
113 : sequencer_(this), 112 : sequencer_(this),
114 id_(id), 113 id_(id),
115 session_(session), 114 session_(session),
116 stream_bytes_read_(0), 115 stream_bytes_read_(0),
117 stream_bytes_written_(0), 116 stream_bytes_written_(0),
118 stream_error_(QUIC_STREAM_NO_ERROR), 117 stream_error_(QUIC_STREAM_NO_ERROR),
119 connection_error_(QUIC_NO_ERROR), 118 connection_error_(QUIC_NO_ERROR),
120 read_side_closed_(false), 119 read_side_closed_(false),
121 write_side_closed_(false), 120 write_side_closed_(false),
122 fin_buffered_(false), 121 fin_buffered_(false),
123 fin_sent_(false), 122 fin_sent_(false),
124 rst_sent_(false), 123 rst_sent_(false),
125 is_server_(session_->is_server()), 124 is_server_(session_->is_server()),
126 flow_controller_( 125 flow_controller_(
127 session_->connection()->version(), 126 session_->connection()->version(),
128 id_, 127 id_,
129 is_server_, 128 is_server_,
130 session_->config()->HasReceivedInitialFlowControlWindowBytes() ? 129 session_->config()->HasReceivedInitialFlowControlWindowBytes()
131 session_->config()->ReceivedInitialFlowControlWindowBytes() : 130 ? session_->config()->ReceivedInitialFlowControlWindowBytes()
132 kDefaultFlowControlSendWindow, 131 : kDefaultFlowControlSendWindow,
133 session_->connection()->max_flow_control_receive_window_bytes(), 132 session_->connection()->max_flow_control_receive_window_bytes(),
134 session_->connection()->max_flow_control_receive_window_bytes()) { 133 session_->connection()->max_flow_control_receive_window_bytes()) {
135 } 134 }
136 135
137 ReliableQuicStream::~ReliableQuicStream() { 136 ReliableQuicStream::~ReliableQuicStream() {
138 } 137 }
139 138
140 bool ReliableQuicStream::OnStreamFrame(const QuicStreamFrame& frame) { 139 bool ReliableQuicStream::OnStreamFrame(const QuicStreamFrame& frame) {
141 if (read_side_closed_) { 140 if (read_side_closed_) {
142 DVLOG(1) << ENDPOINT << "Ignoring frame " << frame.stream_id; 141 DVLOG(1) << ENDPOINT << "Ignoring frame " << frame.stream_id;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 386
388 void ReliableQuicStream::OnClose() { 387 void ReliableQuicStream::OnClose() {
389 CloseReadSide(); 388 CloseReadSide();
390 CloseWriteSide(); 389 CloseWriteSide();
391 390
392 if (!fin_sent_ && !rst_sent_) { 391 if (!fin_sent_ && !rst_sent_) {
393 // For flow control accounting, we must tell the peer how many bytes we have 392 // For flow control accounting, we must tell the peer how many bytes we have
394 // written on this stream before termination. Done here if needed, using a 393 // written on this stream before termination. Done here if needed, using a
395 // RST frame. 394 // RST frame.
396 DVLOG(1) << ENDPOINT << "Sending RST in OnClose: " << id(); 395 DVLOG(1) << ENDPOINT << "Sending RST in OnClose: " << id();
397 session_->SendRstStream(id(), QUIC_RST_FLOW_CONTROL_ACCOUNTING, 396 session_->SendRstStream(
398 stream_bytes_written_); 397 id(), QUIC_RST_FLOW_CONTROL_ACCOUNTING, stream_bytes_written_);
399 rst_sent_ = true; 398 rst_sent_ = true;
400 } 399 }
401 } 400 }
402 401
403 void ReliableQuicStream::OnWindowUpdateFrame( 402 void ReliableQuicStream::OnWindowUpdateFrame(
404 const QuicWindowUpdateFrame& frame) { 403 const QuicWindowUpdateFrame& frame) {
405 if (!flow_controller_.IsEnabled()) { 404 if (!flow_controller_.IsEnabled()) {
406 DLOG(DFATAL) << "Flow control not enabled! " << version(); 405 DLOG(DFATAL) << "Flow control not enabled! " << version();
407 return; 406 return;
408 } 407 }
409 408
410 if (flow_controller_.UpdateSendWindowOffset(frame.byte_offset)) { 409 if (flow_controller_.UpdateSendWindowOffset(frame.byte_offset)) {
411 // We can write again! 410 // We can write again!
412 // TODO(rjshade): This does not respect priorities (e.g. multiple 411 // TODO(rjshade): This does not respect priorities (e.g. multiple
413 // outstanding POSTs are unblocked on arrival of 412 // outstanding POSTs are unblocked on arrival of
414 // SHLO with initial window). 413 // SHLO with initial window).
415 OnCanWrite(); 414 OnCanWrite();
416 } 415 }
417 } 416 }
418 417
419 } // namespace net 418 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698