Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: cc/rate_limiter.cc

Issue 12566033: cc: Chromify RateLimiter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« cc/rate_limiter.h ('K') | « cc/rate_limiter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/rate_limiter.h" 5 #include "cc/rate_limiter.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "cc/thread.h" 8 #include "cc/thread.h"
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 scoped_refptr<RateLimiter> RateLimiter::create(WebKit::WebGraphicsContext3D* con text, RateLimiterClient *client, Thread* thread) 13 scoped_refptr<RateLimiter> RateLimiter::Create(
14 { 14 WebKit::WebGraphicsContext3D* context,
15 return make_scoped_refptr(new RateLimiter(context, client, thread)); 15 RateLimiterClient* client,
16 Thread* thread) {
17 return make_scoped_refptr(new RateLimiter(context, client, thread));
16 } 18 }
17 19
18 RateLimiter::RateLimiter(WebKit::WebGraphicsContext3D* context, RateLimiterClien t *client, Thread* thread) 20 RateLimiter::RateLimiter(WebKit::WebGraphicsContext3D* context,
19 : m_thread(thread) 21 RateLimiterClient* client,
20 , m_context(context) 22 Thread* thread)
21 , m_active(false) 23 : thread_(thread),
22 , m_client(client) 24 context_(context),
23 { 25 active_(false),
24 DCHECK(context); 26 client_(client) {
27 DCHECK(context);
25 } 28 }
26 29
27 RateLimiter::~RateLimiter() 30 RateLimiter::~RateLimiter() {}
28 { 31
32 void RateLimiter::Start() {
33 if (active_)
34 return;
35
36 TRACE_EVENT0("cc", "RateLimiter::Start");
37 active_ = true;
38 thread_->postTask(base::Bind(&RateLimiter::RateLimitContext, this));
29 } 39 }
30 40
31 void RateLimiter::start() 41 void RateLimiter::Stop() {
32 { 42 TRACE_EVENT0("cc", "RateLimiter::Stop");
33 if (m_active) 43 client_ = NULL;
34 return;
35
36 TRACE_EVENT0("cc", "RateLimiter::start");
37 m_active = true;
38 m_thread->postTask(base::Bind(&RateLimiter::rateLimitContext, this));
39 } 44 }
40 45
41 void RateLimiter::stop() 46 void RateLimiter::RateLimitContext() {
42 { 47 if (!client_)
43 TRACE_EVENT0("cc", "RateLimiter::stop"); 48 return;
44 m_client = 0;
45 }
46 49
47 void RateLimiter::rateLimitContext() 50 TRACE_EVENT0("cc", "RateLimiter::RateLimitContext");
48 {
49 if (!m_client)
50 return;
51 51
52 TRACE_EVENT0("cc", "RateLimiter::rateLimitContext"); 52 active_ = false;
53 53 client_->RateLimit();
54 m_active = false; 54 context_->rateLimitOffscreenContextCHROMIUM();
55 m_client->rateLimit();
56 m_context->rateLimitOffscreenContextCHROMIUM();
57 } 55 }
58 56
59 } // namespace cc 57 } // namespace cc
OLDNEW
« cc/rate_limiter.h ('K') | « cc/rate_limiter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698