| 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 "platform/scheduler/child/web_task_runner_impl.h" | 5 #include "platform/scheduler/child/web_task_runner_impl.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/location.h" | 10 #include "base/location.h" |
| 9 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 10 #include "public/platform/scheduler/base/task_queue.h" | 12 #include "public/platform/scheduler/base/task_queue.h" |
| 11 #include "platform/scheduler/base/time_domain.h" | 13 #include "platform/scheduler/base/time_domain.h" |
| 12 #include "public/platform/WebTraceLocation.h" | 14 #include "public/platform/WebTraceLocation.h" |
| 13 | 15 |
| 14 namespace blink { | 16 namespace blink { |
| 15 namespace scheduler { | 17 namespace scheduler { |
| 16 | 18 |
| 17 RefPtr<WebTaskRunnerImpl> WebTaskRunnerImpl::create( | 19 RefPtr<WebTaskRunnerImpl> WebTaskRunnerImpl::create( |
| 18 scoped_refptr<TaskQueue> task_queue) { | 20 scoped_refptr<TaskQueue> task_queue) { |
| 19 return adoptRef(new WebTaskRunnerImpl(std::move(task_queue))); | 21 return adoptRef(new WebTaskRunnerImpl(std::move(task_queue))); |
| 20 } | 22 } |
| 21 | 23 |
| 22 void WebTaskRunnerImpl::postDelayedTask(const WebTraceLocation& location, | 24 void WebTaskRunnerImpl::postDelayedTask(const WebTraceLocation& location, |
| 23 const base::Closure& task, | 25 base::Closure task, |
| 24 double delayMs) { | 26 double delayMs) { |
| 25 DCHECK_GE(delayMs, 0.0) << location.function_name() << " " | 27 DCHECK_GE(delayMs, 0.0) << location.function_name() << " " |
| 26 << location.file_name(); | 28 << location.file_name(); |
| 27 task_queue_->PostDelayedTask(location, task, | 29 task_queue_->PostDelayedTask(location, std::move(task), |
| 28 base::TimeDelta::FromMillisecondsD(delayMs)); | 30 base::TimeDelta::FromMillisecondsD(delayMs)); |
| 29 } | 31 } |
| 30 | 32 |
| 31 bool WebTaskRunnerImpl::runsTasksOnCurrentThread() { | 33 bool WebTaskRunnerImpl::runsTasksOnCurrentThread() { |
| 32 return task_queue_->RunsTasksOnCurrentThread(); | 34 return task_queue_->RunsTasksOnCurrentThread(); |
| 33 } | 35 } |
| 34 | 36 |
| 35 double WebTaskRunnerImpl::virtualTimeSeconds() const { | 37 double WebTaskRunnerImpl::virtualTimeSeconds() const { |
| 36 return (Now() - base::TimeTicks::UnixEpoch()).InSecondsF(); | 38 return (Now() - base::TimeTicks::UnixEpoch()).InSecondsF(); |
| 37 } | 39 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 54 return base::TimeTicks::Now(); | 56 return base::TimeTicks::Now(); |
| 55 return time_domain->Now(); | 57 return time_domain->Now(); |
| 56 } | 58 } |
| 57 | 59 |
| 58 base::SingleThreadTaskRunner* WebTaskRunnerImpl::toSingleThreadTaskRunner() { | 60 base::SingleThreadTaskRunner* WebTaskRunnerImpl::toSingleThreadTaskRunner() { |
| 59 return task_queue_.get(); | 61 return task_queue_.get(); |
| 60 } | 62 } |
| 61 | 63 |
| 62 } // namespace scheduler | 64 } // namespace scheduler |
| 63 } // namespace blink | 65 } // namespace blink |
| OLD | NEW |