OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef RateLimiter_h | 5 #ifndef RateLimiter_h |
6 #define RateLimiter_h | 6 #define RateLimiter_h |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "cc/proxy.h" |
9 | 10 |
10 namespace WebKit { | 11 namespace WebKit { |
11 class WebGraphicsContext3D; | 12 class WebGraphicsContext3D; |
12 } | 13 } |
13 | 14 |
14 namespace cc { | 15 namespace cc { |
15 | 16 |
16 class RateLimiterClient { | 17 class RateLimiterClient { |
17 public: | 18 public: |
18 virtual void rateLimit() = 0; | 19 virtual void rateLimit() = 0; |
19 }; | 20 }; |
20 | 21 |
21 // A RateLimiter can be used to make sure that a single context does not dominat
e all execution time. | 22 // A RateLimiter can be used to make sure that a single context does not dominat
e all execution time. |
22 // To use, construct a RateLimiter class around the context and call start() whe
never calls are made on the | 23 // To use, construct a RateLimiter class around the context and call start() whe
never calls are made on the |
23 // context outside of normal flow control. RateLimiter will block if the context
is too far ahead of the | 24 // context outside of normal flow control. RateLimiter will block if the context
is too far ahead of the |
24 // compositor. | 25 // compositor. |
25 class RateLimiter : public base::RefCounted<RateLimiter> { | 26 class RateLimiter : public base::RefCounted<RateLimiter> { |
26 public: | 27 public: |
27 static scoped_refptr<RateLimiter> create(WebKit::WebGraphicsContext3D*, Rate
LimiterClient*); | 28 static scoped_refptr<RateLimiter> create(WebKit::WebGraphicsContext3D*, Rate
LimiterClient*, Proxy*); |
28 | 29 |
29 void start(); | 30 void start(); |
30 | 31 |
31 // Context and client will not be accessed after stop(). | 32 // Context and client will not be accessed after stop(). |
32 void stop(); | 33 void stop(); |
33 | 34 |
34 private: | 35 private: |
35 RateLimiter(WebKit::WebGraphicsContext3D*, RateLimiterClient*); | 36 RateLimiter(WebKit::WebGraphicsContext3D*, RateLimiterClient*, Proxy*); |
36 ~RateLimiter(); | 37 ~RateLimiter(); |
37 friend class base::RefCounted<RateLimiter>; | 38 friend class base::RefCounted<RateLimiter>; |
38 | 39 |
39 class Task; | 40 class Task; |
40 friend class Task; | 41 friend class Task; |
41 void rateLimitContext(); | 42 void rateLimitContext(); |
42 | 43 |
43 WebKit::WebGraphicsContext3D* m_context; | 44 WebKit::WebGraphicsContext3D* m_context; |
44 bool m_active; | 45 bool m_active; |
45 RateLimiterClient *m_client; | 46 RateLimiterClient *m_client; |
| 47 Proxy* m_proxy; |
46 }; | 48 }; |
47 | 49 |
48 } | 50 } |
49 #endif | 51 #endif |
OLD | NEW |