Don't consider a Bluetooth adapter present until it has an address.
[chromium-blink-merge.git] / cc / RateLimiter.h
blob8cb8a1dbe19bf2958210697b004c92c46753077a
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 RateLimiter_h
6 #define RateLimiter_h
8 #if USE(ACCELERATED_COMPOSITING)
10 #include <wtf/PassRefPtr.h>
11 #include <wtf/RefCounted.h>
13 namespace WebKit {
14 class WebGraphicsContext3D;
17 namespace WebCore {
19 class RateLimiterClient {
20 public:
21 virtual void rateLimit() = 0;
24 // A RateLimiter can be used to make sure that a single context does not dominate all execution time.
25 // To use, construct a RateLimiter class around the context and call start() whenever calls are made on the
26 // context outside of normal flow control. RateLimiter will block if the context is too far ahead of the
27 // compositor.
28 class RateLimiter : public RefCounted<RateLimiter> {
29 public:
30 static PassRefPtr<RateLimiter> create(WebKit::WebGraphicsContext3D*, RateLimiterClient*);
31 ~RateLimiter();
33 void start();
35 // Context and client will not be accessed after stop().
36 void stop();
38 private:
39 RateLimiter(WebKit::WebGraphicsContext3D*, RateLimiterClient*);
41 class Task;
42 friend class Task;
43 void rateLimitContext();
45 WebKit::WebGraphicsContext3D* m_context;
46 bool m_active;
47 RateLimiterClient *m_client;
51 #endif // USE(ACCELERATED_COMPOSITING)
53 #endif