| 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 23 matching lines...) Expand all Loading... |
| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 { | 264 { |
| 265 if (!executionContext()) { | 265 if (!executionContext()) { |
| 266 deleteIfNoExistingOwner(serviceWorker); | 266 deleteIfNoExistingOwner(serviceWorker); |
| 267 return; | 267 return; |
| 268 } | 268 } |
| 269 m_controller = ServiceWorker::from(executionContext(), serviceWorker); | 269 m_controller = ServiceWorker::from(executionContext(), serviceWorker); |
| 270 if (shouldNotifyControllerChange) | 270 if (shouldNotifyControllerChange) |
| 271 dispatchEvent(Event::create(EventTypeNames::controllerchange)); | 271 dispatchEvent(Event::create(EventTypeNames::controllerchange)); |
| 272 } | 272 } |
| 273 | 273 |
| 274 void ServiceWorkerContainer::dispatchMessageEvent(const WebString& message, cons
t WebMessagePortChannelArray& webChannels) | 274 void ServiceWorkerContainer::dispatchMessageEvent(WebServiceWorker* serviceWorke
r, const WebString& message, const WebMessagePortChannelArray& webChannels) |
| 275 { | 275 { |
| 276 if (!executionContext() || !executionContext()->executingWindow()) | 276 if (!executionContext() || !executionContext()->executingWindow()) |
| 277 return; | 277 return; |
| 278 | 278 |
| 279 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray
(executionContext(), webChannels); | 279 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray
(executionContext(), webChannels); |
| 280 RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance
().createFromWire(message); | 280 RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance
().createFromWire(message); |
| 281 executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(po
rts.release(), value)); | 281 RefPtrWillBeRawPtr<ServiceWorker> source = ServiceWorker::from(executionCont
ext(), serviceWorker); |
| 282 dispatchEvent(ServiceWorkerMessageEvent::create(ports.release(), value, Serv
iceWorkerOrMessagePort::fromServiceWorker(source))); |
| 282 } | 283 } |
| 283 | 284 |
| 284 const AtomicString& ServiceWorkerContainer::interfaceName() const | 285 const AtomicString& ServiceWorkerContainer::interfaceName() const |
| 285 { | 286 { |
| 286 return EventTargetNames::ServiceWorkerContainer; | 287 return EventTargetNames::ServiceWorkerContainer; |
| 287 } | 288 } |
| 288 | 289 |
| 289 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex
t) | 290 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex
t) |
| 290 : ContextLifecycleObserver(executionContext) | 291 : ContextLifecycleObserver(executionContext) |
| 291 , m_provider(0) | 292 , m_provider(0) |
| 292 { | 293 { |
| 293 | 294 |
| 294 if (!executionContext) | 295 if (!executionContext) |
| 295 return; | 296 return; |
| 296 | 297 |
| 297 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { | 298 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { |
| 298 m_provider = client->provider(); | 299 m_provider = client->provider(); |
| 299 if (m_provider) | 300 if (m_provider) |
| 300 m_provider->setClient(this); | 301 m_provider->setClient(this); |
| 301 } | 302 } |
| 302 } | 303 } |
| 303 | 304 |
| 304 } // namespace blink | 305 } // namespace blink |
| OLD | NEW |