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

Unified Diff: Source/core/dom/MainThreadTaskRunner.cpp

Issue 1296243004: Oilpan: Move MainThreadTaskRunner into Oilpan heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use CrossThreadWeakPersistent. Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/MainThreadTaskRunner.h ('k') | Source/core/dom/MainThreadTaskRunnerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/MainThreadTaskRunner.cpp
diff --git a/Source/core/dom/MainThreadTaskRunner.cpp b/Source/core/dom/MainThreadTaskRunner.cpp
index 095e28d2dcce6cfb6e833a3232dc5612a0d4dce9..339332f5050456d486acedd6de1ea58f7448043e 100644
--- a/Source/core/dom/MainThreadTaskRunner.cpp
+++ b/Source/core/dom/MainThreadTaskRunner.cpp
@@ -38,7 +38,7 @@ namespace blink {
class MainThreadTask : public WebThread::Task {
WTF_MAKE_NONCOPYABLE(MainThreadTask); WTF_MAKE_FAST_ALLOCATED(MainThreadTask);
public:
- MainThreadTask(WeakPtr<MainThreadTaskRunner> runner, PassOwnPtr<ExecutionContextTask> task, bool isInspectorTask)
+ MainThreadTask(WeakPtrWillBeRawPtr<MainThreadTaskRunner> runner, PassOwnPtr<ExecutionContextTask> task, bool isInspectorTask)
: m_runner(runner)
, m_task(task)
, m_isInspectorTask(isInspectorTask)
@@ -48,7 +48,11 @@ public:
void run() override;
private:
+#if ENABLE(OILPAN)
+ CrossThreadWeakPersistent<MainThreadTaskRunner> m_runner;
+#else
WeakPtr<MainThreadTaskRunner> m_runner;
+#endif
OwnPtr<ExecutionContextTask> m_task;
bool m_isInspectorTask;
};
@@ -64,7 +68,9 @@ void MainThreadTask::run()
MainThreadTaskRunner::MainThreadTaskRunner(ExecutionContext* context)
: m_context(context)
+#if !ENABLE(OILPAN)
, m_weakFactory(this)
+#endif
, m_pendingTasksTimer(this, &MainThreadTaskRunner::pendingTasksTimerFired)
, m_suspended(false)
{
@@ -74,16 +80,21 @@ MainThreadTaskRunner::~MainThreadTaskRunner()
{
}
+DEFINE_TRACE(MainThreadTaskRunner)
+{
+ visitor->trace(m_context);
+}
+
void MainThreadTaskRunner::postTask(const WebTraceLocation& location, PassOwnPtr<ExecutionContextTask> task)
{
if (!task->taskNameForInstrumentation().isEmpty())
InspectorInstrumentation::didPostExecutionContextTask(m_context, task.get());
- Platform::current()->mainThread()->postTask(location, new MainThreadTask(m_weakFactory.createWeakPtr(), task, false));
+ Platform::current()->mainThread()->postTask(location, new MainThreadTask(createWeakPointerToSelf(), task, false));
}
void MainThreadTaskRunner::postInspectorTask(const WebTraceLocation& location, PassOwnPtr<ExecutionContextTask> task)
{
- Platform::current()->mainThread()->postTask(location, new MainThreadTask(m_weakFactory.createWeakPtr(), task, true));
+ Platform::current()->mainThread()->postTask(location, new MainThreadTask(createWeakPointerToSelf(), task, true));
}
void MainThreadTaskRunner::perform(PassOwnPtr<ExecutionContextTask> task, bool isInspectorTask)
@@ -131,4 +142,13 @@ void MainThreadTaskRunner::pendingTasksTimerFired(Timer<MainThreadTaskRunner>*)
}
}
+WeakPtrWillBeRawPtr<MainThreadTaskRunner> MainThreadTaskRunner::createWeakPointerToSelf()
+{
+#if ENABLE(OILPAN)
+ return this;
+#else
+ return m_weakFactory.createWeakPtr();
+#endif
+}
+
} // namespace
« no previous file with comments | « Source/core/dom/MainThreadTaskRunner.h ('k') | Source/core/dom/MainThreadTaskRunnerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698