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

Side by Side 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: add initEvent tests 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 23 matching lines...) Expand all
34 #include "bindings/core/v8/ScriptPromise.h" 34 #include "bindings/core/v8/ScriptPromise.h"
35 #include "bindings/core/v8/ScriptPromiseResolver.h" 35 #include "bindings/core/v8/ScriptPromiseResolver.h"
36 #include "bindings/core/v8/ScriptState.h" 36 #include "bindings/core/v8/ScriptState.h"
37 #include "bindings/core/v8/SerializedScriptValue.h" 37 #include "bindings/core/v8/SerializedScriptValue.h"
38 #include "bindings/core/v8/SerializedScriptValueFactory.h" 38 #include "bindings/core/v8/SerializedScriptValueFactory.h"
39 #include "core/dom/DOMException.h" 39 #include "core/dom/DOMException.h"
40 #include "core/dom/Document.h" 40 #include "core/dom/Document.h"
41 #include "core/dom/ExceptionCode.h" 41 #include "core/dom/ExceptionCode.h"
42 #include "core/dom/ExecutionContext.h" 42 #include "core/dom/ExecutionContext.h"
43 #include "core/dom/MessagePort.h" 43 #include "core/dom/MessagePort.h"
44 #include "core/events/MessageEvent.h"
45 #include "core/frame/LocalDOMWindow.h" 44 #include "core/frame/LocalDOMWindow.h"
46 #include "modules/EventTargetModules.h" 45 #include "modules/EventTargetModules.h"
47 #include "modules/serviceworkers/ServiceWorker.h" 46 #include "modules/serviceworkers/ServiceWorker.h"
48 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" 47 #include "modules/serviceworkers/ServiceWorkerContainerClient.h"
49 #include "modules/serviceworkers/ServiceWorkerError.h" 48 #include "modules/serviceworkers/ServiceWorkerError.h"
49 #include "modules/serviceworkers/ServiceWorkerMessageEvent.h"
50 #include "modules/serviceworkers/ServiceWorkerRegistration.h" 50 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
51 #include "platform/RuntimeEnabledFeatures.h" 51 #include "platform/RuntimeEnabledFeatures.h"
52 #include "public/platform/WebServiceWorker.h" 52 #include "public/platform/WebServiceWorker.h"
53 #include "public/platform/WebServiceWorkerProvider.h" 53 #include "public/platform/WebServiceWorkerProvider.h"
54 #include "public/platform/WebServiceWorkerRegistration.h" 54 #include "public/platform/WebServiceWorkerRegistration.h"
55 #include "public/platform/WebString.h" 55 #include "public/platform/WebString.h"
56 #include "public/platform/WebURL.h" 56 #include "public/platform/WebURL.h"
57 57
58 namespace blink { 58 namespace blink {
59 59
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 { 256 {
257 if (!executionContext()) { 257 if (!executionContext()) {
258 deleteIfNoExistingOwner(serviceWorker); 258 deleteIfNoExistingOwner(serviceWorker);
259 return; 259 return;
260 } 260 }
261 m_controller = ServiceWorker::from(executionContext(), serviceWorker); 261 m_controller = ServiceWorker::from(executionContext(), serviceWorker);
262 if (shouldNotifyControllerChange) 262 if (shouldNotifyControllerChange)
263 dispatchEvent(Event::create(EventTypeNames::controllerchange)); 263 dispatchEvent(Event::create(EventTypeNames::controllerchange));
264 } 264 }
265 265
266 void ServiceWorkerContainer::dispatchMessageEvent(const WebString& message, cons t WebMessagePortChannelArray& webChannels) 266 void ServiceWorkerContainer::dispatchMessageEvent(WebServiceWorker* serviceWorke r, const WebString& message, const WebMessagePortChannelArray& webChannels)
267 { 267 {
268 if (!executionContext() || !executionContext()->executingWindow()) 268 if (!executionContext() || !executionContext()->executingWindow())
269 return; 269 return;
270 270
271 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (executionContext(), webChannels); 271 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (executionContext(), webChannels);
272 RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance ().createFromWire(message); 272 RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance ().createFromWire(message);
273 executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(po rts.release(), value)); 273 RefPtrWillBeRawPtr<ServiceWorker> source = ServiceWorker::from(executionCont ext(), serviceWorker);
274 dispatchEvent(ServiceWorkerMessageEvent::create(ports.release(), value, sour ce));
274 } 275 }
275 276
276 const AtomicString& ServiceWorkerContainer::interfaceName() const 277 const AtomicString& ServiceWorkerContainer::interfaceName() const
277 { 278 {
278 return EventTargetNames::ServiceWorkerContainer; 279 return EventTargetNames::ServiceWorkerContainer;
279 } 280 }
280 281
281 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t) 282 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t)
282 : ContextLifecycleObserver(executionContext) 283 : ContextLifecycleObserver(executionContext)
283 , m_provider(0) 284 , m_provider(0)
284 { 285 {
285 286
286 if (!executionContext) 287 if (!executionContext)
287 return; 288 return;
288 289
289 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 290 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
290 m_provider = client->provider(); 291 m_provider = client->provider();
291 if (m_provider) 292 if (m_provider)
292 m_provider->setClient(this); 293 m_provider->setClient(this);
293 } 294 }
294 } 295 }
295 296
296 } // namespace blink 297 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698