[Android] Fix selection handle flicker with contextual search
[chromium-blink-merge.git] / remoting / test / leaky_bucket.h
blob5b54b40e373d4a416842ff76fb2ef781e2b88808
1 // Copyright 2014 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.
5 #ifndef REMOTING_TEST_LEAKY_BUCKET_H_
6 #define REMOTING_TEST_LEAKY_BUCKET_H_
8 #include "base/basictypes.h"
9 #include "base/time/time.h"
11 namespace remoting {
13 class LeakyBucket {
14 public:
15 // |depth| is in bytes. |rate| is specified in bytes/second.
16 LeakyBucket(double depth, double rate);
17 ~LeakyBucket();
19 // Adds a packet of the given |size| to the bucket and returns packet delay.
20 // Returns TimeDelta::Max() if the packet overflows the bucket, in which case
21 // it should be dropped.
22 base::TimeDelta AddPacket(int size);
24 private:
25 void UpdateLevel();
27 double depth_;
28 double rate_;
30 double level_;
31 base::TimeTicks last_update_;
33 DISALLOW_COPY_AND_ASSIGN(LeakyBucket);
36 } // namespace remoting
38 #endif // REMOTING_TEST_LEAKY_BUCKET_H_