| 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& web_location, | 83 void WebThreadBase::postIdleTask(const blink::WebTraceLocation& location, |
| 84 IdleTask* idle_task) { | 84 IdleTask* idle_task) { |
| 85 tracked_objects::Location location(web_location.functionName(), | |
| 86 web_location.fileName(), -1, nullptr); | |
| 87 GetIdleTaskRunner()->PostIdleTask( | 85 GetIdleTaskRunner()->PostIdleTask( |
| 88 location, base::Bind(&WebThreadBase::RunWebThreadIdleTask, | 86 location, |
| 89 base::Passed(base::WrapUnique(idle_task)))); | 87 base::Bind(&WebThreadBase::RunWebThreadIdleTask, |
| 88 base::Passed(base::WrapUnique(idle_task)))); |
| 90 } | 89 } |
| 91 | 90 |
| 92 void WebThreadBase::postIdleTaskAfterWakeup( | 91 void WebThreadBase::postIdleTaskAfterWakeup( |
| 93 const blink::WebTraceLocation& web_location, | 92 const blink::WebTraceLocation& location, |
| 94 IdleTask* idle_task) { | 93 IdleTask* idle_task) { |
| 95 tracked_objects::Location location(web_location.functionName(), | |
| 96 web_location.fileName(), -1, nullptr); | |
| 97 GetIdleTaskRunner()->PostIdleTaskAfterWakeup( | 94 GetIdleTaskRunner()->PostIdleTaskAfterWakeup( |
| 98 location, base::Bind(&WebThreadBase::RunWebThreadIdleTask, | 95 location, |
| 99 base::Passed(base::WrapUnique(idle_task)))); | 96 base::Bind(&WebThreadBase::RunWebThreadIdleTask, |
| 97 base::Passed(base::WrapUnique(idle_task)))); |
| 100 } | 98 } |
| 101 | 99 |
| 102 bool WebThreadBase::isCurrentThread() const { | 100 bool WebThreadBase::isCurrentThread() const { |
| 103 return GetTaskRunner()->BelongsToCurrentThread(); | 101 return GetTaskRunner()->BelongsToCurrentThread(); |
| 104 } | 102 } |
| 105 | 103 |
| 106 } // namespace scheduler | 104 } // namespace scheduler |
| OLD | NEW |