| 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_RATE_LIMITER_H_ | 5 #ifndef CC_RATE_LIMITER_H_ |
| 6 #define CC_RATE_LIMITER_H_ | 6 #define CC_RATE_LIMITER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 | 9 |
| 10 namespace WebKit { | 10 namespace WebKit { |
| 11 class WebGraphicsContext3D; | 11 class WebGraphicsContext3D; |
| 12 } | 12 } |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 class Thread; |
| 17 |
| 16 class RateLimiterClient { | 18 class RateLimiterClient { |
| 17 public: | 19 public: |
| 18 virtual void rateLimit() = 0; | 20 virtual void rateLimit() = 0; |
| 19 }; | 21 }; |
| 20 | 22 |
| 21 // A RateLimiter can be used to make sure that a single context does not dominat
e all execution time. | 23 // 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 | 24 // 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 | 25 // context outside of normal flow control. RateLimiter will block if the context
is too far ahead of the |
| 24 // compositor. | 26 // compositor. |
| 25 class RateLimiter : public base::RefCounted<RateLimiter> { | 27 class RateLimiter : public base::RefCounted<RateLimiter> { |
| 26 public: | 28 public: |
| 27 static scoped_refptr<RateLimiter> create(WebKit::WebGraphicsContext3D*, Rate
LimiterClient*); | 29 static scoped_refptr<RateLimiter> create(WebKit::WebGraphicsContext3D*, Rate
LimiterClient*, Thread*); |
| 28 | 30 |
| 29 void start(); | 31 void start(); |
| 30 | 32 |
| 31 // Context and client will not be accessed after stop(). | 33 // Context and client will not be accessed after stop(). |
| 32 void stop(); | 34 void stop(); |
| 33 | 35 |
| 34 private: | 36 private: |
| 35 RateLimiter(WebKit::WebGraphicsContext3D*, RateLimiterClient*); | 37 RateLimiter(WebKit::WebGraphicsContext3D*, RateLimiterClient*, Thread*); |
| 36 ~RateLimiter(); | 38 ~RateLimiter(); |
| 37 friend class base::RefCounted<RateLimiter>; | 39 friend class base::RefCounted<RateLimiter>; |
| 38 | 40 |
| 39 class Task; | 41 class Task; |
| 40 friend class Task; | 42 friend class Task; |
| 41 void rateLimitContext(); | 43 void rateLimitContext(); |
| 42 | 44 |
| 43 WebKit::WebGraphicsContext3D* m_context; | 45 WebKit::WebGraphicsContext3D* m_context; |
| 44 bool m_active; | 46 bool m_active; |
| 45 RateLimiterClient *m_client; | 47 RateLimiterClient *m_client; |
| 48 Thread* m_thread; |
| 46 }; | 49 }; |
| 47 | 50 |
| 48 } | 51 } |
| 49 #endif // CC_RATE_LIMITER_H_ | 52 #endif // CC_RATE_LIMITER_H_ |
| OLD | NEW |