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

Side by Side Diff: device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.h

Issue 1920693002: Complete //device/bt implementation for hosting local GATT attributes. (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 unified diff | Download patch
OLDNEW
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_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<BluetoothGattServiceBlueZ::AttributeValueDelegate>
31 delegate,
29 const std::string& uuid, 32 const std::string& uuid,
30 const std::vector<std::string>& flags, 33 const std::vector<std::string>& flags,
31 const std::vector<std::string>& permissions, 34 const std::vector<std::string>& permissions,
32 const dbus::ObjectPath& service_path); 35 const dbus::ObjectPath& service_path);
33 ~FakeBluetoothGattCharacteristicServiceProvider() override; 36 ~FakeBluetoothGattCharacteristicServiceProvider() override;
34 37
35 // BluetoothGattCharacteristicServiceProvider override. 38 // BluetoothGattCharacteristicServiceProvider override.
36 void SendValueChanged(const std::vector<uint8_t>& value) override; 39 void SendValueChanged(const std::vector<uint8_t>& value) override;
37 40
38 // Methods to simulate value get/set requests issued from a remote device. The 41 // 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 42 // methods do nothing, if the associated service was not registered with the
40 // GATT manager. 43 // GATT manager.
41 void GetValue(const Delegate::ValueCallback& callback, 44 void GetValue(
42 const Delegate::ErrorCallback& error_callback); 45 const device::BluetoothLocalGattService::Delegate::ValueCallback&
43 void SetValue(const std::vector<uint8_t>& value, 46 callback,
44 const base::Closure& callback, 47 const device::BluetoothLocalGattService::Delegate::ErrorCallback&
45 const Delegate::ErrorCallback& error_callback); 48 error_callback);
49 void SetValue(
50 const std::vector<uint8_t>& value,
51 const base::Closure& callback,
52 const device::BluetoothLocalGattService::Delegate::ErrorCallback&
53 error_callback);
46 54
47 const dbus::ObjectPath& object_path() const { return object_path_; } 55 const dbus::ObjectPath& object_path() const override;
48 const std::string& uuid() const { return uuid_; } 56 const std::string& uuid() const { return uuid_; }
49 const dbus::ObjectPath& service_path() const { return service_path_; } 57 const dbus::ObjectPath& service_path() const { return service_path_; }
50 58
51 private: 59 private:
52 // D-Bus object path of the fake GATT characteristic. 60 // D-Bus object path of the fake GATT characteristic.
53 dbus::ObjectPath object_path_; 61 dbus::ObjectPath object_path_;
54 62
55 // 128-bit GATT characteristic UUID. 63 // 128-bit GATT characteristic UUID.
56 std::string uuid_; 64 std::string uuid_;
57 65
58 // Object path of the service that this characteristic belongs to. 66 // Object path of the service that this characteristic belongs to.
59 dbus::ObjectPath service_path_; 67 dbus::ObjectPath service_path_;
60 68
61 // The delegate that method calls are passed on to. 69 // The delegate that method calls are passed on to.
62 Delegate* delegate_; 70 std::unique_ptr<BluetoothGattServiceBlueZ::AttributeValueDelegate> delegate_;
63 71
64 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattCharacteristicServiceProvider); 72 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattCharacteristicServiceProvider);
65 }; 73 };
66 74
67 } // namespace bluez 75 } // namespace bluez
68 76
69 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROV IDER_H_ 77 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROV IDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698