OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
6 #include "platform/scheduler/Scheduler.h" | 6 #include "platform/scheduler/Scheduler.h" |
7 | 7 |
8 #include "platform/TraceLocation.h" | 8 #include "platform/TraceLocation.h" |
9 #include "public/platform/Platform.h" | 9 #include "public/platform/Platform.h" |
10 #include "public/platform/WebScheduler.h" | 10 #include "public/platform/WebScheduler.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 | 25 |
26 // WebScheduler::IdleTask implementation. | 26 // WebScheduler::IdleTask implementation. |
27 void run(double deadlineSeconds) override | 27 void run(double deadlineSeconds) override |
28 { | 28 { |
29 (*m_task)(deadlineSeconds); | 29 (*m_task)(deadlineSeconds); |
30 } | 30 } |
31 private: | 31 private: |
32 OwnPtr<Scheduler::IdleTask> m_task; | 32 OwnPtr<Scheduler::IdleTask> m_task; |
33 }; | 33 }; |
34 | 34 |
35 class ClosureRunner : public WebThread::Task { | |
rmcilroy
2015/01/26 18:09:01
nit - ClosureRunnerTask (if you take my suggestion
alex clarke (OOO till 29th)
2015/01/27 11:41:19
Done.
| |
36 public: | |
jochen (gone - plz use gerrit)
2015/01/26 15:53:31
non-copyable
alex clarke (OOO till 29th)
2015/01/26 17:00:45
Done.
| |
37 explicit ClosureRunner(PassOwnPtr<Closure> closure) : m_closure(closure) | |
38 { | |
39 } | |
40 | |
41 virtual ~ClosureRunner() | |
42 { | |
43 } | |
44 | |
45 // WebThread::Task implementation. | |
46 void run() override | |
47 { | |
48 (*m_closure)(); | |
49 } | |
50 private: | |
51 OwnPtr<Closure> m_closure; | |
52 }; | |
53 | |
35 Scheduler* Scheduler::s_sharedScheduler = nullptr; | 54 Scheduler* Scheduler::s_sharedScheduler = nullptr; |
36 | 55 |
37 void Scheduler::shutdown() | 56 void Scheduler::shutdown() |
38 { | 57 { |
39 delete s_sharedScheduler; | 58 delete s_sharedScheduler; |
40 s_sharedScheduler = nullptr; | 59 s_sharedScheduler = nullptr; |
41 } | 60 } |
42 | 61 |
43 Scheduler* Scheduler::shared() | 62 Scheduler* Scheduler::shared() |
44 { | 63 { |
(...skipping 12 matching lines...) Expand all Loading... | |
57 if (m_webScheduler) | 76 if (m_webScheduler) |
58 m_webScheduler->shutdown(); | 77 m_webScheduler->shutdown(); |
59 } | 78 } |
60 | 79 |
61 void Scheduler::postIdleTask(const TraceLocation& location, PassOwnPtr<IdleTask> idleTask) | 80 void Scheduler::postIdleTask(const TraceLocation& location, PassOwnPtr<IdleTask> idleTask) |
62 { | 81 { |
63 if (m_webScheduler) | 82 if (m_webScheduler) |
64 m_webScheduler->postIdleTask(WebTraceLocation(location), new IdleTaskRun ner(idleTask)); | 83 m_webScheduler->postIdleTask(WebTraceLocation(location), new IdleTaskRun ner(idleTask)); |
65 } | 84 } |
66 | 85 |
86 void Scheduler::postLoadingTask(const TraceLocation& location, PassOwnPtr<Closur e> closure) | |
87 { | |
88 if (m_webScheduler) | |
89 m_webScheduler->postLoadingTask(WebTraceLocation(location), new ClosureR unner(closure)); | |
90 } | |
91 | |
67 bool Scheduler::shouldYieldForHighPriorityWork() const | 92 bool Scheduler::shouldYieldForHighPriorityWork() const |
68 { | 93 { |
69 if (m_webScheduler) | 94 if (m_webScheduler) |
70 return m_webScheduler->shouldYieldForHighPriorityWork(); | 95 return m_webScheduler->shouldYieldForHighPriorityWork(); |
71 return false; | 96 return false; |
72 } | 97 } |
73 | 98 |
74 } // namespace blink | 99 } // namespace blink |
OLD | NEW |