Chromium Code Reviews| 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 |