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

Side by Side Diff: Source/platform/WebScheduler.cpp

Issue 1087203002: Patch 2/3 to get WebScheduler via WebThread (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Style nits Created 5 years, 8 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
« no previous file with comments | « Source/platform/ThreadTimers.cpp ('k') | Source/platform/blink_platform.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « Source/platform/ThreadTimers.cpp ('k') | Source/platform/blink_platform.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698