OLD | NEW |
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 explicit ProxyAckNotifierDelegate(DelegateInterface* delegate) | 69 explicit ProxyAckNotifierDelegate(DelegateInterface* delegate) |
70 : delegate_(delegate), | 70 : delegate_(delegate), |
71 pending_acks_(0), | 71 pending_acks_(0), |
72 wrote_last_data_(false), | 72 wrote_last_data_(false), |
73 num_original_packets_(0), | 73 num_original_packets_(0), |
74 num_original_bytes_(0), | 74 num_original_bytes_(0), |
75 num_retransmitted_packets_(0), | 75 num_retransmitted_packets_(0), |
76 num_retransmitted_bytes_(0) { | 76 num_retransmitted_bytes_(0) { |
77 } | 77 } |
78 | 78 |
79 virtual void OnAckNotification(int num_original_packets, | 79 void OnAckNotification(int num_original_packets, |
80 int num_original_bytes, | 80 int num_original_bytes, |
81 int num_retransmitted_packets, | 81 int num_retransmitted_packets, |
82 int num_retransmitted_bytes, | 82 int num_retransmitted_bytes, |
83 QuicTime::Delta delta_largest_observed) | 83 QuicTime::Delta delta_largest_observed) override { |
84 override { | |
85 DCHECK_LT(0, pending_acks_); | 84 DCHECK_LT(0, pending_acks_); |
86 --pending_acks_; | 85 --pending_acks_; |
87 num_original_packets_ += num_original_packets; | 86 num_original_packets_ += num_original_packets; |
88 num_original_bytes_ += num_original_bytes; | 87 num_original_bytes_ += num_original_bytes; |
89 num_retransmitted_packets_ += num_retransmitted_packets; | 88 num_retransmitted_packets_ += num_retransmitted_packets; |
90 num_retransmitted_bytes_ += num_retransmitted_bytes; | 89 num_retransmitted_bytes_ += num_retransmitted_bytes; |
91 | 90 |
92 if (wrote_last_data_ && pending_acks_ == 0) { | 91 if (wrote_last_data_ && pending_acks_ == 0) { |
93 delegate_->OnAckNotification(num_original_packets_, | 92 delegate_->OnAckNotification(num_original_packets_, |
94 num_original_bytes_, | 93 num_original_bytes_, |
95 num_retransmitted_packets_, | 94 num_retransmitted_packets_, |
96 num_retransmitted_bytes_, | 95 num_retransmitted_bytes_, |
97 delta_largest_observed); | 96 delta_largest_observed); |
98 } | 97 } |
99 } | 98 } |
100 | 99 |
101 void WroteData(bool last_data) { | 100 void WroteData(bool last_data) { |
102 DCHECK(!wrote_last_data_); | 101 DCHECK(!wrote_last_data_); |
103 ++pending_acks_; | 102 ++pending_acks_; |
104 wrote_last_data_ = last_data; | 103 wrote_last_data_ = last_data; |
105 } | 104 } |
106 | 105 |
107 protected: | 106 protected: |
108 // Delegates are ref counted. | 107 // Delegates are ref counted. |
109 virtual ~ProxyAckNotifierDelegate() override { | 108 ~ProxyAckNotifierDelegate() override {} |
110 } | |
111 | 109 |
112 private: | 110 private: |
113 // Original delegate. delegate_->OnAckNotification will be called when: | 111 // Original delegate. delegate_->OnAckNotification will be called when: |
114 // wrote_last_data_ == true and pending_acks_ == 0 | 112 // wrote_last_data_ == true and pending_acks_ == 0 |
115 scoped_refptr<DelegateInterface> delegate_; | 113 scoped_refptr<DelegateInterface> delegate_; |
116 | 114 |
117 // Number of outstanding acks. | 115 // Number of outstanding acks. |
118 int pending_acks_; | 116 int pending_acks_; |
119 | 117 |
120 // True if no pending writes remain. | 118 // True if no pending writes remain. |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 | 538 |
541 bool ReliableQuicStream::IsFlowControlBlocked() { | 539 bool ReliableQuicStream::IsFlowControlBlocked() { |
542 if (flow_controller_.IsBlocked()) { | 540 if (flow_controller_.IsBlocked()) { |
543 return true; | 541 return true; |
544 } | 542 } |
545 return stream_contributes_to_connection_flow_control_ && | 543 return stream_contributes_to_connection_flow_control_ && |
546 connection_flow_controller_->IsBlocked(); | 544 connection_flow_controller_->IsBlocked(); |
547 } | 545 } |
548 | 546 |
549 } // namespace net | 547 } // namespace net |
OLD | NEW |