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 4912d3c6267a4be3b30792e8914859ce784d9dd3..8e6680f0ea51c8715500e1668a165629e1eabea5 100644 |
--- a/third_party/WebKit/Source/core/dom/MainThreadTaskRunner.cpp |
+++ b/third_party/WebKit/Source/core/dom/MainThreadTaskRunner.cpp |
@@ -40,6 +40,8 @@ MainThreadTaskRunner::MainThreadTaskRunner(ExecutionContext* context) |
, m_pendingTasksTimer(this, &MainThreadTaskRunner::pendingTasksTimerFired) |
, m_suspended(false) |
, m_weakFactory(this) |
+ // Bind a WeakPtr now to avoid data races creating a WeakPtr inside postTask. |
+ , m_weakPtr(m_weakFactory.createWeakPtr()) |
{ |
} |
@@ -51,7 +53,7 @@ void MainThreadTaskRunner::postTaskInternal(const WebTraceLocation& location, st |
{ |
Platform::current()->mainThread()->getWebTaskRunner()->postTask(location, crossThreadBind( |
&MainThreadTaskRunner::perform, |
- m_weakFactory.createWeakPtr(), |
+ m_weakPtr, |
esprehn
2016/09/13 19:44:21
This means we're sharing a weakptr now instead of
dcheng
2016/09/13 19:51:40
It's copied, not shared, when it's bound into the
|
passed(std::move(task)), |
isInspectorTask, |
instrumenting)); |