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

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

Issue 734063004: Update from https://crrev.com/304418 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
deleted file mode 100644
index f3972f62eaca0b32b0076d07dc4e661587be80a5..0000000000000000000000000000000000000000
--- a/net/quic/congestion_control/leaky_bucket.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/quic/congestion_control/leaky_bucket.h"
-
-#include "base/time/time.h"
-
-namespace net {
-
-LeakyBucket::LeakyBucket(QuicBandwidth draining_rate)
- : bytes_(0),
- time_last_updated_(QuicTime::Zero()),
- draining_rate_(draining_rate) {
-}
-
-void LeakyBucket::SetDrainingRate(QuicTime now, QuicBandwidth draining_rate) {
- Update(now);
- draining_rate_ = draining_rate;
-}
-
-void LeakyBucket::Add(QuicTime now, QuicByteCount bytes) {
- Update(now);
- bytes_ += bytes;
-}
-
-QuicTime::Delta LeakyBucket::TimeRemaining(QuicTime now) const {
- QuicTime::Delta time_since_last_update = now.Subtract(time_last_updated_);
- QuicTime::Delta send_delay = QuicTime::Delta::FromMicroseconds(
- (bytes_ * base::Time::kMicrosecondsPerSecond) /
- draining_rate_.ToBytesPerSecond());
- if (send_delay < time_since_last_update) {
- return QuicTime::Delta::Zero();
- }
- return send_delay.Subtract(time_since_last_update);
-}
-
-QuicByteCount LeakyBucket::BytesPending(QuicTime now) {
- Update(now);
- return bytes_;
-}
-
-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_) {
- bytes_ = 0;
- } else {
- bytes_ -= bytes_cleared;
- }
- time_last_updated_ = now;
-}
-
-} // namespace net
« 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