| 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_clock.h" | |
| 15 #include "net/quic/quic_time.h" | 14 #include "net/quic/quic_time.h" |
| 16 | 15 |
| 17 namespace net { | 16 namespace net { |
| 18 | 17 |
| 19 class NET_EXPORT_PRIVATE PacedSender { | 18 class NET_EXPORT_PRIVATE PacedSender { |
| 20 public: | 19 public: |
| 21 PacedSender(const QuicClock* clock, QuicBandwidth bandwidth_estimate); | 20 explicit PacedSender(QuicBandwidth bandwidth_estimate); |
| 22 | 21 |
| 23 // The estimated bandidth from the congestion algorithm changed. | 22 // The estimated bandidth from the congestion algorithm changed. |
| 24 void UpdateBandwidthEstimate(QuicBandwidth bandwidth_estimate); | 23 void UpdateBandwidthEstimate(QuicTime now, QuicBandwidth bandwidth_estimate); |
| 25 | 24 |
| 26 // A packet of size bytes was sent. | 25 // A packet of size bytes was sent. |
| 27 void SentPacket(QuicByteCount bytes); | 26 void SentPacket(QuicTime now, QuicByteCount bytes); |
| 28 | 27 |
| 29 // Return time until we can send based on the pacing. | 28 // Return time until we can send based on the pacing. |
| 30 QuicTime::Delta TimeUntilSend(QuicTime::Delta time_until_send); | 29 QuicTime::Delta TimeUntilSend(QuicTime now, QuicTime::Delta time_until_send); |
| 31 | |
| 32 // Return the amount of data in bytes we can send based on the pacing. | |
| 33 // available_congestion_window is the congestion algorithms available | |
| 34 // congestion window in bytes. | |
| 35 QuicByteCount AvailableWindow(QuicByteCount available_congestion_window); | |
| 36 | 30 |
| 37 private: | 31 private: |
| 38 // 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. |
| 39 LeakyBucket leaky_bucket_; | 33 LeakyBucket leaky_bucket_; |
| 40 QuicBandwidth pace_; | 34 QuicBandwidth pace_; |
| 41 | 35 |
| 42 DISALLOW_COPY_AND_ASSIGN(PacedSender); | 36 DISALLOW_COPY_AND_ASSIGN(PacedSender); |
| 43 }; | 37 }; |
| 44 | 38 |
| 45 } // namespace net | 39 } // namespace net |
| 46 | 40 |
| 47 #endif // NET_QUIC_CONGESTION_CONTROL_PACED_SENDER_H_ | 41 #endif // NET_QUIC_CONGESTION_CONTROL_PACED_SENDER_H_ |
| OLD | NEW |