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

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

Issue 924983002: Expose v8 context a MessagePort lives in to give content side code a valid context to (de)serialize… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: change to use the world of some event listener Created 5 years, 10 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/MessagePort.h ('k') | public/platform/WebMessagePortChannelClient.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/MessagePort.cpp
diff --git a/Source/core/dom/MessagePort.cpp b/Source/core/dom/MessagePort.cpp
index d9da4a2e26a76e97ed76ca6076dc57a389cf9513..392bc0dddf6005013937b30954a1e58de8ecf778 100644
--- a/Source/core/dom/MessagePort.cpp
+++ b/Source/core/dom/MessagePort.cpp
@@ -31,6 +31,7 @@
#include "bindings/core/v8/ExceptionStatePlaceholder.h"
#include "bindings/core/v8/SerializedScriptValue.h"
#include "bindings/core/v8/SerializedScriptValueFactory.h"
+#include "bindings/core/v8/V8AbstractEventListener.h"
#include "core/dom/CrossThreadTask.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContext.h"
@@ -266,4 +267,25 @@ void MessagePort::trace(Visitor* visitor)
EventTargetWithInlineData::trace(visitor);
}
+v8::Isolate* MessagePort::scriptIsolate()
+{
+ ASSERT(executionContext());
+ return toIsolate(executionContext());
+}
+
+v8::Handle<v8::Context> MessagePort::scriptContext()
+{
+ ASSERT(executionContext());
+ // Since a MessagePort doesn't live in any particular world, return the
+ // context for some arbitrary event listener that is registered with this
+ // port.
haraken 2015/02/25 07:44:34 I don't understand why this is right. Not all even
Marijn Kruisselbrink 2015/02/25 17:35:17 The context returned by this is used by WebMessage
+ const EventListenerVector& listeners = getEventListeners(EventTypeNames::message);
+ for (const RegisteredEventListener& listener: listeners) {
+ const V8AbstractEventListener* v8listener = V8AbstractEventListener::cast(listener.listener.get());
+ if (v8listener)
+ return toV8Context(executionContext(), v8listener->world());
+ }
+ return v8::Handle<v8::Context>();
+}
+
} // namespace blink
« no previous file with comments | « Source/core/dom/MessagePort.h ('k') | public/platform/WebMessagePortChannelClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698