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

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/bluetooth/BluetoothRemoteGATTServer.h" 5 #include "modules/bluetooth/BluetoothRemoteGATTServer.h"
6 6
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" 7 #include "bindings/core/v8/CallbackPromiseAdapter.h"
8 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "core/dom/DOMException.h" 10 #include "core/dom/DOMException.h"
11 #include "core/dom/ExceptionCode.h" 11 #include "core/dom/ExceptionCode.h"
12 #include "core/events/Event.h" 12 #include "core/events/Event.h"
13 #include "modules/bluetooth/BluetoothError.h" 13 #include "modules/bluetooth/BluetoothError.h"
14 #include "modules/bluetooth/BluetoothRemoteGATTService.h" 14 #include "modules/bluetooth/BluetoothRemoteGATTService.h"
15 #include "modules/bluetooth/BluetoothSupplement.h" 15 #include "modules/bluetooth/BluetoothSupplement.h"
16 #include "modules/bluetooth/BluetoothUUID.h" 16 #include "modules/bluetooth/BluetoothUUID.h"
17 #include "public/platform/modules/bluetooth/WebBluetooth.h" 17 #include "public/platform/modules/bluetooth/WebBluetooth.h"
18 #include "wtf/OwnPtr.h"
19 18
20 namespace blink { 19 namespace blink {
21 20
22 BluetoothRemoteGATTServer::BluetoothRemoteGATTServer(BluetoothDevice* device) 21 BluetoothRemoteGATTServer::BluetoothRemoteGATTServer(BluetoothDevice* device)
23 : m_device(device) 22 : m_device(device)
24 , m_connected(false) 23 , m_connected(false)
25 { 24 {
26 } 25 }
27 26
28 BluetoothRemoteGATTServer* BluetoothRemoteGATTServer::create(BluetoothDevice* de vice) 27 BluetoothRemoteGATTServer* BluetoothRemoteGATTServer::create(BluetoothDevice* de vice)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 : m_resolver(resolver) 89 : m_resolver(resolver)
91 , m_quantity(quantity) {} 90 , m_quantity(quantity) {}
92 91
93 void onSuccess(const WebVector<WebBluetoothRemoteGATTService*>& webServices) override 92 void onSuccess(const WebVector<WebBluetoothRemoteGATTService*>& webServices) override
94 { 93 {
95 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex t()->activeDOMObjectsAreStopped()) 94 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex t()->activeDOMObjectsAreStopped())
96 return; 95 return;
97 96
98 if (m_quantity == mojom::WebBluetoothGATTQueryQuantity::SINGLE) { 97 if (m_quantity == mojom::WebBluetoothGATTQueryQuantity::SINGLE) {
99 DCHECK_EQ(1u, webServices.size()); 98 DCHECK_EQ(1u, webServices.size());
100 m_resolver->resolve(BluetoothRemoteGATTService::take(m_resolver, ado ptPtr(webServices[0]))); 99 m_resolver->resolve(BluetoothRemoteGATTService::take(m_resolver, wra pUnique(webServices[0])));
101 return; 100 return;
102 } 101 }
103 102
104 HeapVector<Member<BluetoothRemoteGATTService>> services; 103 HeapVector<Member<BluetoothRemoteGATTService>> services;
105 services.reserveInitialCapacity(webServices.size()); 104 services.reserveInitialCapacity(webServices.size());
106 for (WebBluetoothRemoteGATTService* webService : webServices) { 105 for (WebBluetoothRemoteGATTService* webService : webServices) {
107 services.append(BluetoothRemoteGATTService::take(m_resolver, adoptPt r(webService))); 106 services.append(BluetoothRemoteGATTService::take(m_resolver, wrapUni que(webService)));
108 } 107 }
109 m_resolver->resolve(services); 108 m_resolver->resolve(services);
110 } 109 }
111 110
112 void onError(const WebBluetoothError& e) override 111 void onError(const WebBluetoothError& e) override
113 { 112 {
114 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex t()->activeDOMObjectsAreStopped()) 113 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex t()->activeDOMObjectsAreStopped())
115 return; 114 return;
116 m_resolver->reject(BluetoothError::take(m_resolver, e)); 115 m_resolver->reject(BluetoothError::take(m_resolver, e));
117 } 116 }
(...skipping 30 matching lines...) Expand all
148 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 147 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
149 ScriptPromise promise = resolver->promise(); 148 ScriptPromise promise = resolver->promise();
150 149
151 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e); 150 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e);
152 webbluetooth->getPrimaryServices(device()->id(), quantity, servicesUUID, new GetPrimaryServicesCallback(quantity, resolver)); 151 webbluetooth->getPrimaryServices(device()->id(), quantity, servicesUUID, new GetPrimaryServicesCallback(quantity, resolver));
153 152
154 return promise; 153 return promise;
155 } 154 }
156 155
157 } // namespace blink 156 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698