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 <memory> | 8 #include <memory> |
9 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 9 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
10 #include "bindings/core/v8/ExceptionState.h" | 10 #include "bindings/core/v8/ExceptionState.h" |
11 #include "bindings/core/v8/ScriptState.h" | 11 #include "bindings/core/v8/ScriptState.h" |
12 #include "bindings/core/v8/SerializedScriptValue.h" | 12 #include "bindings/core/v8/SerializedScriptValue.h" |
| 13 #include "core/dom/ExecutionContext.h" |
13 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" | 14 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
14 #include "platform/wtf/RefPtr.h" | 15 #include "platform/wtf/RefPtr.h" |
15 #include "public/platform/WebString.h" | 16 #include "public/platform/WebString.h" |
16 | 17 |
17 namespace blink { | 18 namespace blink { |
18 | 19 |
19 ServiceWorkerClient* ServiceWorkerClient::Take( | 20 ServiceWorkerClient* ServiceWorkerClient::Take( |
20 ScriptPromiseResolver*, | 21 ScriptPromiseResolver*, |
21 std::unique_ptr<WebServiceWorkerClientInfo> web_client) { | 22 std::unique_ptr<WebServiceWorkerClientInfo> web_client) { |
22 if (!web_client) | 23 if (!web_client) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 62 } |
62 | 63 |
63 ASSERT_NOT_REACHED(); | 64 ASSERT_NOT_REACHED(); |
64 return String(); | 65 return String(); |
65 } | 66 } |
66 | 67 |
67 void ServiceWorkerClient::postMessage(ScriptState* script_state, | 68 void ServiceWorkerClient::postMessage(ScriptState* script_state, |
68 PassRefPtr<SerializedScriptValue> message, | 69 PassRefPtr<SerializedScriptValue> message, |
69 const MessagePortArray& ports, | 70 const MessagePortArray& ports, |
70 ExceptionState& exception_state) { | 71 ExceptionState& exception_state) { |
71 ExecutionContext* context = script_state->GetExecutionContext(); | 72 ExecutionContext* context = ExecutionContext::From(script_state); |
72 // Disentangle the port in preparation for sending it to the remote context. | 73 // Disentangle the port in preparation for sending it to the remote context. |
73 MessagePortChannelArray channels = | 74 MessagePortChannelArray channels = |
74 MessagePort::DisentanglePorts(context, ports, exception_state); | 75 MessagePort::DisentanglePorts(context, ports, exception_state); |
75 if (exception_state.HadException()) | 76 if (exception_state.HadException()) |
76 return; | 77 return; |
77 | 78 |
78 WebString message_string = message->ToWireString(); | 79 WebString message_string = message->ToWireString(); |
79 WebMessagePortChannelArray web_channels = | 80 WebMessagePortChannelArray web_channels = |
80 MessagePort::ToWebMessagePortChannelArray(std::move(channels)); | 81 MessagePort::ToWebMessagePortChannelArray(std::move(channels)); |
81 ServiceWorkerGlobalScopeClient::From(context)->PostMessageToClient( | 82 ServiceWorkerGlobalScopeClient::From(context)->PostMessageToClient( |
82 uuid_, message_string, std::move(web_channels)); | 83 uuid_, message_string, std::move(web_channels)); |
83 } | 84 } |
84 | 85 |
85 } // namespace blink | 86 } // namespace blink |
OLD | NEW |