| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 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); |
| 36 tracked_objects::Location location(web_location.functionName(), | 36 tracked_objects::Location location(web_location.functionName(), |
| 37 web_location.fileName(), -1, nullptr); | 37 web_location.fileName(), -1, nullptr); |
| 38 task_runner_->PostTask(location, base::Bind(&WebSchedulerImpl::RunTask, | 38 task_runner_->PostTask(location, base::Bind(&WebSchedulerImpl::RunTask, |
| 39 base::Passed(&scoped_task))); | 39 base::Passed(&scoped_task))); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void WebSchedulerImp::postTimerTask(const WebTraceLocation& web_location, |
| 43 blink::WebThread::Task* task, |
| 44 long long delayMs) { |
| 45 scoped_ptr<blink::WebThread::Task> scoped_task(task); |
| 46 tracked_objects::Location location(web_location.functionName(), |
| 47 web_location.fileName(), -1, nullptr); |
| 48 task_runner_->PostDelayedTask( |
| 49 location, |
| 50 base::Bind(&WebSchedulerImpl::RunTask, base::Passed(&scoped_task)), |
| 51 base::TimeDelta::FromMilliseconds(delayMs)); |
| 52 } |
| 53 |
| 42 void WebSchedulerImpl::shutdown() { | 54 void WebSchedulerImpl::shutdown() { |
| 43 task_runner_ = nullptr; | 55 task_runner_ = nullptr; |
| 44 } | 56 } |
| 45 | 57 |
| 46 // static | 58 // static |
| 47 void WebSchedulerImpl::RunIdleTask( | 59 void WebSchedulerImpl::RunIdleTask( |
| 48 scoped_ptr<blink::WebScheduler::IdleTask> task) { | 60 scoped_ptr<blink::WebScheduler::IdleTask> task) { |
| 49 // TODO(davemoore) Implement idle scheduling. | 61 // TODO(davemoore) Implement idle scheduling. |
| 50 task->run(0); | 62 task->run(0); |
| 51 } | 63 } |
| 52 | 64 |
| 53 // static | 65 // static |
| 54 void WebSchedulerImpl::RunTask(scoped_ptr<blink::WebThread::Task> task) { | 66 void WebSchedulerImpl::RunTask(scoped_ptr<blink::WebThread::Task> task) { |
| 55 task->run(); | 67 task->run(); |
| 56 } | 68 } |
| 57 | 69 |
| 58 } // namespace html_viewer | 70 } // namespace html_viewer |
| OLD | NEW |