Commit 2e2647b9 authored by alexclarke's avatar alexclarke Committed by Commit bot

Move IdleTask to WebThread side 2/3

Second step of a a three sided patch to move IdleTask to WebThread.
This is needed because we plan to introduce a scheduler for worker
threads, and they will use the WebTherad interface for posting idle
tasks.

Other patches https://codereview.chromium.org/1031843002/
and https://codereview.chromium.org/1029803002

BUG=463143

Review URL: https://codereview.chromium.org/1029343002

Cr-Commit-Position: refs/heads/master@{#322443}
parent ff84d8d3
...@@ -29,9 +29,8 @@ bool WebSchedulerImpl::canExceedIdleDeadlineIfRequired() { ...@@ -29,9 +29,8 @@ bool WebSchedulerImpl::canExceedIdleDeadlineIfRequired() {
return renderer_scheduler_->CanExceedIdleDeadlineIfRequired(); return renderer_scheduler_->CanExceedIdleDeadlineIfRequired();
} }
void WebSchedulerImpl::runIdleTask( void WebSchedulerImpl::runIdleTask(scoped_ptr<blink::WebThread::IdleTask> task,
scoped_ptr<blink::WebScheduler::IdleTask> task, base::TimeTicks deadline) {
base::TimeTicks deadline) {
task->run((deadline - base::TimeTicks()).InSecondsF()); task->run((deadline - base::TimeTicks()).InSecondsF());
} }
...@@ -40,9 +39,9 @@ void WebSchedulerImpl::runTask(scoped_ptr<blink::WebThread::Task> task) { ...@@ -40,9 +39,9 @@ void WebSchedulerImpl::runTask(scoped_ptr<blink::WebThread::Task> task) {
} }
void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation& web_location, void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation& web_location,
blink::WebScheduler::IdleTask* task) { blink::WebThread::IdleTask* task) {
DCHECK(idle_task_runner_); DCHECK(idle_task_runner_);
scoped_ptr<blink::WebScheduler::IdleTask> scoped_task(task); scoped_ptr<blink::WebThread::IdleTask> scoped_task(task);
tracked_objects::Location location(web_location.functionName(), tracked_objects::Location location(web_location.functionName(),
web_location.fileName(), -1, nullptr); web_location.fileName(), -1, nullptr);
idle_task_runner_->PostIdleTask( idle_task_runner_->PostIdleTask(
...@@ -52,9 +51,9 @@ void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation& web_location, ...@@ -52,9 +51,9 @@ void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation& web_location,
void WebSchedulerImpl::postNonNestableIdleTask( void WebSchedulerImpl::postNonNestableIdleTask(
const blink::WebTraceLocation& web_location, const blink::WebTraceLocation& web_location,
blink::WebScheduler::IdleTask* task) { blink::WebThread::IdleTask* task) {
DCHECK(idle_task_runner_); DCHECK(idle_task_runner_);
scoped_ptr<blink::WebScheduler::IdleTask> scoped_task(task); scoped_ptr<blink::WebThread::IdleTask> scoped_task(task);
tracked_objects::Location location(web_location.functionName(), tracked_objects::Location location(web_location.functionName(),
web_location.fileName(), -1, nullptr); web_location.fileName(), -1, nullptr);
idle_task_runner_->PostNonNestableIdleTask( idle_task_runner_->PostNonNestableIdleTask(
...@@ -64,9 +63,9 @@ void WebSchedulerImpl::postNonNestableIdleTask( ...@@ -64,9 +63,9 @@ void WebSchedulerImpl::postNonNestableIdleTask(
void WebSchedulerImpl::postIdleTaskAfterWakeup( void WebSchedulerImpl::postIdleTaskAfterWakeup(
const blink::WebTraceLocation& web_location, const blink::WebTraceLocation& web_location,
blink::WebScheduler::IdleTask* task) { blink::WebThread::IdleTask* task) {
DCHECK(idle_task_runner_); DCHECK(idle_task_runner_);
scoped_ptr<blink::WebScheduler::IdleTask> scoped_task(task); scoped_ptr<blink::WebThread::IdleTask> scoped_task(task);
tracked_objects::Location location(web_location.functionName(), tracked_objects::Location location(web_location.functionName(),
web_location.fileName(), -1, nullptr); web_location.fileName(), -1, nullptr);
idle_task_runner_->PostIdleTaskAfterWakeup( idle_task_runner_->PostIdleTaskAfterWakeup(
......
...@@ -29,11 +29,11 @@ class CONTENT_EXPORT WebSchedulerImpl : public blink::WebScheduler { ...@@ -29,11 +29,11 @@ class CONTENT_EXPORT WebSchedulerImpl : public blink::WebScheduler {
virtual bool shouldYieldForHighPriorityWork(); virtual bool shouldYieldForHighPriorityWork();
virtual bool canExceedIdleDeadlineIfRequired(); virtual bool canExceedIdleDeadlineIfRequired();
virtual void postIdleTask(const blink::WebTraceLocation& location, virtual void postIdleTask(const blink::WebTraceLocation& location,
blink::WebScheduler::IdleTask* task); blink::WebThread::IdleTask* task);
virtual void postNonNestableIdleTask(const blink::WebTraceLocation& location, virtual void postNonNestableIdleTask(const blink::WebTraceLocation& location,
blink::WebScheduler::IdleTask* task); blink::WebThread::IdleTask* task);
virtual void postIdleTaskAfterWakeup(const blink::WebTraceLocation& location, virtual void postIdleTaskAfterWakeup(const blink::WebTraceLocation& location,
blink::WebScheduler::IdleTask* task); blink::WebThread::IdleTask* task);
virtual void postLoadingTask(const blink::WebTraceLocation& location, virtual void postLoadingTask(const blink::WebTraceLocation& location,
blink::WebThread::Task* task); blink::WebThread::Task* task);
virtual void postTimerTask(const blink::WebTraceLocation& location, virtual void postTimerTask(const blink::WebTraceLocation& location,
...@@ -41,7 +41,7 @@ class CONTENT_EXPORT WebSchedulerImpl : public blink::WebScheduler { ...@@ -41,7 +41,7 @@ class CONTENT_EXPORT WebSchedulerImpl : public blink::WebScheduler {
long long delayMs); long long delayMs);
private: private:
static void runIdleTask(scoped_ptr<blink::WebScheduler::IdleTask> task, static void runIdleTask(scoped_ptr<blink::WebThread::IdleTask> task,
base::TimeTicks deadline); base::TimeTicks deadline);
static void runTask(scoped_ptr<blink::WebThread::Task> task); static void runTask(scoped_ptr<blink::WebThread::Task> task);
......
...@@ -21,8 +21,8 @@ WebSchedulerImpl::~WebSchedulerImpl() { ...@@ -21,8 +21,8 @@ WebSchedulerImpl::~WebSchedulerImpl() {
} }
void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation& web_location, void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation& web_location,
blink::WebScheduler::IdleTask* task) { blink::WebThread::IdleTask* task) {
scoped_ptr<blink::WebScheduler::IdleTask> scoped_task(task); scoped_ptr<blink::WebThread::IdleTask> scoped_task(task);
tracked_objects::Location location(web_location.functionName(), tracked_objects::Location location(web_location.functionName(),
web_location.fileName(), -1, nullptr); web_location.fileName(), -1, nullptr);
task_runner_->PostTask(location, base::Bind(&WebSchedulerImpl::RunIdleTask, task_runner_->PostTask(location, base::Bind(&WebSchedulerImpl::RunIdleTask,
...@@ -54,7 +54,7 @@ void WebSchedulerImpl::postTimerTask( ...@@ -54,7 +54,7 @@ void WebSchedulerImpl::postTimerTask(
// static // static
void WebSchedulerImpl::RunIdleTask( void WebSchedulerImpl::RunIdleTask(
scoped_ptr<blink::WebScheduler::IdleTask> task) { scoped_ptr<blink::WebThread::IdleTask> task) {
// TODO(davemoore) Implement idle scheduling. // TODO(davemoore) Implement idle scheduling.
task->run(0); task->run(0);
} }
......
...@@ -20,14 +20,14 @@ class WebSchedulerImpl : public blink::WebScheduler { ...@@ -20,14 +20,14 @@ class WebSchedulerImpl : public blink::WebScheduler {
private: private:
// blink::WebScheduler overrides. // blink::WebScheduler overrides.
virtual void postIdleTask(const blink::WebTraceLocation& location, virtual void postIdleTask(const blink::WebTraceLocation& location,
blink::WebScheduler::IdleTask* task); blink::WebThread::IdleTask* task);
virtual void postLoadingTask(const blink::WebTraceLocation& location, virtual void postLoadingTask(const blink::WebTraceLocation& location,
blink::WebThread::Task* task); blink::WebThread::Task* task);
virtual void postTimerTask(const blink::WebTraceLocation& location, virtual void postTimerTask(const blink::WebTraceLocation& location,
blink::WebThread::Task* task, blink::WebThread::Task* task,
long long delayMs); long long delayMs);
static void RunIdleTask(scoped_ptr<blink::WebScheduler::IdleTask> task); static void RunIdleTask(scoped_ptr<blink::WebThread::IdleTask> task);
static void RunTask(scoped_ptr<blink::WebThread::Task> task); static void RunTask(scoped_ptr<blink::WebThread::Task> task);
scoped_refptr<base::SingleThreadTaskRunner> task_runner_; scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment