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 ServiceWorkerClient* client; | |
21 if (!webClient) | |
22 client = nullptr; | |
23 else if (webClient->clientType == WebServiceWorkerClientTypeWindow) | |
24 client = ServiceWorkerWindowClient::create(*webClient); | |
25 else | |
26 client = ServiceWorkerClient::create(*webClient); | |
nhiroki
2016/02/03 09:40:00
Can you verify the passed |webClient| type using s
jungkees
2016/02/03 14:15:07
Addressed. Thanks!
| |
27 return client; | |
28 } | |
29 | |
17 ServiceWorkerClient* ServiceWorkerClient::create(const WebServiceWorkerClientInf o& info) | 30 ServiceWorkerClient* ServiceWorkerClient::create(const WebServiceWorkerClientInf o& info) |
18 { | 31 { |
19 return new ServiceWorkerClient(info); | 32 return new ServiceWorkerClient(info); |
20 } | 33 } |
21 | 34 |
22 ServiceWorkerClient::ServiceWorkerClient(const WebServiceWorkerClientInfo& info) | 35 ServiceWorkerClient::ServiceWorkerClient(const WebServiceWorkerClientInfo& info) |
23 : m_uuid(info.uuid) | 36 : m_uuid(info.uuid) |
24 , m_url(info.url.string()) | 37 , m_url(info.url.string()) |
25 , m_frameType(info.frameType) | 38 , m_frameType(info.frameType) |
26 { | 39 { |
(...skipping 29 matching lines...) Expand all Loading... | |
56 | 69 |
57 if (message->containsTransferableArrayBuffer()) | 70 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")); | 71 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni ngMessageLevel, "ServiceWorkerClient cannot send an ArrayBuffer as a transferabl e object yet. See http://crbug.com/511119")); |
59 | 72 |
60 WebString messageString = message->toWireString(); | 73 WebString messageString = message->toWireString(); |
61 OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePo rtChannelArray(channels.release()); | 74 OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePo rtChannelArray(channels.release()); |
62 ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_uuid, m essageString, webChannels.release()); | 75 ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_uuid, m essageString, webChannels.release()); |
63 } | 76 } |
64 | 77 |
65 } // namespace blink | 78 } // namespace blink |
OLD | NEW |