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 CC_SCHEDULER_RATE_LIMITER_H_ | 5 #ifndef CC_SCHEDULER_RATE_LIMITER_H_ |
6 #define CC_SCHEDULER_RATE_LIMITER_H_ | 6 #define CC_SCHEDULER_RATE_LIMITER_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 | 9 |
10 namespace WebKit { class WebGraphicsContext3D; } | 10 namespace WebKit { class WebGraphicsContext3D; } |
11 | 11 |
12 namespace cc { | 12 namespace cc { |
13 | 13 |
14 class Thread; | 14 class Thread; |
15 | 15 |
16 class RateLimiterClient { | 16 class RateLimiterClient { |
17 public: | 17 public: |
18 virtual void RateLimit() = 0; | 18 virtual void RateLimit() = 0; |
| 19 |
| 20 protected: |
| 21 virtual ~RateLimiterClient() {} |
19 }; | 22 }; |
20 | 23 |
21 // A RateLimiter can be used to make sure that a single context does not | 24 // A RateLimiter can be used to make sure that a single context does not |
22 // dominate all execution time. To use, construct a RateLimiter class around | 25 // dominate all execution time. To use, construct a RateLimiter class around |
23 // the context and call Start() whenever calls are made on the context outside | 26 // the context and call Start() whenever calls are made on the context outside |
24 // of normal flow control. RateLimiter will block if the context is too far | 27 // of normal flow control. RateLimiter will block if the context is too far |
25 // ahead of the compositor. | 28 // ahead of the compositor. |
26 class RateLimiter : public base::RefCounted<RateLimiter> { | 29 class RateLimiter : public base::RefCounted<RateLimiter> { |
27 public: | 30 public: |
28 static scoped_refptr<RateLimiter> Create( | 31 static scoped_refptr<RateLimiter> Create( |
(...skipping 17 matching lines...) Expand all Loading... |
46 void RateLimitContext(); | 49 void RateLimitContext(); |
47 | 50 |
48 WebKit::WebGraphicsContext3D* context_; | 51 WebKit::WebGraphicsContext3D* context_; |
49 bool active_; | 52 bool active_; |
50 RateLimiterClient* client_; | 53 RateLimiterClient* client_; |
51 Thread* thread_; | 54 Thread* thread_; |
52 | 55 |
53 DISALLOW_COPY_AND_ASSIGN(RateLimiter); | 56 DISALLOW_COPY_AND_ASSIGN(RateLimiter); |
54 }; | 57 }; |
55 | 58 |
56 } | 59 } // namespace cc |
| 60 |
57 #endif // CC_SCHEDULER_RATE_LIMITER_H_ | 61 #endif // CC_SCHEDULER_RATE_LIMITER_H_ |
OLD | NEW |