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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_service.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/bluetooth_remote_gatt_service.h
diff --git a/device/bluetooth/bluetooth_gatt_service_bluez.h b/device/bluetooth/bluetooth_remote_gatt_service.h
similarity index 13%
copy from device/bluetooth/bluetooth_gatt_service_bluez.h
copy to device/bluetooth/bluetooth_remote_gatt_service.h
index bdd03f0e0bd0336bf68d08acd396281ff5d901a4..e531fcdfdc49743e578c8cd97821b4e1348f005f 100644
--- a/device/bluetooth/bluetooth_gatt_service_bluez.h
+++ b/device/bluetooth/bluetooth_remote_gatt_service.h
@@ -2,80 +2,63 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_BLUEZ_H_
-#define DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_BLUEZ_H_
+#ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_H_
+#define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_H_
-#include <map>
#include <string>
#include <vector>
#include "base/macros.h"
-#include "dbus/object_path.h"
+#include "device/bluetooth/bluetooth_export.h"
#include "device/bluetooth/bluetooth_gatt_service.h"
+#include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
namespace device {
-class BluetoothGattCharacteristic;
-
-} // namespace device
-
-namespace bluez {
-
-class BluetoothAdapterBlueZ;
-class BluetoothDeviceBlueZ;
-class BluetoothGattCharacteristicBlueZ;
-
-// The BluetoothGattServiceBlueZ class implements BluetootGattService
-// for GATT services on platforms that use BlueZ.
-class BluetoothGattServiceBlueZ : public device::BluetoothGattService {
+class BluetoothDevice;
+class BluetoothRemoteGattCharacteristic;
+class BluetoothRemoteGattDescriptor;
+
+// BluetoothRemoteGattService represents a remote GATT service.
+//
+// Instances of the BluetoothRemoteGATTService class are used to represent GATT
+// attribute hierarchies that have been received from a
+// remote Bluetooth GATT peripheral. Such BluetoothRemoteGattService instances
+// are constructed and owned by a BluetoothDevice.
+//
+// Note: We use virtual inheritance on the GATT service since it will be
+// inherited by platform specific versions of the GATT service classes also. The
+// platform specific remote GATT service classes will inherit both this class
+// and their GATT service class, hence causing an inheritance diamond.
+class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattService
+ : public virtual BluetoothGattService {
public:
- // device::BluetoothGattService overrides.
- std::string GetIdentifier() const override;
- std::vector<device::BluetoothGattCharacteristic*> GetCharacteristics()
- const override;
- std::vector<device::BluetoothGattService*> GetIncludedServices()
- const override;
- device::BluetoothGattCharacteristic* GetCharacteristic(
- const std::string& identifier) const override;
-
- // Object path of the underlying service.
- const dbus::ObjectPath& object_path() const { return object_path_; }
+ ~BluetoothRemoteGattService() override;
- // Parses a named D-Bus error into a service error code.
- static device::BluetoothGattService::GattErrorCode DBusErrorToServiceError(
- const std::string error_name);
+ // Returns the BluetoothDevice that this GATT service was received from, which
+ // also owns this service.
+ virtual BluetoothDevice* GetDevice() const = 0;
- // Returns the adapter associated with this service.
- BluetoothAdapterBlueZ* GetAdapter() const;
+ // List of characteristics that belong to this service.
+ virtual std::vector<BluetoothRemoteGattCharacteristic*> GetCharacteristics()
+ const = 0;
- protected:
- BluetoothGattServiceBlueZ(BluetoothAdapterBlueZ* adapter,
- const dbus::ObjectPath& object_path);
- ~BluetoothGattServiceBlueZ() override;
+ // List of GATT services that are included by this service.
+ virtual std::vector<BluetoothRemoteGattService*> GetIncludedServices()
+ const = 0;
- // Does not take ownership of the characteristic object.
- using CharacteristicMap =
- std::map<dbus::ObjectPath, BluetoothGattCharacteristicBlueZ*>;
+ // Returns the GATT characteristic with identifier |identifier| if it belongs
+ // to this GATT service.
+ virtual BluetoothRemoteGattCharacteristic* GetCharacteristic(
+ const std::string& identifier) const = 0;
- // 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_;
+ protected:
+ BluetoothRemoteGattService();
private:
- friend class BluetoothDeviceBlueZ;
-
- // The adapter associated with this service. It's ok to store a raw pointer
- // here since |adapter_| indirectly owns this instance.
- BluetoothAdapterBlueZ* adapter_;
-
- // Object path of the GATT service.
- dbus::ObjectPath object_path_;
-
- DISALLOW_COPY_AND_ASSIGN(BluetoothGattServiceBlueZ);
+ DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattService);
};
-} // namespace bluez
+} // namespace device
-#endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_BLUEZ_H_
+#endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_H_
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_descriptor_win.cc ('k') | device/bluetooth/bluetooth_remote_gatt_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698