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

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

Issue 2728813002: bluetooth: Improve error message for retrieving Descriptors when disconnecting (Closed)
Patch Set: Fix conflict error Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/BluetoothRemoteGATTCharacteristic.h" 5 #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h"
6 6
7 #include "bindings/core/v8/ScriptPromise.h" 7 #include "bindings/core/v8/ScriptPromise.h"
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
10 #include "core/events/Event.h" 10 #include "core/events/Event.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 scriptState, mojom::blink::WebBluetoothGATTQueryQuantity::MULTIPLE, 328 scriptState, mojom::blink::WebBluetoothGATTQueryQuantity::MULTIPLE,
329 descriptor); 329 descriptor);
330 } 330 }
331 331
332 ScriptPromise BluetoothRemoteGATTCharacteristic::getDescriptorsImpl( 332 ScriptPromise BluetoothRemoteGATTCharacteristic::getDescriptorsImpl(
333 ScriptState* scriptState, 333 ScriptState* scriptState,
334 mojom::blink::WebBluetoothGATTQueryQuantity quantity, 334 mojom::blink::WebBluetoothGATTQueryQuantity quantity,
335 const String& descriptorsUUID) { 335 const String& descriptorsUUID) {
336 if (!getGatt()->connected()) { 336 if (!getGatt()->connected()) {
337 return ScriptPromise::rejectWithDOMException( 337 return ScriptPromise::rejectWithDOMException(
338 scriptState, 338 scriptState, BluetoothError::createNotConnectedException(
339 // TODO(crbug.com/684445): Change to DescriptorsRetrieval. 339 BluetoothOperation::DescriptorsRetrieval));
340 BluetoothError::createNotConnectedException(BluetoothOperation::GATT));
341 } 340 }
342 341
343 if (!getGatt()->device()->isValidCharacteristic( 342 if (!getGatt()->device()->isValidCharacteristic(
344 m_characteristic->instance_id)) { 343 m_characteristic->instance_id)) {
345 return ScriptPromise::rejectWithDOMException( 344 return ScriptPromise::rejectWithDOMException(
346 scriptState, createInvalidCharacteristicError()); 345 scriptState, createInvalidCharacteristicError());
347 } 346 }
348 347
349 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 348 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
350 ScriptPromise promise = resolver->promise(); 349 ScriptPromise promise = resolver->promise();
(...skipping 19 matching lines...) Expand all
370 ScriptPromiseResolver* resolver, 369 ScriptPromiseResolver* resolver,
371 mojom::blink::WebBluetoothResult result, 370 mojom::blink::WebBluetoothResult result,
372 Optional<Vector<mojom::blink::WebBluetoothRemoteGATTDescriptorPtr>> 371 Optional<Vector<mojom::blink::WebBluetoothRemoteGATTDescriptorPtr>>
373 descriptors) { 372 descriptors) {
374 if (!resolver->getExecutionContext() || 373 if (!resolver->getExecutionContext() ||
375 resolver->getExecutionContext()->isContextDestroyed()) 374 resolver->getExecutionContext()->isContextDestroyed())
376 return; 375 return;
377 376
378 // If the device is disconnected, reject. 377 // If the device is disconnected, reject.
379 if (!m_service->device()->gatt()->RemoveFromActiveAlgorithms(resolver)) { 378 if (!m_service->device()->gatt()->RemoveFromActiveAlgorithms(resolver)) {
380 // TODO(crbug.com/684445): Change to DescriptorsRetrieval. 379 resolver->reject(BluetoothError::createNotConnectedException(
381 resolver->reject( 380 BluetoothOperation::DescriptorsRetrieval));
382 BluetoothError::createNotConnectedException(BluetoothOperation::GATT));
383 return; 381 return;
384 } 382 }
385 383
386 if (result == mojom::blink::WebBluetoothResult::SUCCESS) { 384 if (result == mojom::blink::WebBluetoothResult::SUCCESS) {
387 DCHECK(descriptors); 385 DCHECK(descriptors);
388 386
389 if (quantity == mojom::blink::WebBluetoothGATTQueryQuantity::SINGLE) { 387 if (quantity == mojom::blink::WebBluetoothGATTQueryQuantity::SINGLE) {
390 DCHECK_EQ(1u, descriptors->size()); 388 DCHECK_EQ(1u, descriptors->size());
391 resolver->resolve( 389 resolver->resolve(
392 m_service->device()->getOrCreateBluetoothRemoteGATTDescriptor( 390 m_service->device()->getOrCreateBluetoothRemoteGATTDescriptor(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) { 424 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) {
427 visitor->trace(m_service); 425 visitor->trace(m_service);
428 visitor->trace(m_properties); 426 visitor->trace(m_properties);
429 visitor->trace(m_value); 427 visitor->trace(m_value);
430 visitor->trace(m_device); 428 visitor->trace(m_device);
431 EventTargetWithInlineData::trace(visitor); 429 EventTargetWithInlineData::trace(visitor);
432 ContextLifecycleObserver::trace(visitor); 430 ContextLifecycleObserver::trace(visitor);
433 } 431 }
434 432
435 } // namespace blink 433 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698