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

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp

Issue 2637343002: Implement WebBluetooth descriptor.readValue() (Closed)
Patch Set: #3 Created 3 years, 11 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"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 ScriptState* scriptState, 168 ScriptState* scriptState,
169 ExceptionState&) { 169 ExceptionState&) {
170 return getPrimaryServicesImpl( 170 return getPrimaryServicesImpl(
171 scriptState, mojom::blink::WebBluetoothGATTQueryQuantity::MULTIPLE); 171 scriptState, mojom::blink::WebBluetoothGATTQueryQuantity::MULTIPLE);
172 } 172 }
173 173
174 ScriptPromise BluetoothRemoteGATTServer::getPrimaryServicesImpl( 174 ScriptPromise BluetoothRemoteGATTServer::getPrimaryServicesImpl(
175 ScriptState* scriptState, 175 ScriptState* scriptState,
176 mojom::blink::WebBluetoothGATTQueryQuantity quantity, 176 mojom::blink::WebBluetoothGATTQueryQuantity quantity,
177 String servicesUUID) { 177 String servicesUUID) {
178 // We always check that the device is connected.
179 if (!connected()) { 178 if (!connected()) {
180 return ScriptPromise::rejectWithDOMException( 179 return ScriptPromise::rejectWithDOMException(
181 scriptState, 180 scriptState,
182 DOMException::create(NetworkError, kGATTServerNotConnected)); 181 DOMException::create(NetworkError, kGATTServerNotConnected));
183 } 182 }
184 183
185 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 184 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
186 ScriptPromise promise = resolver->promise(); 185 ScriptPromise promise = resolver->promise();
187 AddToActiveAlgorithms(resolver); 186 AddToActiveAlgorithms(resolver);
188 187
189 mojom::blink::WebBluetoothService* service = m_device->bluetooth()->service(); 188 mojom::blink::WebBluetoothService* service = m_device->bluetooth()->service();
190 WTF::Optional<String> uuid = WTF::nullopt; 189 WTF::Optional<String> uuid = WTF::nullopt;
191 if (!servicesUUID.isEmpty()) 190 if (!servicesUUID.isEmpty())
192 uuid = servicesUUID; 191 uuid = servicesUUID;
193 192
194 service->RemoteServerGetPrimaryServices( 193 service->RemoteServerGetPrimaryServices(
195 device()->id(), quantity, uuid, 194 device()->id(), quantity, uuid,
196 convertToBaseCallback( 195 convertToBaseCallback(
197 WTF::bind(&BluetoothRemoteGATTServer::GetPrimaryServicesCallback, 196 WTF::bind(&BluetoothRemoteGATTServer::GetPrimaryServicesCallback,
198 wrapPersistent(this), quantity, wrapPersistent(resolver)))); 197 wrapPersistent(this), quantity, wrapPersistent(resolver))));
199 return promise; 198 return promise;
200 } 199 }
201 200
202 } // namespace blink 201 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698