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 #if OS(WIN) | |
Sami
2015/04/16 14:02:05
Drop this too?
alex clarke (OOO till 29th)
2015/04/16 14:17:43
Done.
| |
13 #include <windows.h> | |
14 #elif OS(POSIX) | |
15 #include <unistd.h> | |
16 #endif | |
17 | |
18 namespace blink { | |
19 | |
20 namespace { | |
21 class TaskRunner : public WebThread::Task { | |
22 WTF_MAKE_NONCOPYABLE(TaskRunner); | |
23 | |
24 public: | |
25 explicit TaskRunner(PassOwnPtr<WebScheduler::Task> task) | |
26 : m_task(task) | |
27 { | |
28 } | |
29 | |
30 ~TaskRunner() override | |
31 { | |
32 } | |
33 | |
34 // WebThread::Task implementation. | |
35 void run() override | |
36 { | |
37 (*m_task)(); | |
38 } | |
39 private: | |
40 OwnPtr<WebScheduler::Task> m_task; | |
41 }; | |
42 | |
43 class IdleTaskRunner : public WebThread::IdleTask { | |
44 WTF_MAKE_NONCOPYABLE(IdleTaskRunner); | |
45 | |
46 public: | |
47 explicit IdleTaskRunner(PassOwnPtr<WebScheduler::IdleTask> task) | |
48 : m_task(task) | |
49 { | |
50 } | |
51 | |
52 ~IdleTaskRunner() override | |
53 { | |
54 } | |
55 | |
56 // WebThread::IdleTask implementation. | |
57 void run(double deadlineSeconds) override | |
58 { | |
59 (*m_task)(deadlineSeconds); | |
60 } | |
61 private: | |
62 OwnPtr<WebScheduler::IdleTask> m_task; | |
63 }; | |
64 | |
65 } // namespace | |
66 | |
67 void WebScheduler::postIdleTask(const WebTraceLocation& location, PassOwnPtr<Idl eTask> idleTask) | |
68 { | |
69 postIdleTask(location, new IdleTaskRunner(idleTask)); | |
70 } | |
71 | |
72 void WebScheduler::postNonNestableIdleTask(const WebTraceLocation& location, Pas sOwnPtr<IdleTask> idleTask) | |
73 { | |
74 postNonNestableIdleTask(location, new IdleTaskRunner(idleTask)); | |
75 } | |
76 | |
77 void WebScheduler::postIdleTaskAfterWakeup(const WebTraceLocation& location, Pas sOwnPtr<IdleTask> idleTask) | |
78 { | |
79 postIdleTaskAfterWakeup(location, new IdleTaskRunner(idleTask)); | |
80 } | |
81 | |
82 void WebScheduler::postLoadingTask(const WebTraceLocation& location, PassOwnPtr< Task> task) | |
83 { | |
84 postLoadingTask(location, new TaskRunner(task)); | |
85 } | |
86 | |
87 } // namespace blink | |
OLD | NEW |