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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « device/bluetooth/device.h ('k') | device/bluetooth/public/interfaces/device.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 #include <utility> 5 #include <utility>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "device/bluetooth/device.h" 10 #include "device/bluetooth/device.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 characteristic_info->id = characteristic->GetIdentifier(); 116 characteristic_info->id = characteristic->GetIdentifier();
117 characteristic_info->uuid = characteristic->GetUUID(); 117 characteristic_info->uuid = characteristic->GetUUID();
118 characteristic_info->properties = characteristic->GetProperties(); 118 characteristic_info->properties = characteristic->GetProperties();
119 119
120 characteristics.push_back(std::move(characteristic_info)); 120 characteristics.push_back(std::move(characteristic_info));
121 } 121 }
122 122
123 callback.Run(std::move(characteristics)); 123 callback.Run(std::move(characteristics));
124 } 124 }
125 125
126 void Device::GetDescriptors(const std::string& service_id,
127 const std::string& characteristic_id,
128 const GetDescriptorsCallback& callback) {
129 device::BluetoothDevice* device = adapter_->GetDevice(GetAddress());
130 if (!device) {
131 callback.Run(base::nullopt);
132 return;
133 }
134
135 device::BluetoothRemoteGattService* service =
136 device->GetGattService(service_id);
137 if (!service) {
138 callback.Run(base::nullopt);
139 return;
140 }
141
142 device::BluetoothRemoteGattCharacteristic* characteristic =
143 service->GetCharacteristic(characteristic_id);
144 if (!characteristic) {
145 callback.Run(base::nullopt);
146 return;
147 }
148
149 std::vector<mojom::DescriptorInfoPtr> descriptors;
150
151 for (const auto* descriptor : characteristic->GetDescriptors()) {
152 mojom::DescriptorInfoPtr descriptor_info = mojom::DescriptorInfo::New();
153
154 descriptor_info->id = descriptor->GetIdentifier();
155 descriptor_info->uuid = descriptor->GetUUID();
156 descriptors.push_back(std::move(descriptor_info));
157 }
158
159 callback.Run(std::move(descriptors));
160 }
161
126 Device::Device(scoped_refptr<device::BluetoothAdapter> adapter, 162 Device::Device(scoped_refptr<device::BluetoothAdapter> adapter,
127 std::unique_ptr<device::BluetoothGattConnection> connection) 163 std::unique_ptr<device::BluetoothGattConnection> connection)
128 : adapter_(std::move(adapter)), connection_(std::move(connection)) { 164 : adapter_(std::move(adapter)), connection_(std::move(connection)) {
129 adapter_->AddObserver(this); 165 adapter_->AddObserver(this);
130 } 166 }
131 167
132 void Device::GetServicesImpl(const GetServicesCallback& callback) { 168 void Device::GetServicesImpl(const GetServicesCallback& callback) {
133 device::BluetoothDevice* device = adapter_->GetDevice(GetAddress()); 169 device::BluetoothDevice* device = adapter_->GetDevice(GetAddress());
134 DCHECK(device); 170 DCHECK(device);
135 171
(...skipping 16 matching lines...) Expand all
152 service_info->is_primary = service.IsPrimary(); 188 service_info->is_primary = service.IsPrimary();
153 189
154 return service_info; 190 return service_info;
155 } 191 }
156 192
157 const std::string& Device::GetAddress() { 193 const std::string& Device::GetAddress() {
158 return connection_->GetDeviceAddress(); 194 return connection_->GetDeviceAddress();
159 } 195 }
160 196
161 } // namespace bluetooth 197 } // namespace bluetooth
OLDNEW
« 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