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

Side by Side Diff: content/browser/bluetooth/web_bluetooth_service_impl.cc

Issue 2667053002: Add RemoteGATTDescriptor to WebBluetoothFunction histogram enum. (Closed)
Patch Set: Missing return stmt. Created 3 years, 10 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 | « content/browser/bluetooth/bluetooth_metrics.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 // ID Not In Map Note: A service, characteristic, or descriptor ID not in the 5 // ID Not In Map Note: A service, characteristic, or descriptor ID not in the
6 // corresponding WebBluetoothServiceImpl map [service_id_to_device_address_, 6 // corresponding WebBluetoothServiceImpl map [service_id_to_device_address_,
7 // characteristic_id_to_service_id_, descriptor_id_to_characteristic_id_] 7 // characteristic_id_to_service_id_, descriptor_id_to_characteristic_id_]
8 // implies a hostile renderer because a renderer obtains the corresponding ID 8 // implies a hostile renderer because a renderer obtains the corresponding ID
9 // from this class and it will be added to the map at that time. 9 // from this class and it will be added to the map at that time.
10 10
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 : blink::mojom::WebBluetoothResult::NO_CHARACTERISTICS_FOUND, 521 : blink::mojom::WebBluetoothResult::NO_CHARACTERISTICS_FOUND,
522 base::nullopt /* characteristics */); 522 base::nullopt /* characteristics */);
523 } 523 }
524 524
525 void WebBluetoothServiceImpl::RemoteCharacteristicGetDescriptors( 525 void WebBluetoothServiceImpl::RemoteCharacteristicGetDescriptors(
526 const std::string& characteristic_instance_id, 526 const std::string& characteristic_instance_id,
527 blink::mojom::WebBluetoothGATTQueryQuantity quantity, 527 blink::mojom::WebBluetoothGATTQueryQuantity quantity,
528 const base::Optional<BluetoothUUID>& descriptors_uuid, 528 const base::Optional<BluetoothUUID>& descriptors_uuid,
529 const RemoteCharacteristicGetDescriptorsCallback& callback) { 529 const RemoteCharacteristicGetDescriptorsCallback& callback) {
530 DCHECK_CURRENTLY_ON(BrowserThread::UI); 530 DCHECK_CURRENTLY_ON(BrowserThread::UI);
531
532 RecordWebBluetoothFunctionCall(
533 quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE
534 ? UMAWebBluetoothFunction::CHARACTERISTIC_GET_DESCRIPTOR
535 : UMAWebBluetoothFunction::CHARACTERISTIC_GET_DESCRIPTORS);
536 RecordGetDescriptorsDescriptor(quantity, descriptors_uuid);
537
531 if (descriptors_uuid && 538 if (descriptors_uuid &&
532 BluetoothBlocklist::Get().IsExcluded(descriptors_uuid.value())) { 539 BluetoothBlocklist::Get().IsExcluded(descriptors_uuid.value())) {
540 RecordGetDescriptorsOutcome(quantity, UMAGetDescriptorOutcome::BLOCKLISTED);
533 callback.Run(blink::mojom::WebBluetoothResult::BLOCKLISTED_DESCRIPTOR_UUID, 541 callback.Run(blink::mojom::WebBluetoothResult::BLOCKLISTED_DESCRIPTOR_UUID,
534 base::nullopt /* descriptor */); 542 base::nullopt /* descriptor */);
535 return; 543 return;
536 } 544 }
537 545
538 const CacheQueryResult query_result = 546 const CacheQueryResult query_result =
539 QueryCacheForCharacteristic(characteristic_instance_id); 547 QueryCacheForCharacteristic(characteristic_instance_id);
540 548
541 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { 549 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) {
542 return; 550 return;
543 } 551 }
544 552
545 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { 553 if (query_result.outcome != CacheQueryOutcome::SUCCESS) {
554 RecordGetDescriptorsOutcome(quantity, query_result.outcome);
546 callback.Run(query_result.GetWebResult(), base::nullopt /* descriptor */); 555 callback.Run(query_result.GetWebResult(), base::nullopt /* descriptor */);
547 return; 556 return;
548 } 557 }
549 558
550 auto descriptors = 559 auto descriptors =
551 descriptors_uuid 560 descriptors_uuid
552 ? query_result.device->GetDescriptorsByUUID( 561 ? query_result.device->GetDescriptorsByUUID(
553 query_result.characteristic, descriptors_uuid.value()) 562 query_result.characteristic, descriptors_uuid.value())
554 : query_result.characteristic->GetDescriptors(); 563 : query_result.characteristic->GetDescriptors();
555 564
(...skipping 14 matching lines...) Expand all
570 descriptor_ptr->instance_id = descriptor_instance_id; 579 descriptor_ptr->instance_id = descriptor_instance_id;
571 descriptor_ptr->uuid = descriptor->GetUUID(); 580 descriptor_ptr->uuid = descriptor->GetUUID();
572 response_descriptors.push_back(std::move(descriptor_ptr)); 581 response_descriptors.push_back(std::move(descriptor_ptr));
573 582
574 if (quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE) { 583 if (quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE) {
575 break; 584 break;
576 } 585 }
577 } 586 }
578 587
579 if (!response_descriptors.empty()) { 588 if (!response_descriptors.empty()) {
589 RecordGetDescriptorsOutcome(quantity, UMAGetDescriptorOutcome::SUCCESS);
580 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS, 590 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS,
581 std::move(response_descriptors)); 591 std::move(response_descriptors));
582 return; 592 return;
583 } 593 }
584 594 RecordGetDescriptorsOutcome(
595 quantity, descriptors_uuid ? UMAGetDescriptorOutcome::NOT_FOUND
596 : UMAGetDescriptorOutcome::NO_DESCRIPTORS);
585 callback.Run(descriptors_uuid 597 callback.Run(descriptors_uuid
586 ? blink::mojom::WebBluetoothResult::DESCRIPTOR_NOT_FOUND 598 ? blink::mojom::WebBluetoothResult::DESCRIPTOR_NOT_FOUND
587 : blink::mojom::WebBluetoothResult::NO_DESCRIPTORS_FOUND, 599 : blink::mojom::WebBluetoothResult::NO_DESCRIPTORS_FOUND,
588 base::nullopt /* descriptors */); 600 base::nullopt /* descriptors */);
589 } 601 }
590 602
591 void WebBluetoothServiceImpl::RemoteCharacteristicReadValue( 603 void WebBluetoothServiceImpl::RemoteCharacteristicReadValue(
592 const std::string& characteristic_instance_id, 604 const std::string& characteristic_instance_id,
593 const RemoteCharacteristicReadValueCallback& callback) { 605 const RemoteCharacteristicReadValueCallback& callback) {
594 DCHECK_CURRENTLY_ON(BrowserThread::UI); 606 DCHECK_CURRENTLY_ON(BrowserThread::UI);
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 descriptor_id_to_characteristic_id_.clear(); 1207 descriptor_id_to_characteristic_id_.clear();
1196 characteristic_id_to_service_id_.clear(); 1208 characteristic_id_to_service_id_.clear();
1197 service_id_to_device_address_.clear(); 1209 service_id_to_device_address_.clear();
1198 connected_devices_.reset( 1210 connected_devices_.reset(
1199 new FrameConnectedBluetoothDevices(render_frame_host_)); 1211 new FrameConnectedBluetoothDevices(render_frame_host_));
1200 device_chooser_controller_.reset(); 1212 device_chooser_controller_.reset();
1201 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); 1213 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this);
1202 } 1214 }
1203 1215
1204 } // namespace content 1216 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/bluetooth/bluetooth_metrics.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698