Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: Source/platform/scheduler/Scheduler.cpp

Issue 876623002: Adds a CancellableTaskFactory and exposes postLoadingTasks to Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Bundle in the HTML Parser changes too Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "public/platform/WebTraceLocation.h" 11 #include "public/platform/WebTraceLocation.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 class IdleTaskRunner : public WebScheduler::IdleTask { 15 class IdleTaskRunner : public WebScheduler::IdleTask {
16 WTF_MAKE_NONCOPYABLE(IdleTaskRunner);
16 public: 17 public:
17 explicit IdleTaskRunner(PassOwnPtr<Scheduler::IdleTask> task) 18 explicit IdleTaskRunner(PassOwnPtr<Scheduler::IdleTask> task)
18 : m_task(task) 19 : m_task(task)
19 { 20 {
20 } 21 }
21 22
22 virtual ~IdleTaskRunner() 23 virtual ~IdleTaskRunner()
23 { 24 {
24 } 25 }
25 26
26 // WebScheduler::IdleTask implementation. 27 // WebScheduler::IdleTask implementation.
27 void run(double deadlineSeconds) override 28 void run(double deadlineSeconds) override
28 { 29 {
29 (*m_task)(deadlineSeconds); 30 (*m_task)(deadlineSeconds);
30 } 31 }
31 private: 32 private:
32 OwnPtr<Scheduler::IdleTask> m_task; 33 OwnPtr<Scheduler::IdleTask> m_task;
33 }; 34 };
34 35
36 class ClosureRunner : public WebThread::Task {
37 WTF_MAKE_NONCOPYABLE(ClosureRunner);
38 public:
39 explicit ClosureRunner(PassOwnPtr<Closure> closure) : m_closure(closure)
40 {
41 }
42
43 virtual ~ClosureRunner()
Sami 2015/01/26 17:18:34 s/virtual/override/
alex clarke (OOO till 29th) 2015/01/26 17:31:35 Done.
44 {
45 }
46
47 // WebThread::Task implementation.
48 void run() override
49 {
50 (*m_closure)();
51 }
52 private:
53 OwnPtr<Closure> m_closure;
54 };
55
35 Scheduler* Scheduler::s_sharedScheduler = nullptr; 56 Scheduler* Scheduler::s_sharedScheduler = nullptr;
36 57
37 void Scheduler::shutdown() 58 void Scheduler::shutdown()
38 { 59 {
39 delete s_sharedScheduler; 60 delete s_sharedScheduler;
40 s_sharedScheduler = nullptr; 61 s_sharedScheduler = nullptr;
41 } 62 }
42 63
43 Scheduler* Scheduler::shared() 64 Scheduler* Scheduler::shared()
44 { 65 {
(...skipping 12 matching lines...) Expand all
57 if (m_webScheduler) 78 if (m_webScheduler)
58 m_webScheduler->shutdown(); 79 m_webScheduler->shutdown();
59 } 80 }
60 81
61 void Scheduler::postIdleTask(const TraceLocation& location, PassOwnPtr<IdleTask> idleTask) 82 void Scheduler::postIdleTask(const TraceLocation& location, PassOwnPtr<IdleTask> idleTask)
62 { 83 {
63 if (m_webScheduler) 84 if (m_webScheduler)
64 m_webScheduler->postIdleTask(WebTraceLocation(location), new IdleTaskRun ner(idleTask)); 85 m_webScheduler->postIdleTask(WebTraceLocation(location), new IdleTaskRun ner(idleTask));
65 } 86 }
66 87
88 void Scheduler::postLoadingTask(const TraceLocation& location, PassOwnPtr<Closur e> closure)
89 {
90 if (m_webScheduler)
91 m_webScheduler->postLoadingTask(WebTraceLocation(location), new ClosureR unner(closure));
92 }
93
67 bool Scheduler::shouldYieldForHighPriorityWork() const 94 bool Scheduler::shouldYieldForHighPriorityWork() const
68 { 95 {
69 if (m_webScheduler) 96 if (m_webScheduler)
70 return m_webScheduler->shouldYieldForHighPriorityWork(); 97 return m_webScheduler->shouldYieldForHighPriorityWork();
71 return false; 98 return false;
72 } 99 }
73 100
74 } // namespace blink 101 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698