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

Unified Diff: remoting/test/leaky_bucket.cc

Issue 2381153002: Pace outgoing frames in frame scheduler to match target bitrate. (Closed)
Patch Set: . Created 4 years, 2 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 | « remoting/test/leaky_bucket.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/test/leaky_bucket.cc
diff --git a/remoting/test/leaky_bucket.cc b/remoting/test/leaky_bucket.cc
deleted file mode 100644
index ee8a62b06de136d82c2a040c5abb5706f2d9f06e..0000000000000000000000000000000000000000
--- a/remoting/test/leaky_bucket.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2014 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 "remoting/test/leaky_bucket.h"
-
-#include "base/logging.h"
-
-namespace remoting {
-
-LeakyBucket::LeakyBucket(double depth, double rate)
- : depth_(depth),
- rate_(rate),
- level_(0.0),
- last_update_(base::TimeTicks::Now()) {
-}
-
-LeakyBucket::~LeakyBucket() {
-}
-
-base::TimeDelta LeakyBucket::AddPacket(int size) {
- UpdateLevel();
-
- double new_level = level_ + size;
- if (new_level > depth_)
- return base::TimeDelta::Max();
-
- base::TimeDelta result = base::TimeDelta::FromSecondsD(level_ / rate_);
- level_ = new_level;
- return result;
-}
-
-void LeakyBucket::UpdateLevel() {
- base::TimeTicks now = base::TimeTicks::Now();
- level_ -= rate_ * (now - last_update_).InSecondsF();
- if (level_ < 0.0)
- level_ = 0.0;
- last_update_ = now;
-}
-
-} // namespace remoting
« no previous file with comments | « remoting/test/leaky_bucket.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698