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

Unified Diff: device/bluetooth/bluez/bluetooth_remote_gatt_service_bluez.h

Issue 1898643002: Refactor device::BluetoothGattXXX classes to split into remote/local. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/bluez/bluetooth_remote_gatt_service_bluez.h
diff --git a/device/bluetooth/bluetooth_remote_gatt_service_bluez.h b/device/bluetooth/bluez/bluetooth_remote_gatt_service_bluez.h
similarity index 69%
rename from device/bluetooth/bluetooth_remote_gatt_service_bluez.h
rename to device/bluetooth/bluez/bluetooth_remote_gatt_service_bluez.h
index 9be0eef949555c94185c50d24fd4cb7fb372763f..46192a794da576c8a0128af55ae63fd842cfb198 100644
--- a/device/bluetooth/bluetooth_remote_gatt_service_bluez.h
+++ b/device/bluetooth/bluez/bluetooth_remote_gatt_service_bluez.h
@@ -1,20 +1,21 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
+// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_
-#define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_
+#ifndef DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_
+#define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_
#include <stdint.h>
+#include <map>
#include <string>
#include <vector>
-#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "dbus/object_path.h"
-#include "device/bluetooth/bluetooth_gatt_service_bluez.h"
+#include "device/bluetooth/bluetooth_remote_gatt_service.h"
#include "device/bluetooth/bluetooth_uuid.h"
+#include "device/bluetooth/bluez/bluetooth_gatt_service_bluez.h"
#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h"
#include "device/bluetooth/dbus/bluetooth_gatt_service_client.h"
@@ -22,7 +23,7 @@ namespace device {
class BluetoothAdapter;
class BluetoothDevice;
-class BluetoothGattCharacteristic;
+class BluetoothRemoteGattCharacteristic;
} // namespace device
@@ -31,27 +32,26 @@ namespace bluez {
class BluetoothAdapterBlueZ;
class BluetoothDeviceBlueZ;
class BluetoothRemoteGattCharacteristicBlueZ;
-class BluetoothGattDescriptorBlueZ;
+class BluetoothRemoteGattDescriptorBlueZ;
// The BluetoothRemoteGattServiceBlueZ class implements BluetootGattService
// for remote GATT services for platforms that use BlueZ.
class BluetoothRemoteGattServiceBlueZ
: public BluetoothGattServiceBlueZ,
public BluetoothGattServiceClient::Observer,
- public BluetoothGattCharacteristicClient::Observer {
+ public BluetoothGattCharacteristicClient::Observer,
+ public device::BluetoothRemoteGattService {
public:
- // device::BluetoothGattService overrides.
+ // device::BluetoothRemoteGattService overrides.
device::BluetoothUUID GetUUID() const override;
- bool IsLocal() const override;
- bool IsPrimary() const override;
device::BluetoothDevice* GetDevice() const override;
- bool AddCharacteristic(
- device::BluetoothGattCharacteristic* characteristic) override;
- bool AddIncludedService(device::BluetoothGattService* service) override;
- void Register(const base::Closure& callback,
- const ErrorCallback& error_callback) override;
- void Unregister(const base::Closure& callback,
- const ErrorCallback& error_callback) override;
+ bool IsPrimary() const override;
+ std::vector<device::BluetoothRemoteGattCharacteristic*> GetCharacteristics()
+ const override;
+ std::vector<device::BluetoothRemoteGattService*> GetIncludedServices()
+ const override;
+ device::BluetoothRemoteGattCharacteristic* GetCharacteristic(
+ const std::string& identifier) const override;
// Notifies its observers that the GATT service has changed. This is mainly
// used by BluetoothRemoteGattCharacteristicBlueZ instances to notify
@@ -66,7 +66,7 @@ class BluetoothRemoteGattServiceBlueZ
// be sent.
void NotifyDescriptorAddedOrRemoved(
BluetoothRemoteGattCharacteristicBlueZ* characteristic,
- BluetoothGattDescriptorBlueZ* descriptor,
+ BluetoothRemoteGattDescriptorBlueZ* descriptor,
bool added);
// Notifies its observers that the value of a descriptor has changed. Called
@@ -74,7 +74,7 @@ class BluetoothRemoteGattServiceBlueZ
// observers.
void NotifyDescriptorValueChanged(
BluetoothRemoteGattCharacteristicBlueZ* characteristic,
- BluetoothGattDescriptorBlueZ* descriptor,
+ BluetoothRemoteGattDescriptorBlueZ* descriptor,
const std::vector<uint8_t>& value);
private:
@@ -100,6 +100,17 @@ class BluetoothRemoteGattServiceBlueZ
// here since |device_| owns this instance.
BluetoothDeviceBlueZ* device_;
+ // TODO(rkc): Investigate and fix ownership of the characteristic objects in
+ // this map. See crbug.com/604166.
+ using CharacteristicMap =
+ std::map<dbus::ObjectPath, BluetoothRemoteGattCharacteristicBlueZ*>;
+
+ // Mapping from GATT characteristic object paths to characteristic objects.
+ // owned by this service. Since the BlueZ implementation uses object
+ // paths as unique identifiers, we also use this mapping to return
+ // characteristics by identifier.
+ CharacteristicMap characteristics_;
+
// Indicates whether or not the characteristics of this service are known to
// have been discovered.
bool discovery_complete_;
@@ -113,4 +124,4 @@ class BluetoothRemoteGattServiceBlueZ
} // namespace bluez
-#endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_
+#endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_

Powered by Google App Engine
This is Rietveld 408576698