| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/scheduler/child/webthread_base.h" | 8 #include "components/scheduler/child/webthread_base.h" |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 base::MessageLoop::current()->RemoveTaskObserver(observer); | 73 base::MessageLoop::current()->RemoveTaskObserver(observer); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // static | 76 // static |
| 77 void WebThreadBase::RunWebThreadIdleTask( | 77 void WebThreadBase::RunWebThreadIdleTask( |
| 78 std::unique_ptr<blink::WebThread::IdleTask> idle_task, | 78 std::unique_ptr<blink::WebThread::IdleTask> idle_task, |
| 79 base::TimeTicks deadline) { | 79 base::TimeTicks deadline) { |
| 80 idle_task->run((deadline - base::TimeTicks()).InSecondsF()); | 80 idle_task->run((deadline - base::TimeTicks()).InSecondsF()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void WebThreadBase::postIdleTask(const blink::WebTraceLocation& location, | 83 void WebThreadBase::postIdleTask(const blink::WebTraceLocation& web_location, |
| 84 IdleTask* idle_task) { | 84 IdleTask* idle_task) { |
| 85 tracked_objects::Location location(web_location.functionName(), |
| 86 web_location.fileName(), -1, nullptr); |
| 85 GetIdleTaskRunner()->PostIdleTask( | 87 GetIdleTaskRunner()->PostIdleTask( |
| 86 location, | 88 location, base::Bind(&WebThreadBase::RunWebThreadIdleTask, |
| 87 base::Bind(&WebThreadBase::RunWebThreadIdleTask, | 89 base::Passed(base::WrapUnique(idle_task)))); |
| 88 base::Passed(base::WrapUnique(idle_task)))); | |
| 89 } | 90 } |
| 90 | 91 |
| 91 void WebThreadBase::postIdleTaskAfterWakeup( | 92 void WebThreadBase::postIdleTaskAfterWakeup( |
| 92 const blink::WebTraceLocation& location, | 93 const blink::WebTraceLocation& web_location, |
| 93 IdleTask* idle_task) { | 94 IdleTask* idle_task) { |
| 95 tracked_objects::Location location(web_location.functionName(), |
| 96 web_location.fileName(), -1, nullptr); |
| 94 GetIdleTaskRunner()->PostIdleTaskAfterWakeup( | 97 GetIdleTaskRunner()->PostIdleTaskAfterWakeup( |
| 95 location, | 98 location, base::Bind(&WebThreadBase::RunWebThreadIdleTask, |
| 96 base::Bind(&WebThreadBase::RunWebThreadIdleTask, | 99 base::Passed(base::WrapUnique(idle_task)))); |
| 97 base::Passed(base::WrapUnique(idle_task)))); | |
| 98 } | 100 } |
| 99 | 101 |
| 100 bool WebThreadBase::isCurrentThread() const { | 102 bool WebThreadBase::isCurrentThread() const { |
| 101 return GetTaskRunner()->BelongsToCurrentThread(); | 103 return GetTaskRunner()->BelongsToCurrentThread(); |
| 102 } | 104 } |
| 103 | 105 |
| 104 } // namespace scheduler | 106 } // namespace scheduler |
| OLD | NEW |