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

Unified Diff: device/bluetooth/device.cc

Issue 2640073004: bluetooth: Add descriptor list to DeviceDetailsPage on internals page. (Closed)
Patch Set: Add comment to differentiate descriptor return value 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
Index: device/bluetooth/device.cc
diff --git a/device/bluetooth/device.cc b/device/bluetooth/device.cc
index ca1e6149dbf2370efbbb3caea1dd7d202d18fb56..cb261980c151856dde070b902490ef88bd4155e9 100644
--- a/device/bluetooth/device.cc
+++ b/device/bluetooth/device.cc
@@ -112,6 +112,42 @@ void Device::GetCharacteristics(const std::string& service_id,
service_id, callback));
}
+void Device::GetDescriptors(const std::string& service_id,
+ const std::string& characteristic_id,
+ const GetDescriptorsCallback& callback) {
+ device::BluetoothDevice* device = adapter_->GetDevice(GetAddress());
+ if (device == nullptr) {
Dan Beam 2017/01/24 06:07:29 is this preferable to just if (!device) { ?
mbrunson 2017/01/24 21:29:46 I've seen it both ways, but the other files here u
+ callback.Run(base::nullopt);
+ return;
+ }
+
+ device::BluetoothRemoteGattService* service =
+ device->GetGattService(service_id);
+ if (service == nullptr) {
+ callback.Run(base::nullopt);
+ return;
+ }
+
+ device::BluetoothRemoteGattCharacteristic* characteristic =
+ service->GetCharacteristic(characteristic_id);
+ if (characteristic == nullptr) {
+ 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)) {

Powered by Google App Engine
This is Rietveld 408576698