Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerClient.cpp

Issue 1040993003: ServiceWorker: Support non-window clients in Clients.matchAll (2/2 blink) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "config.h" 5 #include "config.h"
6 #include "modules/serviceworkers/ServiceWorkerClient.h" 6 #include "modules/serviceworkers/ServiceWorkerClient.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"
11 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" 11 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
12 #include "public/platform/WebString.h" 12 #include "public/platform/WebString.h"
13 #include "wtf/RefPtr.h" 13 #include "wtf/RefPtr.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 ServiceWorkerClient* ServiceWorkerClient::create(const WebServiceWorkerClientInf o& info) 17 ServiceWorkerClient* ServiceWorkerClient::create(const WebServiceWorkerClientInf o& info)
18 { 18 {
19 return new ServiceWorkerClient(info); 19 return new ServiceWorkerClient(info);
20 } 20 }
21 21
22 ServiceWorkerClient::ServiceWorkerClient(const WebServiceWorkerClientInfo& info) 22 ServiceWorkerClient::ServiceWorkerClient(const WebServiceWorkerClientInfo& info)
23 : m_uuid(info.uuid) 23 : m_uuid(info.uuid)
24 , m_url(info.url.string()) 24 , m_url(info.url.string())
25 , m_frameType(info.frameType)
25 { 26 {
26 } 27 }
27 28
28 ServiceWorkerClient::~ServiceWorkerClient() 29 ServiceWorkerClient::~ServiceWorkerClient()
29 { 30 {
30 } 31 }
31 32
33 String ServiceWorkerClient::frameType() const
34 {
35 switch (m_frameType) {
36 case WebURLRequest::FrameTypeAuxiliary:
37 return "auxiliary";
38 case WebURLRequest::FrameTypeNested:
39 return "nested";
40 case WebURLRequest::FrameTypeNone:
41 return "none";
42 case WebURLRequest::FrameTypeTopLevel:
43 return "top-level";
44 }
45
46 ASSERT_NOT_REACHED();
47 return String();
48 }
49
32 void ServiceWorkerClient::postMessage(ExecutionContext* context, PassRefPtr<Seri alizedScriptValue> message, const MessagePortArray* ports, ExceptionState& excep tionState) 50 void ServiceWorkerClient::postMessage(ExecutionContext* context, PassRefPtr<Seri alizedScriptValue> message, const MessagePortArray* ports, ExceptionState& excep tionState)
33 { 51 {
34 // Disentangle the port in preparation for sending it to the remote context. 52 // Disentangle the port in preparation for sending it to the remote context.
35 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(por ts, exceptionState); 53 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(por ts, exceptionState);
36 if (exceptionState.hadException()) 54 if (exceptionState.hadException())
37 return; 55 return;
38 56
39 WebString messageString = message->toWireString(); 57 WebString messageString = message->toWireString();
40 OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePo rtChannelArray(channels.release()); 58 OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePo rtChannelArray(channels.release());
41 ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_uuid, m essageString, webChannels.release()); 59 ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_uuid, m essageString, webChannels.release());
42 } 60 }
43 61
44 } // namespace blink 62 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698