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

Side by Side Diff: cc/rate_limiter.cc

Issue 11344004: Remove WebKit::Platform dependencies from cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix webkit_compositor_bindings_unittests Created 8 years, 1 month 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
« no previous file with comments | « cc/proxy.cc ('k') | cc/resource_update_controller.h » ('j') | 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 "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 class RateLimiter::Task : public Thread::Task {
17 public:
18 static PassOwnPtr<Task> create(RateLimiter* rateLimiter)
19 {
20 return adoptPtr(new Task(rateLimiter));
21 }
22 virtual ~Task() { }
23
24 private:
25 explicit Task(RateLimiter* rateLimiter)
26 : Thread::Task(this)
27 , m_rateLimiter(rateLimiter)
28 {
29 }
30
31 virtual void performTask() OVERRIDE
32 {
33 m_rateLimiter->rateLimitContext();
34 }
35
36 scoped_refptr<RateLimiter> m_rateLimiter;
37 };
38
39 scoped_refptr<RateLimiter> RateLimiter::create(WebKit::WebGraphicsContext3D* con text, RateLimiterClient *client) 16 scoped_refptr<RateLimiter> RateLimiter::create(WebKit::WebGraphicsContext3D* con text, RateLimiterClient *client)
40 { 17 {
41 return make_scoped_refptr(new RateLimiter(context, client)); 18 return make_scoped_refptr(new RateLimiter(context, client));
42 } 19 }
43 20
44 RateLimiter::RateLimiter(WebKit::WebGraphicsContext3D* context, RateLimiterClien t *client) 21 RateLimiter::RateLimiter(WebKit::WebGraphicsContext3D* context, RateLimiterClien t *client)
45 : m_context(context) 22 : m_context(context)
46 , m_active(false) 23 , m_active(false)
47 , m_client(client) 24 , m_client(client)
48 { 25 {
49 DCHECK(context); 26 DCHECK(context);
50 } 27 }
51 28
52 RateLimiter::~RateLimiter() 29 RateLimiter::~RateLimiter()
53 { 30 {
54 } 31 }
55 32
56 void RateLimiter::start() 33 void RateLimiter::start()
57 { 34 {
58 if (m_active) 35 if (m_active)
59 return; 36 return;
60 37
61 TRACE_EVENT0("cc", "RateLimiter::start"); 38 TRACE_EVENT0("cc", "RateLimiter::start");
62 m_active = true; 39 m_active = true;
63 Proxy::mainThread()->postTask(RateLimiter::Task::create(this)); 40 Proxy::mainThread()->postTask(base::Bind(&RateLimiter::rateLimitContext, thi s));
64 } 41 }
65 42
66 void RateLimiter::stop() 43 void RateLimiter::stop()
67 { 44 {
68 TRACE_EVENT0("cc", "RateLimiter::stop"); 45 TRACE_EVENT0("cc", "RateLimiter::stop");
69 m_client = 0; 46 m_client = 0;
70 } 47 }
71 48
72 void RateLimiter::rateLimitContext() 49 void RateLimiter::rateLimitContext()
73 { 50 {
74 if (!m_client) 51 if (!m_client)
75 return; 52 return;
76 53
77 TRACE_EVENT0("cc", "RateLimiter::rateLimitContext"); 54 TRACE_EVENT0("cc", "RateLimiter::rateLimitContext");
78 55
79 m_active = false; 56 m_active = false;
80 m_client->rateLimit(); 57 m_client->rateLimit();
81 m_context->rateLimitOffscreenContextCHROMIUM(); 58 m_context->rateLimitOffscreenContextCHROMIUM();
82 } 59 }
83 60
84 } 61 }
OLDNEW
« no previous file with comments | « cc/proxy.cc ('k') | cc/resource_update_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698