| 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 #if USE(ACCELERATED_COMPOSITING) | 8 #if USE(ACCELERATED_COMPOSITING) |
| 9 | 9 |
| 10 #include <wtf/PassRefPtr.h> | 10 #include "base/memory/ref_counted.h" |
| 11 #include <wtf/RefCounted.h> | |
| 12 | 11 |
| 13 namespace WebKit { | 12 namespace WebKit { |
| 14 class WebGraphicsContext3D; | 13 class WebGraphicsContext3D; |
| 15 } | 14 } |
| 16 | 15 |
| 17 namespace cc { | 16 namespace cc { |
| 18 | 17 |
| 19 class RateLimiterClient { | 18 class RateLimiterClient { |
| 20 public: | 19 public: |
| 21 virtual void rateLimit() = 0; | 20 virtual void rateLimit() = 0; |
| 22 }; | 21 }; |
| 23 | 22 |
| 24 // 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. |
| 25 // 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 |
| 26 // 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 |
| 27 // compositor. | 26 // compositor. |
| 28 class RateLimiter : public RefCounted<RateLimiter> { | 27 class RateLimiter : public base::RefCounted<RateLimiter> { |
| 29 public: | 28 public: |
| 30 static PassRefPtr<RateLimiter> create(WebKit::WebGraphicsContext3D*, RateLim
iterClient*); | 29 static scoped_refptr<RateLimiter> create(WebKit::WebGraphicsContext3D*, Rate
LimiterClient*); |
| 31 ~RateLimiter(); | |
| 32 | 30 |
| 33 void start(); | 31 void start(); |
| 34 | 32 |
| 35 // Context and client will not be accessed after stop(). | 33 // Context and client will not be accessed after stop(). |
| 36 void stop(); | 34 void stop(); |
| 37 | 35 |
| 38 private: | 36 private: |
| 39 RateLimiter(WebKit::WebGraphicsContext3D*, RateLimiterClient*); | 37 RateLimiter(WebKit::WebGraphicsContext3D*, RateLimiterClient*); |
| 38 ~RateLimiter(); |
| 39 friend class base::RefCounted<RateLimiter>; |
| 40 | 40 |
| 41 class Task; | 41 class Task; |
| 42 friend class Task; | 42 friend class Task; |
| 43 void rateLimitContext(); | 43 void rateLimitContext(); |
| 44 | 44 |
| 45 WebKit::WebGraphicsContext3D* m_context; | 45 WebKit::WebGraphicsContext3D* m_context; |
| 46 bool m_active; | 46 bool m_active; |
| 47 RateLimiterClient *m_client; | 47 RateLimiterClient *m_client; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 } | 50 } |
| 51 #endif // USE(ACCELERATED_COMPOSITING) | 51 #endif // USE(ACCELERATED_COMPOSITING) |
| 52 | 52 |
| 53 #endif | 53 #endif |
| OLD | NEW |