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

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

Issue 1938313003: Move MainThreadTaskRunner off Oilpan heap to simplify posting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile fix Created 4 years, 7 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
Index: third_party/WebKit/Source/core/dom/MainThreadTaskRunner.cpp
diff --git a/third_party/WebKit/Source/core/dom/MainThreadTaskRunner.cpp b/third_party/WebKit/Source/core/dom/MainThreadTaskRunner.cpp
index 187d1784213545c1ebe2d9aadefbb6c3393f0595..925e8bc809b354ce2ce456b8a1b9f2c4d252e33c 100644
--- a/third_party/WebKit/Source/core/dom/MainThreadTaskRunner.cpp
+++ b/third_party/WebKit/Source/core/dom/MainThreadTaskRunner.cpp
@@ -39,6 +39,7 @@ MainThreadTaskRunner::MainThreadTaskRunner(ExecutionContext* context)
: m_context(context)
, m_pendingTasksTimer(this, &MainThreadTaskRunner::pendingTasksTimerFired)
, m_suspended(false)
+ , m_weakFactory(this)
{
}
@@ -46,16 +47,11 @@ MainThreadTaskRunner::~MainThreadTaskRunner()
{
}
-DEFINE_TRACE(MainThreadTaskRunner)
-{
- visitor->trace(m_context);
-}
-
void MainThreadTaskRunner::postTaskInternal(const WebTraceLocation& location, std::unique_ptr<ExecutionContextTask> task, bool isInspectorTask)
{
Platform::current()->mainThread()->getWebTaskRunner()->postTask(location, threadSafeBind(
&MainThreadTaskRunner::perform,
- CrossThreadWeakPersistentThisPointer<MainThreadTaskRunner>(this),
+ m_weakFactory.createWeakPtr(),
passed(std::move(task)),
isInspectorTask));
}
@@ -74,6 +70,11 @@ void MainThreadTaskRunner::postInspectorTask(const WebTraceLocation& location, s
void MainThreadTaskRunner::perform(std::unique_ptr<ExecutionContextTask> task, bool isInspectorTask)
{
+ // If the owner m_context is about to be swept then it
+ // is no longer safe to access.
+ if (ThreadHeap::willObjectBeLazilySwept(m_context.get()))
haraken 2016/05/26 22:04:10 Generally I don't like willObjectBeLazilySwept, bu
+ return;
+
if (!isInspectorTask && (m_context->tasksNeedSuspension() || !m_pendingTasks.isEmpty())) {
m_pendingTasks.append(std::move(task));
return;
@@ -101,6 +102,11 @@ void MainThreadTaskRunner::resume()
void MainThreadTaskRunner::pendingTasksTimerFired(Timer<MainThreadTaskRunner>*)
{
+ // If the owner m_context is about to be swept then it
+ // is no longer safe to access.
+ if (ThreadHeap::willObjectBeLazilySwept(m_context.get()))
+ return;
+
while (!m_pendingTasks.isEmpty()) {
std::unique_ptr<ExecutionContextTask> task = std::move(m_pendingTasks[0]);
m_pendingTasks.remove(0);

Powered by Google App Engine
This is Rietveld 408576698