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

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

Issue 2329243002: Implement WTF::WeakPtr in terms of base::WeakPtr (Closed)
Patch Set: Thread-safety fix with comment Created 4 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 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 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));

Powered by Google App Engine
This is Rietveld 408576698