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

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

Issue 2635473004: bluetooth: web: web_bluetooth.mojom comments and UUID type fix. (Closed)
Patch Set: bluetooth.mojom.UUID type used; Comments updated. 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
« no previous file with comments | « no previous file | third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.mojom » ('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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 std::string characteristic_instance_id = characteristic->GetIdentifier(); 484 std::string characteristic_instance_id = characteristic->GetIdentifier();
485 auto insert_result = characteristic_id_to_service_id_.insert( 485 auto insert_result = characteristic_id_to_service_id_.insert(
486 std::make_pair(characteristic_instance_id, service_instance_id)); 486 std::make_pair(characteristic_instance_id, service_instance_id));
487 // If value is already in map, DCHECK it's valid. 487 // If value is already in map, DCHECK it's valid.
488 if (!insert_result.second) 488 if (!insert_result.second)
489 DCHECK(insert_result.first->second == service_instance_id); 489 DCHECK(insert_result.first->second == service_instance_id);
490 490
491 blink::mojom::WebBluetoothRemoteGATTCharacteristicPtr characteristic_ptr = 491 blink::mojom::WebBluetoothRemoteGATTCharacteristicPtr characteristic_ptr =
492 blink::mojom::WebBluetoothRemoteGATTCharacteristic::New(); 492 blink::mojom::WebBluetoothRemoteGATTCharacteristic::New();
493 characteristic_ptr->instance_id = characteristic_instance_id; 493 characteristic_ptr->instance_id = characteristic_instance_id;
494 characteristic_ptr->uuid = characteristic->GetUUID().canonical_value(); 494 characteristic_ptr->uuid = characteristic->GetUUID();
495 characteristic_ptr->properties = 495 characteristic_ptr->properties =
496 static_cast<uint32_t>(characteristic->GetProperties()); 496 static_cast<uint32_t>(characteristic->GetProperties());
497 response_characteristics.push_back(std::move(characteristic_ptr)); 497 response_characteristics.push_back(std::move(characteristic_ptr));
498 498
499 if (quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE) { 499 if (quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE) {
500 break; 500 break;
501 } 501 }
502 } 502 }
503 503
504 if (!response_characteristics.empty()) { 504 if (!response_characteristics.empty()) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } 558 }
559 std::string descriptor_instance_id = descriptor->GetIdentifier(); 559 std::string descriptor_instance_id = descriptor->GetIdentifier();
560 auto insert_result = descriptor_id_to_characteristic_id_.insert( 560 auto insert_result = descriptor_id_to_characteristic_id_.insert(
561 {descriptor_instance_id, characteristic_instance_id}); 561 {descriptor_instance_id, characteristic_instance_id});
562 // If value is already in map, DCHECK it's valid. 562 // If value is already in map, DCHECK it's valid.
563 if (!insert_result.second) 563 if (!insert_result.second)
564 DCHECK(insert_result.first->second == characteristic_instance_id); 564 DCHECK(insert_result.first->second == characteristic_instance_id);
565 565
566 auto descriptor_ptr(blink::mojom::WebBluetoothRemoteGATTDescriptor::New()); 566 auto descriptor_ptr(blink::mojom::WebBluetoothRemoteGATTDescriptor::New());
567 descriptor_ptr->instance_id = descriptor_instance_id; 567 descriptor_ptr->instance_id = descriptor_instance_id;
568 descriptor_ptr->uuid = descriptor->GetUUID().canonical_value(); 568 descriptor_ptr->uuid = descriptor->GetUUID();
569 response_descriptors.push_back(std::move(descriptor_ptr)); 569 response_descriptors.push_back(std::move(descriptor_ptr));
570 570
571 if (quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE) { 571 if (quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE) {
572 break; 572 break;
573 } 573 }
574 } 574 }
575 575
576 if (!response_descriptors.empty()) { 576 if (!response_descriptors.empty()) {
577 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS, 577 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS,
578 std::move(response_descriptors)); 578 std::move(response_descriptors));
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 const std::string& device_address = device->GetAddress(); 782 const std::string& device_address = device->GetAddress();
783 auto insert_result = service_id_to_device_address_.insert( 783 auto insert_result = service_id_to_device_address_.insert(
784 make_pair(service_instance_id, device_address)); 784 make_pair(service_instance_id, device_address));
785 // If value is already in map, DCHECK it's valid. 785 // If value is already in map, DCHECK it's valid.
786 if (!insert_result.second) 786 if (!insert_result.second)
787 DCHECK_EQ(insert_result.first->second, device_address); 787 DCHECK_EQ(insert_result.first->second, device_address);
788 788
789 blink::mojom::WebBluetoothRemoteGATTServicePtr service_ptr = 789 blink::mojom::WebBluetoothRemoteGATTServicePtr service_ptr =
790 blink::mojom::WebBluetoothRemoteGATTService::New(); 790 blink::mojom::WebBluetoothRemoteGATTService::New();
791 service_ptr->instance_id = service_instance_id; 791 service_ptr->instance_id = service_instance_id;
792 service_ptr->uuid = service->GetUUID().canonical_value(); 792 service_ptr->uuid = service->GetUUID();
793 response_services.push_back(std::move(service_ptr)); 793 response_services.push_back(std::move(service_ptr));
794 794
795 if (quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE) { 795 if (quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE) {
796 break; 796 break;
797 } 797 }
798 } 798 }
799 799
800 if (!response_services.empty()) { 800 if (!response_services.empty()) {
801 DVLOG(1) << "Services found in device."; 801 DVLOG(1) << "Services found in device.";
802 RecordGetPrimaryServicesOutcome(quantity, 802 RecordGetPrimaryServicesOutcome(quantity,
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 characteristic_id_to_service_id_.clear(); 1045 characteristic_id_to_service_id_.clear();
1046 service_id_to_device_address_.clear(); 1046 service_id_to_device_address_.clear();
1047 connected_devices_.reset( 1047 connected_devices_.reset(
1048 new FrameConnectedBluetoothDevices(render_frame_host_)); 1048 new FrameConnectedBluetoothDevices(render_frame_host_));
1049 allowed_devices_map_ = BluetoothAllowedDevicesMap(); 1049 allowed_devices_map_ = BluetoothAllowedDevicesMap();
1050 device_chooser_controller_.reset(); 1050 device_chooser_controller_.reset();
1051 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); 1051 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this);
1052 } 1052 }
1053 1053
1054 } // namespace content 1054 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698