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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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
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 "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"
11 #include "core/inspector/ConsoleMessage.h" 11 #include "core/inspector/ConsoleMessage.h"
12 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" 12 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
13 #include "public/platform/WebString.h" 13 #include "public/platform/WebString.h"
14 #include "wtf/RefPtr.h" 14 #include "wtf/RefPtr.h"
15 #include <memory>
15 16
16 namespace blink { 17 namespace blink {
17 18
18 ServiceWorkerClient* ServiceWorkerClient::take(ScriptPromiseResolver*, PassOwnPt r<WebServiceWorkerClientInfo> webClient) 19 ServiceWorkerClient* ServiceWorkerClient::take(ScriptPromiseResolver*, std::uniq ue_ptr<WebServiceWorkerClientInfo> webClient)
19 { 20 {
20 if (!webClient) 21 if (!webClient)
21 return nullptr; 22 return nullptr;
22 23
23 switch (webClient->clientType) { 24 switch (webClient->clientType) {
24 case WebServiceWorkerClientTypeWindow: 25 case WebServiceWorkerClientTypeWindow:
25 return ServiceWorkerWindowClient::create(*webClient); 26 return ServiceWorkerWindowClient::create(*webClient);
26 case WebServiceWorkerClientTypeWorker: 27 case WebServiceWorkerClientTypeWorker:
27 case WebServiceWorkerClientTypeSharedWorker: 28 case WebServiceWorkerClientTypeSharedWorker:
28 return ServiceWorkerClient::create(*webClient); 29 return ServiceWorkerClient::create(*webClient);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return "top-level"; 64 return "top-level";
64 } 65 }
65 66
66 ASSERT_NOT_REACHED(); 67 ASSERT_NOT_REACHED();
67 return String(); 68 return String();
68 } 69 }
69 70
70 void ServiceWorkerClient::postMessage(ExecutionContext* context, PassRefPtr<Seri alizedScriptValue> message, const MessagePortArray& ports, ExceptionState& excep tionState) 71 void ServiceWorkerClient::postMessage(ExecutionContext* context, PassRefPtr<Seri alizedScriptValue> message, const MessagePortArray& ports, ExceptionState& excep tionState)
71 { 72 {
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 OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(con text, ports, exceptionState); 74 std::unique_ptr<MessagePortChannelArray> channels = MessagePort::disentangle Ports(context, ports, exceptionState);
74 if (exceptionState.hadException()) 75 if (exceptionState.hadException())
75 return; 76 return;
76 77
77 if (message->containsTransferableArrayBuffer()) 78 if (message->containsTransferableArrayBuffer())
78 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni ngMessageLevel, "ServiceWorkerClient cannot send an ArrayBuffer as a transferabl e object yet. See http://crbug.com/511119")); 79 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni ngMessageLevel, "ServiceWorkerClient cannot send an ArrayBuffer as a transferabl e object yet. See http://crbug.com/511119"));
79 80
80 WebString messageString = message->toWireString(); 81 WebString messageString = message->toWireString();
81 OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePo rtChannelArray(std::move(channels)); 82 std::unique_ptr<WebMessagePortChannelArray> webChannels = MessagePort::toWeb MessagePortChannelArray(std::move(channels));
82 ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_uuid, m essageString, std::move(webChannels)); 83 ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_uuid, m essageString, std::move(webChannels));
83 } 84 }
84 85
85 } // namespace blink 86 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698