| 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 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 "core/dom/DOMException.h" | 39 #include "core/dom/DOMException.h" |
| 39 #include "core/dom/ExceptionCode.h" | 40 #include "core/dom/ExceptionCode.h" |
| 40 #include "core/dom/ExecutionContext.h" | 41 #include "core/dom/ExecutionContext.h" |
| 41 #include "core/dom/MessagePort.h" | 42 #include "core/dom/MessagePort.h" |
| 42 #include "core/events/MessageEvent.h" | 43 #include "core/events/MessageEvent.h" |
| 43 #include "core/frame/LocalDOMWindow.h" | 44 #include "core/frame/LocalDOMWindow.h" |
| 44 #include "modules/serviceworkers/ServiceWorker.h" | 45 #include "modules/serviceworkers/ServiceWorker.h" |
| 45 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" | 46 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" |
| 46 #include "modules/serviceworkers/ServiceWorkerError.h" | 47 #include "modules/serviceworkers/ServiceWorkerError.h" |
| 47 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 48 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 m_readyRegistration = readyRegistration; | 260 m_readyRegistration = readyRegistration; |
| 260 m_ready->resolve(readyRegistration); | 261 m_ready->resolve(readyRegistration); |
| 261 } | 262 } |
| 262 | 263 |
| 263 void ServiceWorkerContainer::dispatchMessageEvent(const WebString& message, cons
t WebMessagePortChannelArray& webChannels) | 264 void ServiceWorkerContainer::dispatchMessageEvent(const WebString& message, cons
t WebMessagePortChannelArray& webChannels) |
| 264 { | 265 { |
| 265 if (!executionContext() || !executionContext()->executingWindow()) | 266 if (!executionContext() || !executionContext()->executingWindow()) |
| 266 return; | 267 return; |
| 267 | 268 |
| 268 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray
(executionContext(), webChannels); | 269 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray
(executionContext(), webChannels); |
| 269 RefPtr<SerializedScriptValue> value = SerializedScriptValue::createFromWire(
message); | 270 RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance
().createFromWire(message); |
| 270 executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(po
rts.release(), value)); | 271 executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(po
rts.release(), value)); |
| 271 } | 272 } |
| 272 | 273 |
| 273 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex
t) | 274 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex
t) |
| 274 : ContextLifecycleObserver(executionContext) | 275 : ContextLifecycleObserver(executionContext) |
| 275 , m_provider(0) | 276 , m_provider(0) |
| 276 { | 277 { |
| 277 | 278 |
| 278 if (!executionContext) | 279 if (!executionContext) |
| 279 return; | 280 return; |
| 280 | 281 |
| 281 m_ready = createReadyProperty(); | 282 m_ready = createReadyProperty(); |
| 282 | 283 |
| 283 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { | 284 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { |
| 284 m_provider = client->provider(); | 285 m_provider = client->provider(); |
| 285 if (m_provider) | 286 if (m_provider) |
| 286 m_provider->setClient(this); | 287 m_provider->setClient(this); |
| 287 } | 288 } |
| 288 } | 289 } |
| 289 | 290 |
| 290 } // namespace blink | 291 } // namespace blink |
| OLD | NEW |