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

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

Issue 2836473002: Reland of Messaging: Avoid calling non-thread-safe functions in MessagePort::messageAvailable() (Closed)
Patch Set: Created 3 years, 8 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/MessagePort.cpp
diff --git a/third_party/WebKit/Source/core/dom/MessagePort.cpp b/third_party/WebKit/Source/core/dom/MessagePort.cpp
index 74e1986e847d9991bacf4b93bade62df4f1d39ce..e4c0a2f3268134928213bbcd7c302421cd8832a8 100644
--- a/third_party/WebKit/Source/core/dom/MessagePort.cpp
+++ b/third_party/WebKit/Source/core/dom/MessagePort.cpp
@@ -33,11 +33,11 @@
#include "bindings/core/v8/SerializedScriptValueFactory.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContext.h"
-#include "core/dom/ExecutionContextTask.h"
#include "core/dom/TaskRunnerHelper.h"
#include "core/events/MessageEvent.h"
#include "core/frame/LocalDOMWindow.h"
#include "core/workers/WorkerGlobalScope.h"
+#include "platform/CrossThreadFunctional.h"
#include "platform/wtf/Atomics.h"
#include "platform/wtf/PtrUtil.h"
#include "platform/wtf/text/AtomicString.h"
@@ -51,9 +51,8 @@
MessagePort::MessagePort(ExecutionContext& execution_context)
: ContextLifecycleObserver(&execution_context),
- pending_dispatch_task_(0),
- started_(false),
- closed_(false) {}
+ task_runner_(TaskRunnerHelper::Get(TaskType::kPostedMessage,
+ &execution_context)) {}
MessagePort::~MessagePort() {
DCHECK(!started_ || !IsEntangled());
@@ -122,13 +121,9 @@
if (AtomicTestAndSetToOne(&pending_dispatch_task_))
return;
- DCHECK(GetExecutionContext());
- // TODO(tzik): Use ParentThreadTaskRunners instead of ExecutionContext here to
- // avoid touching foreign thread GCed object.
- GetExecutionContext()->PostTask(
- TaskType::kPostedMessage, BLINK_FROM_HERE,
- CreateCrossThreadTask(&MessagePort::DispatchMessages,
- WrapCrossThreadWeakPersistent(this)));
+ task_runner_->PostTask(BLINK_FROM_HERE,
+ CrossThreadBind(&MessagePort::DispatchMessages,
+ WrapCrossThreadWeakPersistent(this)));
}
void MessagePort::start() {
« no previous file with comments | « third_party/WebKit/Source/core/dom/MessagePort.h ('k') | third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698