Chromium Code Reviews| 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 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/rate_limiter.h" | 7 #include "cc/rate_limiter.h" |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "cc/proxy.h" | 10 #include "cc/proxy.h" |
| 11 #include "cc/thread.h" | 11 #include "cc/thread.h" |
| 12 #include <public/WebGraphicsContext3D.h> | 12 #include <public/WebGraphicsContext3D.h> |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 scoped_refptr<RateLimiter> RateLimiter::create(WebKit::WebGraphicsContext3D* con text, RateLimiterClient *client) | 16 scoped_refptr<RateLimiter> RateLimiter::create(WebKit::WebGraphicsContext3D* con text, RateLimiterClient *client, Proxy* proxy) |
| 17 { | 17 { |
| 18 return make_scoped_refptr(new RateLimiter(context, client)); | 18 return make_scoped_refptr(new RateLimiter(context, client, proxy)); |
| 19 } | 19 } |
| 20 | 20 |
| 21 RateLimiter::RateLimiter(WebKit::WebGraphicsContext3D* context, RateLimiterClien t *client) | 21 RateLimiter::RateLimiter(WebKit::WebGraphicsContext3D* context, RateLimiterClien t *client, Proxy* proxy) |
| 22 : m_context(context) | 22 : m_proxy(proxy) |
| 23 , m_context(context) | |
| 23 , m_active(false) | 24 , m_active(false) |
| 24 , m_client(client) | 25 , m_client(client) |
| 25 { | 26 { |
| 26 DCHECK(context); | 27 DCHECK(context); |
| 27 } | 28 } |
| 28 | 29 |
| 29 RateLimiter::~RateLimiter() | 30 RateLimiter::~RateLimiter() |
| 30 { | 31 { |
| 31 } | 32 } |
| 32 | 33 |
| 33 void RateLimiter::start() | 34 void RateLimiter::start() |
| 34 { | 35 { |
| 35 if (m_active) | 36 if (m_active) |
| 36 return; | 37 return; |
| 37 | 38 |
| 38 TRACE_EVENT0("cc", "RateLimiter::start"); | 39 TRACE_EVENT0("cc", "RateLimiter::start"); |
| 39 m_active = true; | 40 m_active = true; |
| 40 Proxy::mainThread()->postTask(base::Bind(&RateLimiter::rateLimitContext, thi s)); | 41 m_proxy->mainThread()->postTask(base::Bind(&RateLimiter::rateLimitContext, t his)); |
|
jamesr
2012/10/31 04:42:13
could we just give RateLimit a cc::Thread* instead
| |
| 41 } | 42 } |
| 42 | 43 |
| 43 void RateLimiter::stop() | 44 void RateLimiter::stop() |
| 44 { | 45 { |
| 45 TRACE_EVENT0("cc", "RateLimiter::stop"); | 46 TRACE_EVENT0("cc", "RateLimiter::stop"); |
| 46 m_client = 0; | 47 m_client = 0; |
| 47 } | 48 } |
| 48 | 49 |
| 49 void RateLimiter::rateLimitContext() | 50 void RateLimiter::rateLimitContext() |
| 50 { | 51 { |
| 51 if (!m_client) | 52 if (!m_client) |
| 52 return; | 53 return; |
| 53 | 54 |
| 54 TRACE_EVENT0("cc", "RateLimiter::rateLimitContext"); | 55 TRACE_EVENT0("cc", "RateLimiter::rateLimitContext"); |
| 55 | 56 |
| 56 m_active = false; | 57 m_active = false; |
| 57 m_client->rateLimit(); | 58 m_client->rateLimit(); |
| 58 m_context->rateLimitOffscreenContextCHROMIUM(); | 59 m_context->rateLimitOffscreenContextCHROMIUM(); |
| 59 } | 60 } |
| 60 | 61 |
| 61 } | 62 } |
| OLD | NEW |