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

Side by Side Diff: remoting/base/leaky_bucket.h

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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #ifndef REMOTING_BASE_LEAKY_BUCKET_H_
6 #define REMOTING_BASE_LEAKY_BUCKET_H_
7
8 #include "base/macros.h"
9 #include "base/time/time.h"
10
11 namespace remoting {
12
13 class LeakyBucket {
14 public:
15 // |depth| is in bytes. |rate| is specified in bytes/second. Zero depth
Irfan 2016/09/29 22:22:41 bytes/second is a bit odd to track (for debug etc.
Sergey Ulanov 2016/09/29 23:25:20 I think it's best to use the same units for depth
16 // value indicates a bucket of infinite size.
17 LeakyBucket(int depth, int rate);
18 ~LeakyBucket();
19
20 // If the bucket can fit |size| bytes then adds them and returns true.
21 // Otherwise returns false.
22 bool RefillOrSpill(int size, base::TimeTicks now);
23
24 // Updates rate.
25 void UpdateRate(int new_rate, base::TimeTicks now);
26
27 // Returns time when the bucket will be empty. The returned value may be in
28 // the past.
29 base::TimeTicks GetEmptyTime();
30
31 int rate() { return rate_; }
32 int level() { return level_; }
33
34 private:
35 void UpdateLevel(base::TimeTicks now);
36
37 int depth_;
38 int rate_;
39
40 int level_;
Irfan 2016/09/29 22:22:41 document what level means ? may be call it curren
Sergey Ulanov 2016/09/29 23:25:20 Done.
41 base::TimeTicks last_update_;
42
43 DISALLOW_COPY_AND_ASSIGN(LeakyBucket);
44 };
45
46 } // namespace remoting
47
48 #endif // REMOTING_BASE_LEAKY_BUCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698