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

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

Issue 2771893002: Move Bluetooth.Web.FunctionCall.Count UMA from browser to WebKit (Closed)
Patch Set: address more comment Created 3 years, 8 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 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 characteristic_id_to_notify_session_.find(characteristic_instance_id); 285 characteristic_id_to_notify_session_.find(characteristic_instance_id);
286 if (iter != characteristic_id_to_notify_session_.end()) { 286 if (iter != characteristic_id_to_notify_session_.end()) {
287 iter->second->characteristic_client->RemoteCharacteristicValueChanged( 287 iter->second->characteristic_client->RemoteCharacteristicValueChanged(
288 value); 288 value);
289 } 289 }
290 } 290 }
291 291
292 void WebBluetoothServiceImpl::RequestDevice( 292 void WebBluetoothServiceImpl::RequestDevice(
293 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, 293 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options,
294 const RequestDeviceCallback& callback) { 294 const RequestDeviceCallback& callback) {
295 RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::REQUEST_DEVICE);
296 RecordRequestDeviceOptions(options); 295 RecordRequestDeviceOptions(options);
297 296
298 if (!GetAdapter()) { 297 if (!GetAdapter()) {
299 if (BluetoothAdapterFactoryWrapper::Get().IsLowEnergyAvailable()) { 298 if (BluetoothAdapterFactoryWrapper::Get().IsLowEnergyAvailable()) {
300 BluetoothAdapterFactoryWrapper::Get().AcquireAdapter( 299 BluetoothAdapterFactoryWrapper::Get().AcquireAdapter(
301 this, base::Bind(&WebBluetoothServiceImpl::RequestDeviceImpl, 300 this, base::Bind(&WebBluetoothServiceImpl::RequestDeviceImpl,
302 weak_ptr_factory_.GetWeakPtr(), 301 weak_ptr_factory_.GetWeakPtr(),
303 base::Passed(std::move(options)), callback)); 302 base::Passed(std::move(options)), callback));
304 return; 303 return;
305 } 304 }
306 RecordRequestDeviceOutcome( 305 RecordRequestDeviceOutcome(
307 UMARequestDeviceOutcome::BLUETOOTH_LOW_ENERGY_NOT_AVAILABLE); 306 UMARequestDeviceOutcome::BLUETOOTH_LOW_ENERGY_NOT_AVAILABLE);
308 callback.Run( 307 callback.Run(
309 blink::mojom::WebBluetoothResult::BLUETOOTH_LOW_ENERGY_NOT_AVAILABLE, 308 blink::mojom::WebBluetoothResult::BLUETOOTH_LOW_ENERGY_NOT_AVAILABLE,
310 nullptr /* device */); 309 nullptr /* device */);
311 return; 310 return;
312 } 311 }
313 RequestDeviceImpl(std::move(options), callback, GetAdapter()); 312 RequestDeviceImpl(std::move(options), callback, GetAdapter());
314 } 313 }
315 314
316 void WebBluetoothServiceImpl::RemoteServerConnect( 315 void WebBluetoothServiceImpl::RemoteServerConnect(
317 const WebBluetoothDeviceId& device_id, 316 const WebBluetoothDeviceId& device_id,
318 blink::mojom::WebBluetoothServerClientAssociatedPtrInfo client, 317 blink::mojom::WebBluetoothServerClientAssociatedPtrInfo client,
319 const RemoteServerConnectCallback& callback) { 318 const RemoteServerConnectCallback& callback) {
320 DCHECK_CURRENTLY_ON(BrowserThread::UI); 319 DCHECK_CURRENTLY_ON(BrowserThread::UI);
321 RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::CONNECT_GATT);
322 320
323 const CacheQueryResult query_result = QueryCacheForDevice(device_id); 321 const CacheQueryResult query_result = QueryCacheForDevice(device_id);
324 322
325 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { 323 if (query_result.outcome != CacheQueryOutcome::SUCCESS) {
326 RecordConnectGATTOutcome(query_result.outcome); 324 RecordConnectGATTOutcome(query_result.outcome);
327 callback.Run(query_result.GetWebResult()); 325 callback.Run(query_result.GetWebResult());
328 return; 326 return;
329 } 327 }
330 328
331 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { 329 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) {
(...skipping 19 matching lines...) Expand all
351 base::Bind(&WebBluetoothServiceImpl::OnCreateGATTConnectionSuccess, 349 base::Bind(&WebBluetoothServiceImpl::OnCreateGATTConnectionSuccess,
352 weak_ptr_factory_.GetWeakPtr(), device_id, start_time, 350 weak_ptr_factory_.GetWeakPtr(), device_id, start_time,
353 base::Passed(&web_bluetooth_server_client), callback), 351 base::Passed(&web_bluetooth_server_client), callback),
354 base::Bind(&WebBluetoothServiceImpl::OnCreateGATTConnectionFailed, 352 base::Bind(&WebBluetoothServiceImpl::OnCreateGATTConnectionFailed,
355 weak_ptr_factory_.GetWeakPtr(), start_time, callback)); 353 weak_ptr_factory_.GetWeakPtr(), start_time, callback));
356 } 354 }
357 355
358 void WebBluetoothServiceImpl::RemoteServerDisconnect( 356 void WebBluetoothServiceImpl::RemoteServerDisconnect(
359 const WebBluetoothDeviceId& device_id) { 357 const WebBluetoothDeviceId& device_id) {
360 DCHECK_CURRENTLY_ON(BrowserThread::UI); 358 DCHECK_CURRENTLY_ON(BrowserThread::UI);
361 RecordWebBluetoothFunctionCall(
362 UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT);
363 359
364 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { 360 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) {
365 DVLOG(1) << "Disconnecting device: " << device_id.str(); 361 DVLOG(1) << "Disconnecting device: " << device_id.str();
366 connected_devices_->CloseConnectionToDeviceWithId(device_id); 362 connected_devices_->CloseConnectionToDeviceWithId(device_id);
367 } 363 }
368 } 364 }
369 365
370 void WebBluetoothServiceImpl::RemoteServerGetPrimaryServices( 366 void WebBluetoothServiceImpl::RemoteServerGetPrimaryServices(
371 const WebBluetoothDeviceId& device_id, 367 const WebBluetoothDeviceId& device_id,
372 blink::mojom::WebBluetoothGATTQueryQuantity quantity, 368 blink::mojom::WebBluetoothGATTQueryQuantity quantity,
373 const base::Optional<BluetoothUUID>& services_uuid, 369 const base::Optional<BluetoothUUID>& services_uuid,
374 const RemoteServerGetPrimaryServicesCallback& callback) { 370 const RemoteServerGetPrimaryServicesCallback& callback) {
375 DCHECK_CURRENTLY_ON(BrowserThread::UI); 371 DCHECK_CURRENTLY_ON(BrowserThread::UI);
376 RecordWebBluetoothFunctionCall(
377 quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE
378 ? UMAWebBluetoothFunction::GET_PRIMARY_SERVICE
379 : UMAWebBluetoothFunction::GET_PRIMARY_SERVICES);
380 RecordGetPrimaryServicesServices(quantity, services_uuid); 372 RecordGetPrimaryServicesServices(quantity, services_uuid);
381 373
382 if (!allowed_devices().IsAllowedToAccessAtLeastOneService(device_id)) { 374 if (!allowed_devices().IsAllowedToAccessAtLeastOneService(device_id)) {
383 callback.Run( 375 callback.Run(
384 blink::mojom::WebBluetoothResult::NOT_ALLOWED_TO_ACCESS_ANY_SERVICE, 376 blink::mojom::WebBluetoothResult::NOT_ALLOWED_TO_ACCESS_ANY_SERVICE,
385 base::nullopt /* service */); 377 base::nullopt /* service */);
386 return; 378 return;
387 } 379 }
388 380
389 if (services_uuid && 381 if (services_uuid &&
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 base::Unretained(this), device_id, quantity, services_uuid, callback)); 415 base::Unretained(this), device_id, quantity, services_uuid, callback));
424 } 416 }
425 417
426 void WebBluetoothServiceImpl::RemoteServiceGetCharacteristics( 418 void WebBluetoothServiceImpl::RemoteServiceGetCharacteristics(
427 const std::string& service_instance_id, 419 const std::string& service_instance_id,
428 blink::mojom::WebBluetoothGATTQueryQuantity quantity, 420 blink::mojom::WebBluetoothGATTQueryQuantity quantity,
429 const base::Optional<BluetoothUUID>& characteristics_uuid, 421 const base::Optional<BluetoothUUID>& characteristics_uuid,
430 const RemoteServiceGetCharacteristicsCallback& callback) { 422 const RemoteServiceGetCharacteristicsCallback& callback) {
431 DCHECK_CURRENTLY_ON(BrowserThread::UI); 423 DCHECK_CURRENTLY_ON(BrowserThread::UI);
432 424
433 RecordWebBluetoothFunctionCall(
434 quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE
435 ? UMAWebBluetoothFunction::SERVICE_GET_CHARACTERISTIC
436 : UMAWebBluetoothFunction::SERVICE_GET_CHARACTERISTICS);
437 RecordGetCharacteristicsCharacteristic(quantity, characteristics_uuid); 425 RecordGetCharacteristicsCharacteristic(quantity, characteristics_uuid);
438 426
439 if (characteristics_uuid && 427 if (characteristics_uuid &&
440 BluetoothBlocklist::Get().IsExcluded(characteristics_uuid.value())) { 428 BluetoothBlocklist::Get().IsExcluded(characteristics_uuid.value())) {
441 RecordGetCharacteristicsOutcome(quantity, 429 RecordGetCharacteristicsOutcome(quantity,
442 UMAGetCharacteristicOutcome::BLOCKLISTED); 430 UMAGetCharacteristicOutcome::BLOCKLISTED);
443 callback.Run( 431 callback.Run(
444 blink::mojom::WebBluetoothResult::BLOCKLISTED_CHARACTERISTIC_UUID, 432 blink::mojom::WebBluetoothResult::BLOCKLISTED_CHARACTERISTIC_UUID,
445 base::nullopt /* characteristics */); 433 base::nullopt /* characteristics */);
446 return; 434 return;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 base::nullopt /* characteristics */); 499 base::nullopt /* characteristics */);
512 } 500 }
513 501
514 void WebBluetoothServiceImpl::RemoteCharacteristicGetDescriptors( 502 void WebBluetoothServiceImpl::RemoteCharacteristicGetDescriptors(
515 const std::string& characteristic_instance_id, 503 const std::string& characteristic_instance_id,
516 blink::mojom::WebBluetoothGATTQueryQuantity quantity, 504 blink::mojom::WebBluetoothGATTQueryQuantity quantity,
517 const base::Optional<BluetoothUUID>& descriptors_uuid, 505 const base::Optional<BluetoothUUID>& descriptors_uuid,
518 const RemoteCharacteristicGetDescriptorsCallback& callback) { 506 const RemoteCharacteristicGetDescriptorsCallback& callback) {
519 DCHECK_CURRENTLY_ON(BrowserThread::UI); 507 DCHECK_CURRENTLY_ON(BrowserThread::UI);
520 508
521 RecordWebBluetoothFunctionCall(
522 quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE
523 ? UMAWebBluetoothFunction::CHARACTERISTIC_GET_DESCRIPTOR
524 : UMAWebBluetoothFunction::CHARACTERISTIC_GET_DESCRIPTORS);
525 RecordGetDescriptorsDescriptor(quantity, descriptors_uuid); 509 RecordGetDescriptorsDescriptor(quantity, descriptors_uuid);
526 510
527 if (descriptors_uuid && 511 if (descriptors_uuid &&
528 BluetoothBlocklist::Get().IsExcluded(descriptors_uuid.value())) { 512 BluetoothBlocklist::Get().IsExcluded(descriptors_uuid.value())) {
529 RecordGetDescriptorsOutcome(quantity, UMAGetDescriptorOutcome::BLOCKLISTED); 513 RecordGetDescriptorsOutcome(quantity, UMAGetDescriptorOutcome::BLOCKLISTED);
530 callback.Run(blink::mojom::WebBluetoothResult::BLOCKLISTED_DESCRIPTOR_UUID, 514 callback.Run(blink::mojom::WebBluetoothResult::BLOCKLISTED_DESCRIPTOR_UUID,
531 base::nullopt /* descriptor */); 515 base::nullopt /* descriptor */);
532 return; 516 return;
533 } 517 }
534 518
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 callback.Run(descriptors_uuid 570 callback.Run(descriptors_uuid
587 ? blink::mojom::WebBluetoothResult::DESCRIPTOR_NOT_FOUND 571 ? blink::mojom::WebBluetoothResult::DESCRIPTOR_NOT_FOUND
588 : blink::mojom::WebBluetoothResult::NO_DESCRIPTORS_FOUND, 572 : blink::mojom::WebBluetoothResult::NO_DESCRIPTORS_FOUND,
589 base::nullopt /* descriptors */); 573 base::nullopt /* descriptors */);
590 } 574 }
591 575
592 void WebBluetoothServiceImpl::RemoteCharacteristicReadValue( 576 void WebBluetoothServiceImpl::RemoteCharacteristicReadValue(
593 const std::string& characteristic_instance_id, 577 const std::string& characteristic_instance_id,
594 const RemoteCharacteristicReadValueCallback& callback) { 578 const RemoteCharacteristicReadValueCallback& callback) {
595 DCHECK_CURRENTLY_ON(BrowserThread::UI); 579 DCHECK_CURRENTLY_ON(BrowserThread::UI);
596 RecordWebBluetoothFunctionCall(
597 UMAWebBluetoothFunction::CHARACTERISTIC_READ_VALUE);
598 580
599 const CacheQueryResult query_result = 581 const CacheQueryResult query_result =
600 QueryCacheForCharacteristic(characteristic_instance_id); 582 QueryCacheForCharacteristic(characteristic_instance_id);
601 583
602 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { 584 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) {
603 return; 585 return;
604 } 586 }
605 587
606 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { 588 if (query_result.outcome != CacheQueryOutcome::SUCCESS) {
607 RecordCharacteristicReadValueOutcome(query_result.outcome); 589 RecordCharacteristicReadValueOutcome(query_result.outcome);
(...skipping 14 matching lines...) Expand all
622 weak_ptr_factory_.GetWeakPtr(), callback), 604 weak_ptr_factory_.GetWeakPtr(), callback),
623 base::Bind(&WebBluetoothServiceImpl::OnCharacteristicReadValueFailed, 605 base::Bind(&WebBluetoothServiceImpl::OnCharacteristicReadValueFailed,
624 weak_ptr_factory_.GetWeakPtr(), callback)); 606 weak_ptr_factory_.GetWeakPtr(), callback));
625 } 607 }
626 608
627 void WebBluetoothServiceImpl::RemoteCharacteristicWriteValue( 609 void WebBluetoothServiceImpl::RemoteCharacteristicWriteValue(
628 const std::string& characteristic_instance_id, 610 const std::string& characteristic_instance_id,
629 const std::vector<uint8_t>& value, 611 const std::vector<uint8_t>& value,
630 const RemoteCharacteristicWriteValueCallback& callback) { 612 const RemoteCharacteristicWriteValueCallback& callback) {
631 DCHECK_CURRENTLY_ON(BrowserThread::UI); 613 DCHECK_CURRENTLY_ON(BrowserThread::UI);
632 RecordWebBluetoothFunctionCall(
633 UMAWebBluetoothFunction::CHARACTERISTIC_WRITE_VALUE);
634 614
635 // We perform the length check on the renderer side. So if we 615 // We perform the length check on the renderer side. So if we
636 // get a value with length > 512, we can assume it's a hostile 616 // get a value with length > 512, we can assume it's a hostile
637 // renderer and kill it. 617 // renderer and kill it.
638 if (value.size() > 512) { 618 if (value.size() > 512) {
639 CrashRendererAndClosePipe(bad_message::BDH_INVALID_WRITE_VALUE_LENGTH); 619 CrashRendererAndClosePipe(bad_message::BDH_INVALID_WRITE_VALUE_LENGTH);
640 return; 620 return;
641 } 621 }
642 622
643 const CacheQueryResult query_result = 623 const CacheQueryResult query_result =
(...skipping 22 matching lines...) Expand all
666 weak_ptr_factory_.GetWeakPtr(), callback), 646 weak_ptr_factory_.GetWeakPtr(), callback),
667 base::Bind(&WebBluetoothServiceImpl::OnCharacteristicWriteValueFailed, 647 base::Bind(&WebBluetoothServiceImpl::OnCharacteristicWriteValueFailed,
668 weak_ptr_factory_.GetWeakPtr(), callback)); 648 weak_ptr_factory_.GetWeakPtr(), callback));
669 } 649 }
670 650
671 void WebBluetoothServiceImpl::RemoteCharacteristicStartNotifications( 651 void WebBluetoothServiceImpl::RemoteCharacteristicStartNotifications(
672 const std::string& characteristic_instance_id, 652 const std::string& characteristic_instance_id,
673 blink::mojom::WebBluetoothCharacteristicClientAssociatedPtrInfo client, 653 blink::mojom::WebBluetoothCharacteristicClientAssociatedPtrInfo client,
674 const RemoteCharacteristicStartNotificationsCallback& callback) { 654 const RemoteCharacteristicStartNotificationsCallback& callback) {
675 DCHECK_CURRENTLY_ON(BrowserThread::UI); 655 DCHECK_CURRENTLY_ON(BrowserThread::UI);
676 RecordWebBluetoothFunctionCall(
677 UMAWebBluetoothFunction::CHARACTERISTIC_START_NOTIFICATIONS);
678 656
679 auto iter = 657 auto iter =
680 characteristic_id_to_notify_session_.find(characteristic_instance_id); 658 characteristic_id_to_notify_session_.find(characteristic_instance_id);
681 if (iter != characteristic_id_to_notify_session_.end() && 659 if (iter != characteristic_id_to_notify_session_.end() &&
682 iter->second->gatt_notify_session->IsActive()) { 660 iter->second->gatt_notify_session->IsActive()) {
683 // If the frame has already started notifications and the notifications 661 // If the frame has already started notifications and the notifications
684 // are active we return SUCCESS. 662 // are active we return SUCCESS.
685 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS); 663 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS);
686 return; 664 return;
687 } 665 }
(...skipping 29 matching lines...) Expand all
717 weak_ptr_factory_.GetWeakPtr(), 695 weak_ptr_factory_.GetWeakPtr(),
718 base::Passed(&characteristic_client), callback), 696 base::Passed(&characteristic_client), callback),
719 base::Bind(&WebBluetoothServiceImpl::OnStartNotifySessionFailed, 697 base::Bind(&WebBluetoothServiceImpl::OnStartNotifySessionFailed,
720 weak_ptr_factory_.GetWeakPtr(), callback)); 698 weak_ptr_factory_.GetWeakPtr(), callback));
721 } 699 }
722 700
723 void WebBluetoothServiceImpl::RemoteCharacteristicStopNotifications( 701 void WebBluetoothServiceImpl::RemoteCharacteristicStopNotifications(
724 const std::string& characteristic_instance_id, 702 const std::string& characteristic_instance_id,
725 const RemoteCharacteristicStopNotificationsCallback& callback) { 703 const RemoteCharacteristicStopNotificationsCallback& callback) {
726 DCHECK_CURRENTLY_ON(BrowserThread::UI); 704 DCHECK_CURRENTLY_ON(BrowserThread::UI);
727 RecordWebBluetoothFunctionCall(
728 UMAWebBluetoothFunction::CHARACTERISTIC_STOP_NOTIFICATIONS);
729 705
730 const CacheQueryResult query_result = 706 const CacheQueryResult query_result =
731 QueryCacheForCharacteristic(characteristic_instance_id); 707 QueryCacheForCharacteristic(characteristic_instance_id);
732 708
733 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { 709 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) {
734 return; 710 return;
735 } 711 }
736 712
737 auto notify_session_iter = 713 auto notify_session_iter =
738 characteristic_id_to_notify_session_.find(characteristic_instance_id); 714 characteristic_id_to_notify_session_.find(characteristic_instance_id);
739 if (notify_session_iter == characteristic_id_to_notify_session_.end()) { 715 if (notify_session_iter == characteristic_id_to_notify_session_.end()) {
740 // If the frame hasn't subscribed to notifications before we just 716 // If the frame hasn't subscribed to notifications before we just
741 // run the callback. 717 // run the callback.
742 callback.Run(); 718 callback.Run();
743 return; 719 return;
744 } 720 }
745 notify_session_iter->second->gatt_notify_session->Stop(base::Bind( 721 notify_session_iter->second->gatt_notify_session->Stop(base::Bind(
746 &WebBluetoothServiceImpl::OnStopNotifySessionComplete, 722 &WebBluetoothServiceImpl::OnStopNotifySessionComplete,
747 weak_ptr_factory_.GetWeakPtr(), characteristic_instance_id, callback)); 723 weak_ptr_factory_.GetWeakPtr(), characteristic_instance_id, callback));
748 } 724 }
749 725
750 void WebBluetoothServiceImpl::RemoteDescriptorReadValue( 726 void WebBluetoothServiceImpl::RemoteDescriptorReadValue(
751 const std::string& descriptor_instance_id, 727 const std::string& descriptor_instance_id,
752 const RemoteDescriptorReadValueCallback& callback) { 728 const RemoteDescriptorReadValueCallback& callback) {
753 DCHECK_CURRENTLY_ON(BrowserThread::UI); 729 DCHECK_CURRENTLY_ON(BrowserThread::UI);
754 RecordWebBluetoothFunctionCall(
755 UMAWebBluetoothFunction::DESCRIPTOR_READ_VALUE);
756 730
757 const CacheQueryResult query_result = 731 const CacheQueryResult query_result =
758 QueryCacheForDescriptor(descriptor_instance_id); 732 QueryCacheForDescriptor(descriptor_instance_id);
759 733
760 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { 734 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) {
761 return; 735 return;
762 } 736 }
763 737
764 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { 738 if (query_result.outcome != CacheQueryOutcome::SUCCESS) {
765 RecordDescriptorReadValueOutcome(query_result.outcome); 739 RecordDescriptorReadValueOutcome(query_result.outcome);
(...skipping 14 matching lines...) Expand all
780 weak_ptr_factory_.GetWeakPtr(), callback), 754 weak_ptr_factory_.GetWeakPtr(), callback),
781 base::Bind(&WebBluetoothServiceImpl::OnDescriptorReadValueFailed, 755 base::Bind(&WebBluetoothServiceImpl::OnDescriptorReadValueFailed,
782 weak_ptr_factory_.GetWeakPtr(), callback)); 756 weak_ptr_factory_.GetWeakPtr(), callback));
783 } 757 }
784 758
785 void WebBluetoothServiceImpl::RemoteDescriptorWriteValue( 759 void WebBluetoothServiceImpl::RemoteDescriptorWriteValue(
786 const std::string& descriptor_instance_id, 760 const std::string& descriptor_instance_id,
787 const std::vector<uint8_t>& value, 761 const std::vector<uint8_t>& value,
788 const RemoteDescriptorWriteValueCallback& callback) { 762 const RemoteDescriptorWriteValueCallback& callback) {
789 DCHECK_CURRENTLY_ON(BrowserThread::UI); 763 DCHECK_CURRENTLY_ON(BrowserThread::UI);
790 RecordWebBluetoothFunctionCall(
791 UMAWebBluetoothFunction::DESCRIPTOR_WRITE_VALUE);
792 764
793 // We perform the length check on the renderer side. So if we 765 // We perform the length check on the renderer side. So if we
794 // get a value with length > 512, we can assume it's a hostile 766 // get a value with length > 512, we can assume it's a hostile
795 // renderer and kill it. 767 // renderer and kill it.
796 if (value.size() > 512) { 768 if (value.size() > 512) {
797 CrashRendererAndClosePipe(bad_message::BDH_INVALID_WRITE_VALUE_LENGTH); 769 CrashRendererAndClosePipe(bad_message::BDH_INVALID_WRITE_VALUE_LENGTH);
798 return; 770 return;
799 } 771 }
800 772
801 const CacheQueryResult query_result = 773 const CacheQueryResult query_result =
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 descriptor_id_to_characteristic_id_.clear(); 1187 descriptor_id_to_characteristic_id_.clear();
1216 characteristic_id_to_service_id_.clear(); 1188 characteristic_id_to_service_id_.clear();
1217 service_id_to_device_address_.clear(); 1189 service_id_to_device_address_.clear();
1218 connected_devices_.reset( 1190 connected_devices_.reset(
1219 new FrameConnectedBluetoothDevices(render_frame_host_)); 1191 new FrameConnectedBluetoothDevices(render_frame_host_));
1220 device_chooser_controller_.reset(); 1192 device_chooser_controller_.reset();
1221 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); 1193 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this);
1222 } 1194 }
1223 1195
1224 } // namespace content 1196 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/bluetooth/bluetooth_metrics.cc ('k') | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698