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 #include "cc/scheduler/rate_limiter.h"
8 #include "base/debug/trace_event.h"
9 #include "base/location.h"
10 #include "base/logging.h"
11 #include "base/single_thread_task_runner.h"
12 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
16 scoped_refptr
<RateLimiter
> RateLimiter::Create(
17 WebKit::WebGraphicsContext3D
* context
,
18 RateLimiterClient
* client
,
19 base::SingleThreadTaskRunner
* task_runner
) {
20 return make_scoped_refptr(new RateLimiter(context
, client
, task_runner
));
23 RateLimiter::RateLimiter(WebKit::WebGraphicsContext3D
* context
,
24 RateLimiterClient
* client
,
25 base::SingleThreadTaskRunner
* task_runner
)
29 task_runner_(task_runner
) {
33 RateLimiter::~RateLimiter() {}
35 void RateLimiter::Start() {
39 TRACE_EVENT0("cc", "RateLimiter::Start");
41 task_runner_
->PostTask(FROM_HERE
,
42 base::Bind(&RateLimiter::RateLimitContext
, this));
45 void RateLimiter::Stop() {
46 TRACE_EVENT0("cc", "RateLimiter::Stop");
50 void RateLimiter::RateLimitContext() {
54 TRACE_EVENT0("cc", "RateLimiter::RateLimitContext");
58 context_
->rateLimitOffscreenContextCHROMIUM();