| 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 #include "components/scheduler/child/web_task_runner_impl.h" | 5 #include "components/scheduler/child/web_task_runner_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "components/scheduler/base/task_queue.h" | 9 #include "components/scheduler/base/task_queue.h" |
| 10 #include "components/scheduler/base/time_domain.h" | 10 #include "components/scheduler/base/time_domain.h" |
| 11 #include "third_party/WebKit/public/platform/WebTraceLocation.h" | 11 #include "third_party/WebKit/public/platform/WebTraceLocation.h" |
| 12 | 12 |
| 13 namespace scheduler { | 13 namespace scheduler { |
| 14 | 14 |
| 15 WebTaskRunnerImpl::WebTaskRunnerImpl(scoped_refptr<TaskQueue> task_queue) | 15 WebTaskRunnerImpl::WebTaskRunnerImpl(scoped_refptr<TaskQueue> task_queue) |
| 16 : task_queue_(task_queue) {} | 16 : task_queue_(task_queue) {} |
| 17 | 17 |
| 18 WebTaskRunnerImpl::~WebTaskRunnerImpl() {} | 18 WebTaskRunnerImpl::~WebTaskRunnerImpl() {} |
| 19 | 19 |
| 20 void WebTaskRunnerImpl::postTask(const blink::WebTraceLocation& web_location, | 20 void WebTaskRunnerImpl::postTask(const blink::WebTraceLocation& web_location, |
| 21 blink::WebTaskRunner::Task* task) { | 21 blink::WebTaskRunner::Task* task) { |
| 22 tracked_objects::Location location(web_location.functionName(), | 22 tracked_objects::Location location(web_location.functionName(), |
| 23 web_location.fileName(), -1, nullptr); | 23 web_location.fileName(), |
| 24 web_location.lineNumber(), |
| 25 web_location.programCounter()); |
| 24 task_queue_->PostTask( | 26 task_queue_->PostTask( |
| 25 location, | 27 location, |
| 26 base::Bind( | 28 base::Bind( |
| 27 &WebTaskRunnerImpl::runTask, | 29 &WebTaskRunnerImpl::runTask, |
| 28 base::Passed(std::unique_ptr<blink::WebTaskRunner::Task>(task)))); | 30 base::Passed(std::unique_ptr<blink::WebTaskRunner::Task>(task)))); |
| 29 } | 31 } |
| 30 | 32 |
| 31 void WebTaskRunnerImpl::postDelayedTask( | 33 void WebTaskRunnerImpl::postDelayedTask( |
| 32 const blink::WebTraceLocation& web_location, | 34 const blink::WebTraceLocation& web_location, |
| 33 blink::WebTaskRunner::Task* task, | 35 blink::WebTaskRunner::Task* task, |
| 34 double delayMs) { | 36 double delayMs) { |
| 35 DCHECK_GE(delayMs, 0.0); | 37 DCHECK_GE(delayMs, 0.0); |
| 36 tracked_objects::Location location(web_location.functionName(), | 38 tracked_objects::Location location(web_location.functionName(), |
| 37 web_location.fileName(), -1, nullptr); | 39 web_location.fileName(), |
| 40 web_location.lineNumber(), |
| 41 web_location.programCounter()); |
| 38 task_queue_->PostDelayedTask( | 42 task_queue_->PostDelayedTask( |
| 39 location, | 43 location, |
| 40 base::Bind( | 44 base::Bind( |
| 41 &WebTaskRunnerImpl::runTask, | 45 &WebTaskRunnerImpl::runTask, |
| 42 base::Passed(std::unique_ptr<blink::WebTaskRunner::Task>(task))), | 46 base::Passed(std::unique_ptr<blink::WebTaskRunner::Task>(task))), |
| 43 base::TimeDelta::FromMillisecondsD(delayMs)); | 47 base::TimeDelta::FromMillisecondsD(delayMs)); |
| 44 } | 48 } |
| 45 | 49 |
| 46 double WebTaskRunnerImpl::virtualTimeSeconds() const { | 50 double WebTaskRunnerImpl::virtualTimeSeconds() const { |
| 47 return (Now() - base::TimeTicks::UnixEpoch()).InSecondsF(); | 51 return (Now() - base::TimeTicks::UnixEpoch()).InSecondsF(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 64 blink::WebTaskRunner* WebTaskRunnerImpl::clone() { | 68 blink::WebTaskRunner* WebTaskRunnerImpl::clone() { |
| 65 return new WebTaskRunnerImpl(task_queue_); | 69 return new WebTaskRunnerImpl(task_queue_); |
| 66 } | 70 } |
| 67 | 71 |
| 68 void WebTaskRunnerImpl::runTask( | 72 void WebTaskRunnerImpl::runTask( |
| 69 std::unique_ptr<blink::WebTaskRunner::Task> task) { | 73 std::unique_ptr<blink::WebTaskRunner::Task> task) { |
| 70 task->run(); | 74 task->run(); |
| 71 } | 75 } |
| 72 | 76 |
| 73 } // namespace scheduler | 77 } // namespace scheduler |
| OLD | NEW |