| 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" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 tracked_objects::Location location(web_location.functionName(), | 36 tracked_objects::Location location(web_location.functionName(), |
| 37 web_location.fileName(), -1, nullptr); | 37 web_location.fileName(), -1, nullptr); |
| 38 task_queue_->PostDelayedTask( | 38 task_queue_->PostDelayedTask( |
| 39 location, | 39 location, |
| 40 base::Bind( | 40 base::Bind( |
| 41 &WebTaskRunnerImpl::runTask, | 41 &WebTaskRunnerImpl::runTask, |
| 42 base::Passed(std::unique_ptr<blink::WebTaskRunner::Task>(task))), | 42 base::Passed(std::unique_ptr<blink::WebTaskRunner::Task>(task))), |
| 43 base::TimeDelta::FromMillisecondsD(delayMs)); | 43 base::TimeDelta::FromMillisecondsD(delayMs)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool WebTaskRunnerImpl::runsTasksOnCurrentThread() { |
| 47 return task_queue_->RunsTasksOnCurrentThread(); |
| 48 } |
| 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(); |
| 48 } | 52 } |
| 49 | 53 |
| 50 double WebTaskRunnerImpl::monotonicallyIncreasingVirtualTimeSeconds() const { | 54 double WebTaskRunnerImpl::monotonicallyIncreasingVirtualTimeSeconds() const { |
| 51 return Now().ToInternalValue() / | 55 return Now().ToInternalValue() / |
| 52 static_cast<double>(base::Time::kMicrosecondsPerSecond); | 56 static_cast<double>(base::Time::kMicrosecondsPerSecond); |
| 53 } | 57 } |
| 54 | 58 |
| 55 base::TimeTicks WebTaskRunnerImpl::Now() const { | 59 base::TimeTicks WebTaskRunnerImpl::Now() const { |
| 56 TimeDomain* time_domain = task_queue_->GetTimeDomain(); | 60 TimeDomain* time_domain = task_queue_->GetTimeDomain(); |
| 57 // It's possible task_queue_ has been Unregistered which can lead to a null | 61 // It's possible task_queue_ has been Unregistered which can lead to a null |
| 58 // TimeDomain. If that happens just return the current real time. | 62 // TimeDomain. If that happens just return the current real time. |
| 59 if (!time_domain) | 63 if (!time_domain) |
| 60 return base::TimeTicks::Now(); | 64 return base::TimeTicks::Now(); |
| 61 return time_domain->Now(); | 65 return time_domain->Now(); |
| 62 } | 66 } |
| 63 | 67 |
| 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 |