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

Unified Diff: device/bluetooth/device.cc

Issue 2640073004: bluetooth: Add descriptor list to DeviceDetailsPage on internals page. (Closed)
Patch Set: Fix merge issue of bluetooth_internals.css 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/device.h ('k') | device/bluetooth/public/interfaces/device.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/device.cc
diff --git a/device/bluetooth/device.cc b/device/bluetooth/device.cc
index 0e018a2ee93790e3cf15053fd2f93ede4befaa52..61eb1db771c644658e82881a86b14a81f0d7784b 100644
--- a/device/bluetooth/device.cc
+++ b/device/bluetooth/device.cc
@@ -123,6 +123,42 @@ void Device::GetCharacteristics(const std::string& service_id,
callback.Run(std::move(characteristics));
}
+void Device::GetDescriptors(const std::string& service_id,
+ const std::string& characteristic_id,
+ const GetDescriptorsCallback& callback) {
+ device::BluetoothDevice* device = adapter_->GetDevice(GetAddress());
+ if (!device) {
+ callback.Run(base::nullopt);
+ return;
+ }
+
+ device::BluetoothRemoteGattService* service =
+ device->GetGattService(service_id);
+ if (!service) {
+ callback.Run(base::nullopt);
+ return;
+ }
+
+ device::BluetoothRemoteGattCharacteristic* characteristic =
+ service->GetCharacteristic(characteristic_id);
+ if (!characteristic) {
+ callback.Run(base::nullopt);
+ return;
+ }
+
+ std::vector<mojom::DescriptorInfoPtr> descriptors;
+
+ for (const auto* descriptor : characteristic->GetDescriptors()) {
+ mojom::DescriptorInfoPtr descriptor_info = mojom::DescriptorInfo::New();
+
+ descriptor_info->id = descriptor->GetIdentifier();
+ descriptor_info->uuid = descriptor->GetUUID();
+ descriptors.push_back(std::move(descriptor_info));
+ }
+
+ callback.Run(std::move(descriptors));
+}
+
Device::Device(scoped_refptr<device::BluetoothAdapter> adapter,
std::unique_ptr<device::BluetoothGattConnection> connection)
: adapter_(std::move(adapter)), connection_(std::move(connection)) {
« no previous file with comments | « device/bluetooth/device.h ('k') | device/bluetooth/public/interfaces/device.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698