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

Side by Side Diff: Source/core/dom/MainThreadTaskRunner.cpp

Issue 1303153005: Introduce WebTaskRunner Patch 3/5 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add missing #include Created 5 years, 3 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/core/dom/Document.cpp ('k') | Source/core/dom/Microtask.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All Rights Reserved. 2 * Copyright (C) 2013 Google Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 17 matching lines...) Expand all
28 #include "core/dom/MainThreadTaskRunner.h" 28 #include "core/dom/MainThreadTaskRunner.h"
29 29
30 #include "core/dom/ExecutionContext.h" 30 #include "core/dom/ExecutionContext.h"
31 #include "core/dom/ExecutionContextTask.h" 31 #include "core/dom/ExecutionContextTask.h"
32 #include "core/inspector/InspectorInstrumentation.h" 32 #include "core/inspector/InspectorInstrumentation.h"
33 #include "public/platform/Platform.h" 33 #include "public/platform/Platform.h"
34 #include "wtf/Assertions.h" 34 #include "wtf/Assertions.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 class MainThreadTask : public WebThread::Task { 38 class MainThreadTask : public WebTaskRunner::Task {
39 WTF_MAKE_NONCOPYABLE(MainThreadTask); WTF_MAKE_FAST_ALLOCATED(MainThreadTask ); 39 WTF_MAKE_NONCOPYABLE(MainThreadTask); WTF_MAKE_FAST_ALLOCATED(MainThreadTask );
40 public: 40 public:
41 MainThreadTask(WeakPtrWillBeRawPtr<MainThreadTaskRunner> runner, PassOwnPtr< ExecutionContextTask> task, bool isInspectorTask) 41 MainThreadTask(WeakPtrWillBeRawPtr<MainThreadTaskRunner> runner, PassOwnPtr< ExecutionContextTask> task, bool isInspectorTask)
42 : m_runner(runner) 42 : m_runner(runner)
43 , m_task(task) 43 , m_task(task)
44 , m_isInspectorTask(isInspectorTask) 44 , m_isInspectorTask(isInspectorTask)
45 { 45 {
46 } 46 }
47 47
48 void run() override; 48 void run() override;
(...skipping 29 matching lines...) Expand all
78 78
79 DEFINE_TRACE(MainThreadTaskRunner) 79 DEFINE_TRACE(MainThreadTaskRunner)
80 { 80 {
81 visitor->trace(m_context); 81 visitor->trace(m_context);
82 } 82 }
83 83
84 void MainThreadTaskRunner::postTask(const WebTraceLocation& location, PassOwnPtr <ExecutionContextTask> task) 84 void MainThreadTaskRunner::postTask(const WebTraceLocation& location, PassOwnPtr <ExecutionContextTask> task)
85 { 85 {
86 if (!task->taskNameForInstrumentation().isEmpty()) 86 if (!task->taskNameForInstrumentation().isEmpty())
87 InspectorInstrumentation::didPostExecutionContextTask(m_context, task.ge t()); 87 InspectorInstrumentation::didPostExecutionContextTask(m_context, task.ge t());
88 Platform::current()->mainThread()->postTask(location, new MainThreadTask(cre ateWeakPointerToSelf(), task, false)); 88 Platform::current()->mainThread()->taskRunner()->postTask(location, new Main ThreadTask(createWeakPointerToSelf(), task, false));
89 } 89 }
90 90
91 void MainThreadTaskRunner::postInspectorTask(const WebTraceLocation& location, P assOwnPtr<ExecutionContextTask> task) 91 void MainThreadTaskRunner::postInspectorTask(const WebTraceLocation& location, P assOwnPtr<ExecutionContextTask> task)
92 { 92 {
93 Platform::current()->mainThread()->postTask(location, new MainThreadTask(cre ateWeakPointerToSelf(), task, true)); 93 Platform::current()->mainThread()->taskRunner()->postTask(location, new Main ThreadTask(createWeakPointerToSelf(), task, true));
94 } 94 }
95 95
96 void MainThreadTaskRunner::perform(PassOwnPtr<ExecutionContextTask> task, bool i sInspectorTask) 96 void MainThreadTaskRunner::perform(PassOwnPtr<ExecutionContextTask> task, bool i sInspectorTask)
97 { 97 {
98 if (!isInspectorTask && (m_context->tasksNeedSuspension() || !m_pendingTasks .isEmpty())) { 98 if (!isInspectorTask && (m_context->tasksNeedSuspension() || !m_pendingTasks .isEmpty())) {
99 m_pendingTasks.append(task); 99 m_pendingTasks.append(task);
100 return; 100 return;
101 } 101 }
102 102
103 const bool instrumenting = !isInspectorTask && !task->taskNameForInstrumenta tion().isEmpty(); 103 const bool instrumenting = !isInspectorTask && !task->taskNameForInstrumenta tion().isEmpty();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 WeakPtrWillBeRawPtr<MainThreadTaskRunner> MainThreadTaskRunner::createWeakPointe rToSelf() 141 WeakPtrWillBeRawPtr<MainThreadTaskRunner> MainThreadTaskRunner::createWeakPointe rToSelf()
142 { 142 {
143 #if ENABLE(OILPAN) 143 #if ENABLE(OILPAN)
144 return this; 144 return this;
145 #else 145 #else
146 return m_weakFactory.createWeakPtr(); 146 return m_weakFactory.createWeakPtr();
147 #endif 147 #endif
148 } 148 }
149 149
150 } // namespace 150 } // namespace
OLDNEW
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | Source/core/dom/Microtask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698