OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/serviceworkers/ServiceWorkerClient.h" | 5 #include "modules/serviceworkers/ServiceWorkerClient.h" |
6 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" | 6 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" |
7 | 7 |
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
10 #include "bindings/core/v8/SerializedScriptValue.h" | 10 #include "bindings/core/v8/SerializedScriptValue.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 String ServiceWorkerClient::frameType() const | 54 String ServiceWorkerClient::frameType() const |
55 { | 55 { |
56 switch (m_frameType) { | 56 switch (m_frameType) { |
57 case WebURLRequest::FrameTypeAuxiliary: | 57 case WebURLRequest::FrameTypeAuxiliary: |
58 return "auxiliary"; | 58 return "auxiliary"; |
59 case WebURLRequest::FrameTypeNested: | 59 case WebURLRequest::FrameTypeNested: |
60 return "nested"; | 60 return "nested"; |
61 case WebURLRequest::FrameTypeNone: | 61 case WebURLRequest::FrameTypeNone: |
62 return "none"; | 62 return "none"; |
| 63 case WebURLRequest::FrameTypePreload: |
| 64 return "preload"; |
63 case WebURLRequest::FrameTypeTopLevel: | 65 case WebURLRequest::FrameTypeTopLevel: |
64 return "top-level"; | 66 return "top-level"; |
65 } | 67 } |
66 | 68 |
67 ASSERT_NOT_REACHED(); | 69 ASSERT_NOT_REACHED(); |
68 return String(); | 70 return String(); |
69 } | 71 } |
70 | 72 |
71 void ServiceWorkerClient::postMessage(ExecutionContext* context, PassRefPtr<Seri
alizedScriptValue> message, const MessagePortArray& ports, ExceptionState& excep
tionState) | 73 void ServiceWorkerClient::postMessage(ExecutionContext* context, PassRefPtr<Seri
alizedScriptValue> message, const MessagePortArray& ports, ExceptionState& excep
tionState) |
72 { | 74 { |
73 // Disentangle the port in preparation for sending it to the remote context. | 75 // Disentangle the port in preparation for sending it to the remote context. |
74 std::unique_ptr<MessagePortChannelArray> channels = MessagePort::disentangle
Ports(context, ports, exceptionState); | 76 std::unique_ptr<MessagePortChannelArray> channels = MessagePort::disentangle
Ports(context, ports, exceptionState); |
75 if (exceptionState.hadException()) | 77 if (exceptionState.hadException()) |
76 return; | 78 return; |
77 | 79 |
78 if (message->containsTransferableArrayBuffer()) | 80 if (message->containsTransferableArrayBuffer()) |
79 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni
ngMessageLevel, "ServiceWorkerClient cannot send an ArrayBuffer as a transferabl
e object yet. See http://crbug.com/511119")); | 81 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni
ngMessageLevel, "ServiceWorkerClient cannot send an ArrayBuffer as a transferabl
e object yet. See http://crbug.com/511119")); |
80 | 82 |
81 WebString messageString = message->toWireString(); | 83 WebString messageString = message->toWireString(); |
82 std::unique_ptr<WebMessagePortChannelArray> webChannels = MessagePort::toWeb
MessagePortChannelArray(std::move(channels)); | 84 std::unique_ptr<WebMessagePortChannelArray> webChannels = MessagePort::toWeb
MessagePortChannelArray(std::move(channels)); |
83 ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_uuid, m
essageString, std::move(webChannels)); | 85 ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_uuid, m
essageString, std::move(webChannels)); |
84 } | 86 } |
85 | 87 |
86 } // namespace blink | 88 } // namespace blink |
OLD | NEW |