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

Side by Side Diff: cc/scheduler/rate_limiter.h

Issue 53153006: Simplify rate limiting since it's main thread shared context only (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « cc/layers/texture_layer_unittest.cc ('k') | cc/scheduler/rate_limiter.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 2011 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 CC_SCHEDULER_RATE_LIMITER_H_
6 #define CC_SCHEDULER_RATE_LIMITER_H_
7
8 #include "base/memory/ref_counted.h"
9
10 namespace base { class SingleThreadTaskRunner; }
11
12 namespace WebKit { class WebGraphicsContext3D; }
13
14 namespace cc {
15
16 class RateLimiterClient {
17 public:
18 virtual void RateLimit() = 0;
19
20 protected:
21 virtual ~RateLimiterClient() {}
22 };
23
24 // A RateLimiter can be used to make sure that a single context does not
25 // dominate all execution time. To use, construct a RateLimiter class around
26 // the context and call Start() whenever calls are made on the context outside
27 // of normal flow control. RateLimiter will block if the context is too far
28 // ahead of the compositor.
29 class RateLimiter : public base::RefCounted<RateLimiter> {
30 public:
31 static scoped_refptr<RateLimiter> Create(
32 WebKit::WebGraphicsContext3D* context,
33 RateLimiterClient* client,
34 base::SingleThreadTaskRunner* task_runner);
35
36 void Start();
37
38 // Context and client will not be accessed after Stop().
39 void Stop();
40
41 private:
42 friend class base::RefCounted<RateLimiter>;
43
44 RateLimiter(WebKit::WebGraphicsContext3D* context,
45 RateLimiterClient* client,
46 base::SingleThreadTaskRunner* task_runner);
47 ~RateLimiter();
48
49 void RateLimitContext();
50
51 WebKit::WebGraphicsContext3D* context_;
52 bool active_;
53 RateLimiterClient* client_;
54 base::SingleThreadTaskRunner* task_runner_;
55
56 DISALLOW_COPY_AND_ASSIGN(RateLimiter);
57 };
58
59 } // namespace cc
60
61 #endif // CC_SCHEDULER_RATE_LIMITER_H_
OLDNEW
« no previous file with comments | « cc/layers/texture_layer_unittest.cc ('k') | cc/scheduler/rate_limiter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698