| 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 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "ServiceWorker.h" | 32 #include "ServiceWorker.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/ExceptionState.h" | 34 #include "bindings/core/v8/ExceptionState.h" |
| 35 #include "core/dom/ExceptionCode.h" | 35 #include "core/dom/ExceptionCode.h" |
| 36 #include "core/dom/MessagePort.h" | 36 #include "core/dom/MessagePort.h" |
| 37 #include "core/events/Event.h" | 37 #include "core/events/Event.h" |
| 38 #include "core/inspector/ConsoleMessage.h" |
| 38 #include "modules/EventTargetModules.h" | 39 #include "modules/EventTargetModules.h" |
| 39 #include "public/platform/WebMessagePortChannel.h" | 40 #include "public/platform/WebMessagePortChannel.h" |
| 40 #include "public/platform/WebString.h" | 41 #include "public/platform/WebString.h" |
| 41 #include "public/platform/modules/serviceworker/WebServiceWorkerState.h" | 42 #include "public/platform/modules/serviceworker/WebServiceWorkerState.h" |
| 42 | 43 |
| 43 namespace blink { | 44 namespace blink { |
| 44 | 45 |
| 45 const AtomicString& ServiceWorker::interfaceName() const | 46 const AtomicString& ServiceWorker::interfaceName() const |
| 46 { | 47 { |
| 47 return EventTargetNames::ServiceWorker; | 48 return EventTargetNames::ServiceWorker; |
| 48 } | 49 } |
| 49 | 50 |
| 50 void ServiceWorker::postMessage(ExecutionContext* context, PassRefPtr<Serialized
ScriptValue> message, const MessagePortArray* ports, ExceptionState& exceptionSt
ate) | 51 void ServiceWorker::postMessage(ExecutionContext* context, PassRefPtr<Serialized
ScriptValue> message, const MessagePortArray* ports, ExceptionState& exceptionSt
ate) |
| 51 { | 52 { |
| 52 // Disentangle the port in preparation for sending it to the remote context. | 53 // Disentangle the port in preparation for sending it to the remote context. |
| 53 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(con
text, ports, exceptionState); | 54 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(con
text, ports, exceptionState); |
| 54 if (exceptionState.hadException()) | 55 if (exceptionState.hadException()) |
| 55 return; | 56 return; |
| 56 if (m_outerWorker->state() == WebServiceWorkerStateRedundant) { | 57 if (m_outerWorker->state() == WebServiceWorkerStateRedundant) { |
| 57 exceptionState.throwDOMException(InvalidStateError, "ServiceWorker is in
redundant state."); | 58 exceptionState.throwDOMException(InvalidStateError, "ServiceWorker is in
redundant state."); |
| 58 return; | 59 return; |
| 59 } | 60 } |
| 60 | 61 |
| 62 if (message->containsTransferableArrayBuffer()) |
| 63 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni
ngMessageLevel, "ServiceWorker cannot send an ArrayBuffer as a transferable obje
ct yet. See http://crbug.com/511119")); |
| 64 |
| 61 WebString messageString = message->toWireString(); | 65 WebString messageString = message->toWireString(); |
| 62 OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePo
rtChannelArray(channels.release()); | 66 OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePo
rtChannelArray(channels.release()); |
| 63 m_outerWorker->postMessage(messageString, webChannels.leakPtr()); | 67 m_outerWorker->postMessage(messageString, webChannels.leakPtr()); |
| 64 } | 68 } |
| 65 | 69 |
| 66 void ServiceWorker::internalsTerminate() | 70 void ServiceWorker::internalsTerminate() |
| 67 { | 71 { |
| 68 m_outerWorker->terminate(); | 72 m_outerWorker->terminate(); |
| 69 } | 73 } |
| 70 | 74 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 { | 147 { |
| 144 ASSERT(m_outerWorker); | 148 ASSERT(m_outerWorker); |
| 145 m_outerWorker->setProxy(this); | 149 m_outerWorker->setProxy(this); |
| 146 } | 150 } |
| 147 | 151 |
| 148 ServiceWorker::~ServiceWorker() | 152 ServiceWorker::~ServiceWorker() |
| 149 { | 153 { |
| 150 } | 154 } |
| 151 | 155 |
| 152 } // namespace blink | 156 } // namespace blink |
| OLD | NEW |