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 | 7 |
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
8 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
9 #include "bindings/core/v8/SerializedScriptValue.h" | 10 #include "bindings/core/v8/SerializedScriptValue.h" |
10 #include "core/inspector/ConsoleMessage.h" | 11 #include "core/inspector/ConsoleMessage.h" |
11 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" | 12 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
12 #include "public/platform/WebString.h" | 13 #include "public/platform/WebString.h" |
13 #include "wtf/RefPtr.h" | 14 #include "wtf/RefPtr.h" |
14 | 15 |
15 namespace blink { | 16 namespace blink { |
16 | 17 |
| 18 ServiceWorkerClient* ServiceWorkerClient::take(ScriptPromiseResolver*, PassOwnPt
r<WebServiceWorkerClientInfo> webClient) |
| 19 { |
| 20 if (!webClient) |
| 21 return nullptr; |
| 22 |
| 23 switch (webClient->clientType) { |
| 24 case WebServiceWorkerClientTypeWindow: |
| 25 return ServiceWorkerWindowClient::create(*webClient); |
| 26 case WebServiceWorkerClientTypeWorker: |
| 27 case WebServiceWorkerClientTypeSharedWorker: |
| 28 return ServiceWorkerClient::create(*webClient); |
| 29 case WebServiceWorkerClientTypeLast: |
| 30 ASSERT_NOT_REACHED(); |
| 31 return nullptr; |
| 32 } |
| 33 } |
| 34 |
17 ServiceWorkerClient* ServiceWorkerClient::create(const WebServiceWorkerClientInf
o& info) | 35 ServiceWorkerClient* ServiceWorkerClient::create(const WebServiceWorkerClientInf
o& info) |
18 { | 36 { |
19 return new ServiceWorkerClient(info); | 37 return new ServiceWorkerClient(info); |
20 } | 38 } |
21 | 39 |
22 ServiceWorkerClient::ServiceWorkerClient(const WebServiceWorkerClientInfo& info) | 40 ServiceWorkerClient::ServiceWorkerClient(const WebServiceWorkerClientInfo& info) |
23 : m_uuid(info.uuid) | 41 : m_uuid(info.uuid) |
24 , m_url(info.url.string()) | 42 , m_url(info.url.string()) |
25 , m_frameType(info.frameType) | 43 , m_frameType(info.frameType) |
26 { | 44 { |
(...skipping 29 matching lines...) Expand all Loading... |
56 | 74 |
57 if (message->containsTransferableArrayBuffer()) | 75 if (message->containsTransferableArrayBuffer()) |
58 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni
ngMessageLevel, "ServiceWorkerClient cannot send an ArrayBuffer as a transferabl
e object yet. See http://crbug.com/511119")); | 76 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni
ngMessageLevel, "ServiceWorkerClient cannot send an ArrayBuffer as a transferabl
e object yet. See http://crbug.com/511119")); |
59 | 77 |
60 WebString messageString = message->toWireString(); | 78 WebString messageString = message->toWireString(); |
61 OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePo
rtChannelArray(channels.release()); | 79 OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePo
rtChannelArray(channels.release()); |
62 ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_uuid, m
essageString, webChannels.release()); | 80 ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_uuid, m
essageString, webChannels.release()); |
63 } | 81 } |
64 | 82 |
65 } // namespace blink | 83 } // namespace blink |
OLD | NEW |