| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDE
R_H_ | 5 #ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDE
R_H_ |
| 6 #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDE
R_H_ | 6 #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDE
R_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | |
| 10 #include <string> | 9 #include <string> |
| 11 #include <vector> | 10 #include <vector> |
| 12 | 11 |
| 12 #include "base/callback_forward.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "dbus/object_path.h" | 14 #include "dbus/object_path.h" |
| 15 #include "device/bluetooth/bluetooth_export.h" | 15 #include "device/bluetooth/bluetooth_export.h" |
| 16 #include "device/bluetooth/bluetooth_local_gatt_service.h" |
| 17 #include "device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.h" |
| 16 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.h
" | 18 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.h
" |
| 17 | 19 |
| 18 namespace bluez { | 20 namespace bluez { |
| 19 | 21 |
| 20 // FakeBluetoothGattCharacteristicServiceProvider simulates behavior of a local | 22 // FakeBluetoothGattCharacteristicServiceProvider simulates behavior of a local |
| 21 // GATT characteristic object and is used both in test cases in place of a mock | 23 // GATT characteristic object and is used both in test cases in place of a mock |
| 22 // and on the Linux desktop. | 24 // and on the Linux desktop. |
| 23 class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattCharacteristicServiceProvider | 25 class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattCharacteristicServiceProvider |
| 24 : public BluetoothGattCharacteristicServiceProvider { | 26 : public BluetoothGattCharacteristicServiceProvider { |
| 25 public: | 27 public: |
| 26 FakeBluetoothGattCharacteristicServiceProvider( | 28 FakeBluetoothGattCharacteristicServiceProvider( |
| 27 const dbus::ObjectPath& object_path, | 29 const dbus::ObjectPath& object_path, |
| 28 Delegate* delegate, | 30 std::unique_ptr<BluetoothGattAttributeValueDelegate> delegate, |
| 29 const std::string& uuid, | 31 const std::string& uuid, |
| 30 const std::vector<std::string>& flags, | 32 const std::vector<std::string>& flags, |
| 31 const std::vector<std::string>& permissions, | 33 const std::vector<std::string>& permissions, |
| 32 const dbus::ObjectPath& service_path); | 34 const dbus::ObjectPath& service_path); |
| 33 ~FakeBluetoothGattCharacteristicServiceProvider() override; | 35 ~FakeBluetoothGattCharacteristicServiceProvider() override; |
| 34 | 36 |
| 35 // BluetoothGattCharacteristicServiceProvider override. | 37 // BluetoothGattCharacteristicServiceProvider override. |
| 36 void SendValueChanged(const std::vector<uint8_t>& value) override; | 38 void SendValueChanged(const std::vector<uint8_t>& value) override; |
| 37 | 39 |
| 38 // Methods to simulate value get/set requests issued from a remote device. The | 40 // Methods to simulate value get/set requests issued from a remote device. The |
| 39 // methods do nothing, if the associated service was not registered with the | 41 // methods do nothing, if the associated service was not registered with the |
| 40 // GATT manager. | 42 // GATT manager. |
| 41 void GetValue(const Delegate::ValueCallback& callback, | 43 void GetValue( |
| 42 const Delegate::ErrorCallback& error_callback); | 44 const device::BluetoothLocalGattService::Delegate::ValueCallback& |
| 43 void SetValue(const std::vector<uint8_t>& value, | 45 callback, |
| 44 const base::Closure& callback, | 46 const device::BluetoothLocalGattService::Delegate::ErrorCallback& |
| 45 const Delegate::ErrorCallback& error_callback); | 47 error_callback); |
| 48 void SetValue( |
| 49 const std::vector<uint8_t>& value, |
| 50 const base::Closure& callback, |
| 51 const device::BluetoothLocalGattService::Delegate::ErrorCallback& |
| 52 error_callback); |
| 46 | 53 |
| 47 const dbus::ObjectPath& object_path() const { return object_path_; } | 54 const dbus::ObjectPath& object_path() const override; |
| 48 const std::string& uuid() const { return uuid_; } | 55 const std::string& uuid() const { return uuid_; } |
| 49 const dbus::ObjectPath& service_path() const { return service_path_; } | 56 const dbus::ObjectPath& service_path() const { return service_path_; } |
| 50 | 57 |
| 51 private: | 58 private: |
| 52 // D-Bus object path of the fake GATT characteristic. | 59 // D-Bus object path of the fake GATT characteristic. |
| 53 dbus::ObjectPath object_path_; | 60 dbus::ObjectPath object_path_; |
| 54 | 61 |
| 55 // 128-bit GATT characteristic UUID. | 62 // 128-bit GATT characteristic UUID. |
| 56 std::string uuid_; | 63 std::string uuid_; |
| 57 | 64 |
| 58 // Object path of the service that this characteristic belongs to. | 65 // Object path of the service that this characteristic belongs to. |
| 59 dbus::ObjectPath service_path_; | 66 dbus::ObjectPath service_path_; |
| 60 | 67 |
| 61 // The delegate that method calls are passed on to. | 68 // The delegate that method calls are passed on to. |
| 62 Delegate* delegate_; | 69 std::unique_ptr<BluetoothGattAttributeValueDelegate> delegate_; |
| 63 | 70 |
| 64 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattCharacteristicServiceProvider); | 71 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattCharacteristicServiceProvider); |
| 65 }; | 72 }; |
| 66 | 73 |
| 67 } // namespace bluez | 74 } // namespace bluez |
| 68 | 75 |
| 69 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROV
IDER_H_ | 76 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROV
IDER_H_ |
| OLD | NEW |