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

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

Issue 263143004: Add blink-side plumbing for ServiceWorker -> Document postMessage (1/3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: addressed comments Created 6 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
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerContainer.h ('k') | Source/web/FrameLoaderClientImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/ServiceWorkerContainer.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
index 56fc12874424b70eea4fa86d10e5462c38ac5222..c4f5c07915dfafe8fcc55491dd95ccf1556583ba 100644
--- a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
@@ -34,9 +34,13 @@
#include "bindings/v8/CallbackPromiseAdapter.h"
#include "bindings/v8/ScriptPromiseResolverWithContext.h"
#include "bindings/v8/ScriptState.h"
+#include "bindings/v8/SerializedScriptValue.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 "modules/serviceworkers/RegistrationOptionList.h"
#include "modules/serviceworkers/ServiceWorker.h"
#include "modules/serviceworkers/ServiceWorkerContainerClient.h"
@@ -140,8 +144,19 @@ void ServiceWorkerContainer::setCurrentServiceWorker(blink::WebServiceWorker* se
m_current = ServiceWorker::create(executionContext(), adoptPtr(serviceWorker));
}
+void ServiceWorkerContainer::dispatchMessageEvent(const blink::WebString& message, const blink::WebMessagePortChannelArray& webChannels)
+{
+ if (!executionContext() || !window())
+ return;
+
+ OwnPtr<MessagePortArray> ports = MessagePort::toMessagePortArray(executionContext(), webChannels);
+ RefPtr<SerializedScriptValue> value = SerializedScriptValue::createFromWire(message);
+ window()->dispatchEvent(MessageEvent::create(ports.release(), value));
+}
+
ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContext)
: ContextLifecycleObserver(executionContext)
+ , DOMWindowLifecycleObserver(executionContext->isDocument() ? toDocument(executionContext)->domWindow() : 0)
, m_provider(0)
{
ScriptWrappable::init(this);
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerContainer.h ('k') | Source/web/FrameLoaderClientImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698