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

Unified Diff: remoting/test/leaky_bucket.h

Issue 427613005: Implement network performance simulation for remoting perf tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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/fake_socket_factory.cc ('k') | remoting/test/leaky_bucket.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/test/leaky_bucket.h
diff --git a/remoting/test/leaky_bucket.h b/remoting/test/leaky_bucket.h
new file mode 100644
index 0000000000000000000000000000000000000000..5b54b40e373d4a416842ff76fb2ef781e2b88808
--- /dev/null
+++ b/remoting/test/leaky_bucket.h
@@ -0,0 +1,38 @@
+// 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.
+
+#ifndef REMOTING_TEST_LEAKY_BUCKET_H_
+#define REMOTING_TEST_LEAKY_BUCKET_H_
+
+#include "base/basictypes.h"
+#include "base/time/time.h"
+
+namespace remoting {
+
+class LeakyBucket {
+ public:
+ // |depth| is in bytes. |rate| is specified in bytes/second.
+ LeakyBucket(double depth, double rate);
+ ~LeakyBucket();
+
+ // Adds a packet of the given |size| to the bucket and returns packet delay.
+ // Returns TimeDelta::Max() if the packet overflows the bucket, in which case
+ // it should be dropped.
+ base::TimeDelta AddPacket(int size);
+
+ private:
+ void UpdateLevel();
+
+ double depth_;
+ double rate_;
+
+ double level_;
+ base::TimeTicks last_update_;
+
+ DISALLOW_COPY_AND_ASSIGN(LeakyBucket);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_TEST_LEAKY_BUCKET_H_
« no previous file with comments | « remoting/test/fake_socket_factory.cc ('k') | remoting/test/leaky_bucket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698