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