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

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
« no previous file with comments | « remoting/base/BUILD.gn ('k') | remoting/base/leaky_bucket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 static const int kUnlimitedDepth = -1;
16
17 // |depth| specifies depth of the bucket in drops. kUnlimitedDepth indicate
18 // that bucket size is unlimited. |rate| is specified in drops per second.
19 LeakyBucket(int depth, int rate);
20 ~LeakyBucket();
21
22 // If the bucket can fit |drops| then adds them and returns true. Otherwise
23 // returns false.
24 bool RefillOrSpill(int drops, base::TimeTicks now);
25
26 // Updates rate.
27 void UpdateRate(int new_rate, base::TimeTicks now);
28
29 // Returns time when the bucket will be empty. The returned value may be in
30 // the past.
31 base::TimeTicks GetEmptyTime();
32
33 int rate() { return rate_; }
34
35 private:
36 void UpdateLevel(base::TimeTicks now);
37
38 int depth_;
39 int rate_;
40
41 // |current_level_| stores water level at |level_updated_time_|. Updated in
42 // UpdateLevel(), which is called from RefillOrSpill() and UpdateRate().
43 int current_level_;
44 base::TimeTicks level_updated_time_;
45
46 DISALLOW_COPY_AND_ASSIGN(LeakyBucket);
47 };
48
49 } // namespace remoting
50
51 #endif // REMOTING_BASE_LEAKY_BUCKET_H_
OLDNEW
« no previous file with comments | « remoting/base/BUILD.gn ('k') | remoting/base/leaky_bucket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698