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 // Helper class that limits the congestion window to pace the packets. | 5 // Helper class that limits the congestion window to pace the packets. |
6 | 6 |
7 #ifndef NET_QUIC_CONGESTION_CONTROL_PACED_SENDER_H_ | 7 #ifndef NET_QUIC_CONGESTION_CONTROL_PACED_SENDER_H_ |
8 #define NET_QUIC_CONGESTION_CONTROL_PACED_SENDER_H_ | 8 #define NET_QUIC_CONGESTION_CONTROL_PACED_SENDER_H_ |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
12 #include "net/quic/congestion_control/leaky_bucket.h" | 12 #include "net/quic/congestion_control/leaky_bucket.h" |
13 #include "net/quic/quic_bandwidth.h" | 13 #include "net/quic/quic_bandwidth.h" |
14 #include "net/quic/quic_time.h" | 14 #include "net/quic/quic_time.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 class NET_EXPORT_PRIVATE PacedSender { | 18 class NET_EXPORT_PRIVATE PacedSender { |
19 public: | 19 public: |
20 PacedSender(QuicBandwidth bandwidth_estimate, QuicByteCount max_segment_size); | 20 PacedSender(QuicBandwidth bandwidth_estimate, QuicByteCount max_segment_size); |
21 | 21 |
22 void set_max_segment_size(QuicByteCount max_segment_size); | |
23 | |
24 // The estimated bandidth from the congestion algorithm changed. | 22 // The estimated bandidth from the congestion algorithm changed. |
25 void UpdateBandwidthEstimate(QuicTime now, QuicBandwidth bandwidth_estimate); | 23 void UpdateBandwidthEstimate(QuicTime now, QuicBandwidth bandwidth_estimate); |
26 | 24 |
27 // A packet of size bytes was sent. | 25 // A packet of size bytes was sent. |
28 void OnPacketSent(QuicTime now, QuicByteCount bytes); | 26 void OnPacketSent(QuicTime now, QuicByteCount bytes); |
29 | 27 |
30 // Return time until we can send based on the pacing. | 28 // Return time until we can send based on the pacing. |
31 QuicTime::Delta TimeUntilSend(QuicTime now, QuicTime::Delta time_until_send); | 29 QuicTime::Delta TimeUntilSend(QuicTime now, QuicTime::Delta time_until_send); |
32 | 30 |
33 private: | 31 private: |
34 // Helper object to track the rate data can leave the buffer for pacing. | 32 // Helper object to track the rate data can leave the buffer for pacing. |
35 LeakyBucket leaky_bucket_; | 33 LeakyBucket leaky_bucket_; |
36 QuicBandwidth pace_; | 34 QuicBandwidth pace_; |
37 QuicByteCount max_segment_size_; | 35 QuicByteCount max_segment_size_; |
38 | 36 |
39 DISALLOW_COPY_AND_ASSIGN(PacedSender); | 37 DISALLOW_COPY_AND_ASSIGN(PacedSender); |
40 }; | 38 }; |
41 | 39 |
42 } // namespace net | 40 } // namespace net |
43 | 41 |
44 #endif // NET_QUIC_CONGESTION_CONTROL_PACED_SENDER_H_ | 42 #endif // NET_QUIC_CONGESTION_CONTROL_PACED_SENDER_H_ |
OLD | NEW |