Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 18 matching lines...) Expand all Loading... | |
| 29 */ | 29 */ |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "modules/serviceworkers/ServiceWorkerContainer.h" | 31 #include "modules/serviceworkers/ServiceWorkerContainer.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 33 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 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 "bindings/modules/v8/UnionTypesModules.h" | |
| 39 #include "core/dom/DOMException.h" | 40 #include "core/dom/DOMException.h" |
| 40 #include "core/dom/Document.h" | 41 #include "core/dom/Document.h" |
| 41 #include "core/dom/ExceptionCode.h" | 42 #include "core/dom/ExceptionCode.h" |
| 42 #include "core/dom/ExecutionContext.h" | 43 #include "core/dom/ExecutionContext.h" |
| 43 #include "core/dom/MessagePort.h" | 44 #include "core/dom/MessagePort.h" |
| 44 #include "core/events/MessageEvent.h" | |
| 45 #include "core/frame/LocalDOMWindow.h" | 45 #include "core/frame/LocalDOMWindow.h" |
| 46 #include "modules/EventTargetModules.h" | 46 #include "modules/EventTargetModules.h" |
| 47 #include "modules/serviceworkers/ServiceWorker.h" | 47 #include "modules/serviceworkers/ServiceWorker.h" |
| 48 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" | 48 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" |
| 49 #include "modules/serviceworkers/ServiceWorkerError.h" | 49 #include "modules/serviceworkers/ServiceWorkerError.h" |
| 50 #include "modules/serviceworkers/ServiceWorkerMessageEvent.h" | |
| 50 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 51 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 51 #include "platform/RuntimeEnabledFeatures.h" | 52 #include "platform/RuntimeEnabledFeatures.h" |
| 52 #include "public/platform/WebServiceWorker.h" | 53 #include "public/platform/WebServiceWorker.h" |
| 53 #include "public/platform/WebServiceWorkerProvider.h" | 54 #include "public/platform/WebServiceWorkerProvider.h" |
| 54 #include "public/platform/WebServiceWorkerRegistration.h" | 55 #include "public/platform/WebServiceWorkerRegistration.h" |
| 55 #include "public/platform/WebString.h" | 56 #include "public/platform/WebString.h" |
| 56 #include "public/platform/WebURL.h" | 57 #include "public/platform/WebURL.h" |
| 57 | 58 |
| 58 namespace blink { | 59 namespace blink { |
| 59 | 60 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 { | 265 { |
| 265 if (!executionContext()) { | 266 if (!executionContext()) { |
| 266 deleteIfNoExistingOwner(serviceWorker); | 267 deleteIfNoExistingOwner(serviceWorker); |
| 267 return; | 268 return; |
| 268 } | 269 } |
| 269 m_controller = ServiceWorker::from(executionContext(), serviceWorker); | 270 m_controller = ServiceWorker::from(executionContext(), serviceWorker); |
| 270 if (shouldNotifyControllerChange) | 271 if (shouldNotifyControllerChange) |
| 271 dispatchEvent(Event::create(EventTypeNames::controllerchange)); | 272 dispatchEvent(Event::create(EventTypeNames::controllerchange)); |
| 272 } | 273 } |
| 273 | 274 |
| 274 void ServiceWorkerContainer::dispatchMessageEvent(const WebString& message, cons t WebMessagePortChannelArray& webChannels) | 275 void ServiceWorkerContainer::dispatchMessageEvent(WebServiceWorker* serviceWorke r, const WebString& message, const WebMessagePortChannelArray& webChannels) |
| 275 { | 276 { |
| 276 if (!executionContext() || !executionContext()->executingWindow()) | 277 if (!executionContext() || !executionContext()->executingWindow()) |
| 277 return; | 278 return; |
| 278 | 279 |
| 279 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (executionContext(), webChannels); | 280 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (executionContext(), webChannels); |
| 280 RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance ().createFromWire(message); | 281 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.
| |
| 281 executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(po rts.release(), value)); | 282 RefPtrWillBeRawPtr<ServiceWorker> source = ServiceWorker::from(executionCont ext(), serviceWorker); |
| 283 dispatchEvent(ServiceWorkerMessageEvent::create(ports.release(), value, Serv iceWorkerOrMessagePort::fromServiceWorker(source))); | |
| 282 } | 284 } |
| 283 | 285 |
| 284 const AtomicString& ServiceWorkerContainer::interfaceName() const | 286 const AtomicString& ServiceWorkerContainer::interfaceName() const |
| 285 { | 287 { |
| 286 return EventTargetNames::ServiceWorkerContainer; | 288 return EventTargetNames::ServiceWorkerContainer; |
| 287 } | 289 } |
| 288 | 290 |
| 289 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t) | 291 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t) |
| 290 : ContextLifecycleObserver(executionContext) | 292 : ContextLifecycleObserver(executionContext) |
| 291 , m_provider(0) | 293 , m_provider(0) |
| 292 { | 294 { |
| 293 | 295 |
| 294 if (!executionContext) | 296 if (!executionContext) |
| 295 return; | 297 return; |
| 296 | 298 |
| 297 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { | 299 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { |
| 298 m_provider = client->provider(); | 300 m_provider = client->provider(); |
| 299 if (m_provider) | 301 if (m_provider) |
| 300 m_provider->setClient(this); | 302 m_provider->setClient(this); |
| 301 } | 303 } |
| 302 } | 304 } |
| 303 | 305 |
| 304 } // namespace blink | 306 } // namespace blink |
| OLD | NEW |