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

Unified Diff: Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 1130113006: ServiceWorker: Introduce ServiceWorkerMessageEvent to replace MessageEvent (3/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: remove custom bindings Created 5 years, 7 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: Source/modules/serviceworkers/ServiceWorkerContainer.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
index 4c7d6684f6bd67128e83460171c0d329f8915563..4990d9f29996ba970e972e74218cf6e96cddedbd 100644
--- a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
@@ -36,17 +36,18 @@
#include "bindings/core/v8/ScriptState.h"
#include "bindings/core/v8/SerializedScriptValue.h"
#include "bindings/core/v8/SerializedScriptValueFactory.h"
+#include "bindings/modules/v8/UnionTypesModules.h"
#include "core/dom/DOMException.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContext.h"
#include "core/dom/MessagePort.h"
-#include "core/events/MessageEvent.h"
#include "core/frame/LocalDOMWindow.h"
#include "modules/EventTargetModules.h"
#include "modules/serviceworkers/ServiceWorker.h"
#include "modules/serviceworkers/ServiceWorkerContainerClient.h"
#include "modules/serviceworkers/ServiceWorkerError.h"
+#include "modules/serviceworkers/ServiceWorkerMessageEvent.h"
#include "modules/serviceworkers/ServiceWorkerRegistration.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "public/platform/WebServiceWorker.h"
@@ -271,14 +272,15 @@ void ServiceWorkerContainer::setController(WebServiceWorker* serviceWorker, bool
dispatchEvent(Event::create(EventTypeNames::controllerchange));
}
-void ServiceWorkerContainer::dispatchMessageEvent(const WebString& message, const WebMessagePortChannelArray& webChannels)
+void ServiceWorkerContainer::dispatchMessageEvent(WebServiceWorker* serviceWorker, const WebString& message, const WebMessagePortChannelArray& webChannels)
{
if (!executionContext() || !executionContext()->executingWindow())
return;
OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray(executionContext(), webChannels);
RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance().createFromWire(message);
bashi 2015/05/22 00:23:36 Help me understand: Do we really need to use Seria
xiang 2015/05/25 02:04:25 However when this method called from content layer
bashi 2015/05/26 00:19:00 Makes sense.
- executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(ports.release(), value));
+ RefPtrWillBeRawPtr<ServiceWorker> source = ServiceWorker::from(executionContext(), serviceWorker);
+ dispatchEvent(ServiceWorkerMessageEvent::create(ports.release(), value, ServiceWorkerOrMessagePort::fromServiceWorker(source)));
}
const AtomicString& ServiceWorkerContainer::interfaceName() const

Powered by Google App Engine
This is Rietveld 408576698