| OLD | NEW |
| 1 // Copyright 2015 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 // An implementation of WebThread in terms of base::MessageLoop and | 5 // An implementation of WebThread in terms of base::MessageLoop and |
| 6 // base::Thread | 6 // base::Thread |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/tracked_objects.h" | 10 #include "base/tracked_objects.h" |
| 11 #include "mojo/services/html_viewer/webscheduler_impl.h" | 11 #include "mojo/services/html_viewer/webscheduler_impl.h" |
| 12 | 12 |
| 13 namespace html_viewer { | 13 namespace html_viewer { |
| 14 | 14 |
| 15 WebSchedulerImpl::WebSchedulerImpl( | 15 WebSchedulerImpl::WebSchedulerImpl( |
| 16 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 16 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
| 17 : task_runner_(task_runner) { | 17 : task_runner_(task_runner) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 WebSchedulerImpl::~WebSchedulerImpl() { | 20 WebSchedulerImpl::~WebSchedulerImpl() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation& web_location, | 23 void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation& web_location, |
| 24 blink::WebScheduler::IdleTask* task) { | 24 blink::WebThread::IdleTask* task) { |
| 25 scoped_ptr<blink::WebScheduler::IdleTask> scoped_task(task); | 25 scoped_ptr<blink::WebThread::IdleTask> scoped_task(task); |
| 26 tracked_objects::Location location(web_location.functionName(), | 26 tracked_objects::Location location(web_location.functionName(), |
| 27 web_location.fileName(), -1, nullptr); | 27 web_location.fileName(), -1, nullptr); |
| 28 task_runner_->PostTask(location, base::Bind(&WebSchedulerImpl::RunIdleTask, | 28 task_runner_->PostTask(location, base::Bind(&WebSchedulerImpl::RunIdleTask, |
| 29 base::Passed(&scoped_task))); | 29 base::Passed(&scoped_task))); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void WebSchedulerImpl::postLoadingTask( | 32 void WebSchedulerImpl::postLoadingTask( |
| 33 const blink::WebTraceLocation& web_location, | 33 const blink::WebTraceLocation& web_location, |
| 34 blink::WebThread::Task* task) { | 34 blink::WebThread::Task* task) { |
| 35 scoped_ptr<blink::WebThread::Task> scoped_task(task); | 35 scoped_ptr<blink::WebThread::Task> scoped_task(task); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 47 tracked_objects::Location location(web_location.functionName(), | 47 tracked_objects::Location location(web_location.functionName(), |
| 48 web_location.fileName(), -1, nullptr); | 48 web_location.fileName(), -1, nullptr); |
| 49 task_runner_->PostDelayedTask( | 49 task_runner_->PostDelayedTask( |
| 50 location, | 50 location, |
| 51 base::Bind(&WebSchedulerImpl::RunTask, base::Passed(&scoped_task)), | 51 base::Bind(&WebSchedulerImpl::RunTask, base::Passed(&scoped_task)), |
| 52 base::TimeDelta::FromMilliseconds(delayMs)); | 52 base::TimeDelta::FromMilliseconds(delayMs)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 // static | 55 // static |
| 56 void WebSchedulerImpl::RunIdleTask( | 56 void WebSchedulerImpl::RunIdleTask( |
| 57 scoped_ptr<blink::WebScheduler::IdleTask> task) { | 57 scoped_ptr<blink::WebThread::IdleTask> task) { |
| 58 // TODO(davemoore) Implement idle scheduling. | 58 // TODO(davemoore) Implement idle scheduling. |
| 59 task->run(0); | 59 task->run(0); |
| 60 } | 60 } |
| 61 | 61 |
| 62 // static | 62 // static |
| 63 void WebSchedulerImpl::RunTask(scoped_ptr<blink::WebThread::Task> task) { | 63 void WebSchedulerImpl::RunTask(scoped_ptr<blink::WebThread::Task> task) { |
| 64 task->run(); | 64 task->run(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 } // namespace html_viewer | 67 } // namespace html_viewer |
| OLD | NEW |