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.
5 #ifndef CC_RATE_LIMITER_H_
6 #define CC_RATE_LIMITER_H_
8 #include "base/memory/ref_counted.h"
11 class WebGraphicsContext3D
;
18 class RateLimiterClient
{
20 virtual void rateLimit() = 0;
23 // A RateLimiter can be used to make sure that a single context does not dominate all execution time.
24 // To use, construct a RateLimiter class around the context and call start() whenever calls are made on the
25 // context outside of normal flow control. RateLimiter will block if the context is too far ahead of the
27 class RateLimiter
: public base::RefCounted
<RateLimiter
> {
29 static scoped_refptr
<RateLimiter
> create(WebKit::WebGraphicsContext3D
*, RateLimiterClient
*, Thread
*);
33 // Context and client will not be accessed after stop().
37 RateLimiter(WebKit::WebGraphicsContext3D
*, RateLimiterClient
*, Thread
*);
39 friend class base::RefCounted
<RateLimiter
>;
43 void rateLimitContext();
45 WebKit::WebGraphicsContext3D
* m_context
;
47 RateLimiterClient
*m_client
;
52 #endif // CC_RATE_LIMITER_H_