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