OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "public/platform/WebScheduler.h" |
| 7 |
| 8 #include "public/platform/WebTraceLocation.h" |
| 9 #include "wtf/Assertions.h" |
| 10 #include "wtf/OwnPtr.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 namespace { |
| 15 class TaskRunner : public WebThread::Task { |
| 16 WTF_MAKE_NONCOPYABLE(TaskRunner); |
| 17 public: |
| 18 explicit TaskRunner(PassOwnPtr<WebScheduler::Task> task) |
| 19 : m_task(task) |
| 20 { |
| 21 } |
| 22 |
| 23 ~TaskRunner() override |
| 24 { |
| 25 } |
| 26 |
| 27 // WebThread::Task implementation. |
| 28 void run() override |
| 29 { |
| 30 (*m_task)(); |
| 31 } |
| 32 |
| 33 private: |
| 34 OwnPtr<WebScheduler::Task> m_task; |
| 35 }; |
| 36 |
| 37 class IdleTaskRunner : public WebThread::IdleTask { |
| 38 WTF_MAKE_NONCOPYABLE(IdleTaskRunner); |
| 39 |
| 40 public: |
| 41 explicit IdleTaskRunner(PassOwnPtr<WebScheduler::IdleTask> task) |
| 42 : m_task(task) |
| 43 { |
| 44 } |
| 45 |
| 46 ~IdleTaskRunner() override |
| 47 { |
| 48 } |
| 49 |
| 50 // WebThread::IdleTask implementation. |
| 51 void run(double deadlineSeconds) override |
| 52 { |
| 53 (*m_task)(deadlineSeconds); |
| 54 } |
| 55 |
| 56 private: |
| 57 OwnPtr<WebScheduler::IdleTask> m_task; |
| 58 }; |
| 59 |
| 60 } // namespace |
| 61 |
| 62 void WebScheduler::postIdleTask(const WebTraceLocation& location, PassOwnPtr<Idl
eTask> idleTask) |
| 63 { |
| 64 postIdleTask(location, new IdleTaskRunner(idleTask)); |
| 65 } |
| 66 |
| 67 void WebScheduler::postNonNestableIdleTask(const WebTraceLocation& location, Pas
sOwnPtr<IdleTask> idleTask) |
| 68 { |
| 69 postNonNestableIdleTask(location, new IdleTaskRunner(idleTask)); |
| 70 } |
| 71 |
| 72 void WebScheduler::postIdleTaskAfterWakeup(const WebTraceLocation& location, Pas
sOwnPtr<IdleTask> idleTask) |
| 73 { |
| 74 postIdleTaskAfterWakeup(location, new IdleTaskRunner(idleTask)); |
| 75 } |
| 76 |
| 77 void WebScheduler::postLoadingTask(const WebTraceLocation& location, PassOwnPtr<
Task> task) |
| 78 { |
| 79 postLoadingTask(location, new TaskRunner(task)); |
| 80 } |
| 81 |
| 82 } // namespace blink |
OLD | NEW |