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

Side by Side Diff: content/renderer/scheduler/renderer_web_scheduler_impl.cc

Issue 1088053003: Patch 1/3 to get WebScheduler via WebThread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile Created 5 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/renderer/scheduler/web_scheduler_impl.h" 5 #include "content/renderer/scheduler/renderer_web_scheduler_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "content/renderer/scheduler/renderer_scheduler.h" 9 #include "content/renderer/scheduler/renderer_scheduler.h"
10 #include "third_party/WebKit/public/platform/WebTraceLocation.h" 10 #include "third_party/WebKit/public/platform/WebTraceLocation.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 WebSchedulerImpl::WebSchedulerImpl(RendererScheduler* renderer_scheduler) 14 RendererWebSchedulerImpl::RendererWebSchedulerImpl(
15 RendererScheduler* renderer_scheduler)
15 : renderer_scheduler_(renderer_scheduler), 16 : renderer_scheduler_(renderer_scheduler),
16 idle_task_runner_(renderer_scheduler_->IdleTaskRunner()), 17 idle_task_runner_(renderer_scheduler_->IdleTaskRunner()),
17 loading_task_runner_(renderer_scheduler_->LoadingTaskRunner()), 18 loading_task_runner_(renderer_scheduler_->LoadingTaskRunner()),
18 timer_task_runner_(renderer_scheduler_->TimerTaskRunner()) { 19 timer_task_runner_(renderer_scheduler_->TimerTaskRunner()) {
19 } 20 }
20 21
21 WebSchedulerImpl::~WebSchedulerImpl() { 22 RendererWebSchedulerImpl::~RendererWebSchedulerImpl() {
22 } 23 }
23 24
24 bool WebSchedulerImpl::shouldYieldForHighPriorityWork() { 25 bool RendererWebSchedulerImpl::shouldYieldForHighPriorityWork() {
25 return renderer_scheduler_->ShouldYieldForHighPriorityWork(); 26 return renderer_scheduler_->ShouldYieldForHighPriorityWork();
26 } 27 }
27 28
28 bool WebSchedulerImpl::canExceedIdleDeadlineIfRequired() { 29 bool RendererWebSchedulerImpl::canExceedIdleDeadlineIfRequired() {
29 return renderer_scheduler_->CanExceedIdleDeadlineIfRequired(); 30 return renderer_scheduler_->CanExceedIdleDeadlineIfRequired();
30 } 31 }
31 32
32 void WebSchedulerImpl::runIdleTask(scoped_ptr<blink::WebThread::IdleTask> task, 33 void RendererWebSchedulerImpl::runIdleTask(
33 base::TimeTicks deadline) { 34 scoped_ptr<blink::WebThread::IdleTask> task,
35 base::TimeTicks deadline) {
34 task->run((deadline - base::TimeTicks()).InSecondsF()); 36 task->run((deadline - base::TimeTicks()).InSecondsF());
35 } 37 }
36 38
37 void WebSchedulerImpl::runTask(scoped_ptr<blink::WebThread::Task> task) { 39 void RendererWebSchedulerImpl::runTask(
40 scoped_ptr<blink::WebThread::Task> task) {
38 task->run(); 41 task->run();
39 } 42 }
40 43
41 void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation& web_location, 44 void RendererWebSchedulerImpl::postIdleTask(
42 blink::WebThread::IdleTask* task) { 45 const blink::WebTraceLocation& web_location,
46 blink::WebThread::IdleTask* task) {
43 DCHECK(idle_task_runner_); 47 DCHECK(idle_task_runner_);
44 scoped_ptr<blink::WebThread::IdleTask> scoped_task(task); 48 scoped_ptr<blink::WebThread::IdleTask> scoped_task(task);
45 tracked_objects::Location location(web_location.functionName(), 49 tracked_objects::Location location(web_location.functionName(),
46 web_location.fileName(), -1, nullptr); 50 web_location.fileName(), -1, nullptr);
47 idle_task_runner_->PostIdleTask( 51 idle_task_runner_->PostIdleTask(
48 location, 52 location, base::Bind(&RendererWebSchedulerImpl::runIdleTask,
49 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); 53 base::Passed(&scoped_task)));
50 } 54 }
51 55
52 void WebSchedulerImpl::postNonNestableIdleTask( 56 void RendererWebSchedulerImpl::postNonNestableIdleTask(
53 const blink::WebTraceLocation& web_location, 57 const blink::WebTraceLocation& web_location,
54 blink::WebThread::IdleTask* task) { 58 blink::WebThread::IdleTask* task) {
55 DCHECK(idle_task_runner_); 59 DCHECK(idle_task_runner_);
56 scoped_ptr<blink::WebThread::IdleTask> scoped_task(task); 60 scoped_ptr<blink::WebThread::IdleTask> scoped_task(task);
57 tracked_objects::Location location(web_location.functionName(), 61 tracked_objects::Location location(web_location.functionName(),
58 web_location.fileName(), -1, nullptr); 62 web_location.fileName(), -1, nullptr);
59 idle_task_runner_->PostNonNestableIdleTask( 63 idle_task_runner_->PostNonNestableIdleTask(
60 location, 64 location, base::Bind(&RendererWebSchedulerImpl::runIdleTask,
61 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); 65 base::Passed(&scoped_task)));
62 } 66 }
63 67
64 void WebSchedulerImpl::postIdleTaskAfterWakeup( 68 void RendererWebSchedulerImpl::postIdleTaskAfterWakeup(
65 const blink::WebTraceLocation& web_location, 69 const blink::WebTraceLocation& web_location,
66 blink::WebThread::IdleTask* task) { 70 blink::WebThread::IdleTask* task) {
67 DCHECK(idle_task_runner_); 71 DCHECK(idle_task_runner_);
68 scoped_ptr<blink::WebThread::IdleTask> scoped_task(task); 72 scoped_ptr<blink::WebThread::IdleTask> scoped_task(task);
69 tracked_objects::Location location(web_location.functionName(), 73 tracked_objects::Location location(web_location.functionName(),
70 web_location.fileName(), -1, nullptr); 74 web_location.fileName(), -1, nullptr);
71 idle_task_runner_->PostIdleTaskAfterWakeup( 75 idle_task_runner_->PostIdleTaskAfterWakeup(
72 location, 76 location, base::Bind(&RendererWebSchedulerImpl::runIdleTask,
73 base::Bind(&WebSchedulerImpl::runIdleTask, base::Passed(&scoped_task))); 77 base::Passed(&scoped_task)));
74 } 78 }
75 79
76 void WebSchedulerImpl::postLoadingTask( 80 void RendererWebSchedulerImpl::postLoadingTask(
77 const blink::WebTraceLocation& web_location, blink::WebThread::Task* task) { 81 const blink::WebTraceLocation& web_location,
82 blink::WebThread::Task* task) {
78 DCHECK(loading_task_runner_); 83 DCHECK(loading_task_runner_);
79 scoped_ptr<blink::WebThread::Task> scoped_task(task); 84 scoped_ptr<blink::WebThread::Task> scoped_task(task);
80 tracked_objects::Location location(web_location.functionName(), 85 tracked_objects::Location location(web_location.functionName(),
81 web_location.fileName(), -1, nullptr); 86 web_location.fileName(), -1, nullptr);
82 loading_task_runner_->PostTask( 87 loading_task_runner_->PostTask(location,
83 location, 88 base::Bind(&RendererWebSchedulerImpl::runTask,
84 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task))); 89 base::Passed(&scoped_task)));
85 } 90 }
86 91
87 void WebSchedulerImpl::postTimerTask( 92 void RendererWebSchedulerImpl::postTimerTask(
88 const blink::WebTraceLocation& web_location, 93 const blink::WebTraceLocation& web_location,
89 blink::WebThread::Task* task, 94 blink::WebThread::Task* task,
90 long long delayMs) { 95 long long delayMs) {
91 DCHECK(timer_task_runner_); 96 DCHECK(timer_task_runner_);
92 scoped_ptr<blink::WebThread::Task> scoped_task(task); 97 scoped_ptr<blink::WebThread::Task> scoped_task(task);
93 tracked_objects::Location location(web_location.functionName(), 98 tracked_objects::Location location(web_location.functionName(),
94 web_location.fileName(), -1, nullptr); 99 web_location.fileName(), -1, nullptr);
95 timer_task_runner_->PostDelayedTask( 100 timer_task_runner_->PostDelayedTask(
96 location, 101 location, base::Bind(&RendererWebSchedulerImpl::runTask,
97 base::Bind(&WebSchedulerImpl::runTask, base::Passed(&scoped_task)), 102 base::Passed(&scoped_task)),
98 base::TimeDelta::FromMilliseconds(delayMs)); 103 base::TimeDelta::FromMilliseconds(delayMs));
99 } 104 }
100 105
101 } // namespace content 106 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698