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

Unified Diff: device/bluetooth/bluetooth_device.cc

Issue 2615323002: Move some functions from web_bluetooth_service_impl.cc to BluetoothDevice class (Closed)
Patch Set: merge master 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/bluetooth_device.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_device.cc
diff --git a/device/bluetooth/bluetooth_device.cc b/device/bluetooth/bluetooth_device.cc
index 7c56c127884732fcc129b68a325a909840570e18..81f7d7797891cca50cdfd4ad07e0483de5953831 100644
--- a/device/bluetooth/bluetooth_device.cc
+++ b/device/bluetooth/bluetooth_device.cc
@@ -15,6 +15,7 @@
#include "base/values.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_gatt_connection.h"
+#include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
#include "device/bluetooth/bluetooth_remote_gatt_service.h"
#include "device/bluetooth/string_util_icu.h"
#include "grit/bluetooth_strings.h"
@@ -449,6 +450,52 @@ void BluetoothDevice::ClearAdvertisementData() {
GetAdapter()->NotifyDeviceChanged(this);
}
+std::vector<BluetoothRemoteGattService*> BluetoothDevice::GetPrimaryServices() {
+ std::vector<BluetoothRemoteGattService*> services;
+ VLOG(2) << "Looking for services.";
+ for (BluetoothRemoteGattService* service : GetGattServices()) {
+ VLOG(2) << "Service in cache: " << service->GetUUID().canonical_value();
+ if (service->IsPrimary()) {
+ services.push_back(service);
+ }
+ }
+ return services;
+}
+
+std::vector<BluetoothRemoteGattService*>
+BluetoothDevice::GetPrimaryServicesByUUID(const BluetoothUUID& service_uuid) {
+ std::vector<BluetoothRemoteGattService*> services;
+ VLOG(2) << "Looking for service: " << service_uuid.canonical_value();
+ for (BluetoothRemoteGattService* service : GetGattServices()) {
+ VLOG(2) << "Service in cache: " << service->GetUUID().canonical_value();
+ if (service->GetUUID() == service_uuid && service->IsPrimary()) {
+ services.push_back(service);
+ }
+ }
+ return services;
+}
+
+std::vector<BluetoothRemoteGattCharacteristic*>
+BluetoothDevice::GetCharacteristicsByUUID(
+ const std::string& service_instance_id,
+ const BluetoothUUID& characteristic_uuid) {
+ std::vector<BluetoothRemoteGattCharacteristic*> characteristics;
+ VLOG(2) << "Looking for characteristic: "
+ << characteristic_uuid.canonical_value();
+ BluetoothRemoteGattService* service = GetGattService(service_instance_id);
+ if (service) {
+ for (BluetoothRemoteGattCharacteristic* characteristic :
+ service->GetCharacteristics()) {
+ VLOG(2) << "Characteristic in cache: "
+ << characteristic->GetUUID().canonical_value();
+ if (characteristic->GetUUID() == characteristic_uuid) {
+ characteristics.push_back(characteristic);
+ }
+ }
+ }
+ return characteristics;
+}
+
void BluetoothDevice::DidConnectGatt() {
for (const auto& callback : create_gatt_connection_success_callbacks_) {
callback.Run(
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698