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

Unified Diff: net/quic/congestion_control/leaky_bucket.cc

Issue 12334063: Land recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more EXPECT_FALSE Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/congestion_control/leaky_bucket.h ('k') | net/quic/congestion_control/leaky_bucket_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/congestion_control/leaky_bucket.cc
diff --git a/net/quic/congestion_control/leaky_bucket.cc b/net/quic/congestion_control/leaky_bucket.cc
index 0012ae862acdc6cb146cf6b78dff04d0df49a549..85568109625aa842de17aa10c4e4eb304470b56e 100644
--- a/net/quic/congestion_control/leaky_bucket.cc
+++ b/net/quic/congestion_control/leaky_bucket.cc
@@ -8,37 +8,35 @@
namespace net {
-LeakyBucket::LeakyBucket(const QuicClock* clock, QuicBandwidth draining_rate)
- : clock_(clock),
- bytes_(0),
+LeakyBucket::LeakyBucket(QuicBandwidth draining_rate)
+ : bytes_(0),
time_last_updated_(QuicTime::Zero()),
draining_rate_(draining_rate) {
}
-void LeakyBucket::SetDrainingRate(QuicBandwidth draining_rate) {
- Update();
+void LeakyBucket::SetDrainingRate(QuicTime now, QuicBandwidth draining_rate) {
+ Update(now);
draining_rate_ = draining_rate;
}
-void LeakyBucket::Add(QuicByteCount bytes) {
- Update();
+void LeakyBucket::Add(QuicTime now, QuicByteCount bytes) {
+ Update(now);
bytes_ += bytes;
}
-QuicTime::Delta LeakyBucket::TimeRemaining() {
- Update();
+QuicTime::Delta LeakyBucket::TimeRemaining(QuicTime now) {
+ Update(now);
return QuicTime::Delta::FromMicroseconds(
(bytes_ * base::Time::kMicrosecondsPerSecond) /
draining_rate_.ToBytesPerSecond());
}
-QuicByteCount LeakyBucket::BytesPending() {
- Update();
+QuicByteCount LeakyBucket::BytesPending(QuicTime now) {
+ Update(now);
return bytes_;
}
-void LeakyBucket::Update() {
- QuicTime now = clock_->Now();
+void LeakyBucket::Update(QuicTime now) {
QuicTime::Delta elapsed_time = now.Subtract(time_last_updated_);
QuicByteCount bytes_cleared = draining_rate_.ToBytesPerPeriod(elapsed_time);
if (bytes_cleared >= bytes_) {
« no previous file with comments | « net/quic/congestion_control/leaky_bucket.h ('k') | net/quic/congestion_control/leaky_bucket_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698