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

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: make union type only on stack Created 5 years, 6 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 { 291 {
292 if (!executionContext()) { 292 if (!executionContext()) {
293 deleteIfNoExistingOwner(serviceWorker); 293 deleteIfNoExistingOwner(serviceWorker);
294 return; 294 return;
295 } 295 }
296 m_controller = ServiceWorker::from(executionContext(), serviceWorker); 296 m_controller = ServiceWorker::from(executionContext(), serviceWorker);
297 if (shouldNotifyControllerChange) 297 if (shouldNotifyControllerChange)
298 dispatchEvent(Event::create(EventTypeNames::controllerchange)); 298 dispatchEvent(Event::create(EventTypeNames::controllerchange));
299 } 299 }
300 300
301 void ServiceWorkerContainer::dispatchMessageEvent(const WebString& message, cons t WebMessagePortChannelArray& webChannels) 301 void ServiceWorkerContainer::dispatchMessageEvent(WebServiceWorker* serviceWorke r, const WebString& message, const WebMessagePortChannelArray& webChannels)
302 { 302 {
303 if (!executionContext() || !executionContext()->executingWindow()) 303 if (!executionContext() || !executionContext()->executingWindow())
304 return; 304 return;
305 305
306 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (executionContext(), webChannels); 306 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (executionContext(), webChannels);
307 RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance ().createFromWire(message); 307 RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance ().createFromWire(message);
308 executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(po rts.release(), value)); 308 RefPtrWillBeRawPtr<ServiceWorker> source = ServiceWorker::from(executionCont ext(), serviceWorker);
309 dispatchEvent(ServiceWorkerMessageEvent::create(ports.release(), value, sour ce));
309 } 310 }
310 311
311 const AtomicString& ServiceWorkerContainer::interfaceName() const 312 const AtomicString& ServiceWorkerContainer::interfaceName() const
312 { 313 {
313 return EventTargetNames::ServiceWorkerContainer; 314 return EventTargetNames::ServiceWorkerContainer;
314 } 315 }
315 316
316 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t) 317 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t)
317 : ContextLifecycleObserver(executionContext) 318 : ContextLifecycleObserver(executionContext)
318 , m_provider(0) 319 , m_provider(0)
319 { 320 {
320 321
321 if (!executionContext) 322 if (!executionContext)
322 return; 323 return;
323 324
324 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 325 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
325 m_provider = client->provider(); 326 m_provider = client->provider();
326 if (m_provider) 327 if (m_provider)
327 m_provider->setClient(this); 328 m_provider->setClient(this);
328 } 329 }
329 } 330 }
330 331
331 } // namespace blink 332 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698