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

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

Issue 1914893002: DBus changes for implementing local GATT attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth_classes
Patch Set: test leak fix Created 4 years, 7 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_DESCRIPTOR_SERVICE_PROVIDER_H_ 5 #ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER_H_
6 #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER_H_ 6 #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER_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_descriptor_service_provider.h" 18 #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.h"
17 19
18 namespace bluez { 20 namespace bluez {
19 21
20 // FakeBluetoothGattDescriptorServiceProvider simulates behavior of a local 22 // FakeBluetoothGattDescriptorServiceProvider simulates behavior of a local
21 // GATT descriptor object and is used both in test cases in place of a mock 23 // GATT descriptor 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 FakeBluetoothGattDescriptorServiceProvider 25 class DEVICE_BLUETOOTH_EXPORT FakeBluetoothGattDescriptorServiceProvider
24 : public BluetoothGattDescriptorServiceProvider { 26 : public BluetoothGattDescriptorServiceProvider {
25 public: 27 public:
26 FakeBluetoothGattDescriptorServiceProvider( 28 FakeBluetoothGattDescriptorServiceProvider(
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>& permissions, 32 const std::vector<std::string>& permissions,
31 const dbus::ObjectPath& characteristic_path); 33 const dbus::ObjectPath& characteristic_path);
32 ~FakeBluetoothGattDescriptorServiceProvider() override; 34 ~FakeBluetoothGattDescriptorServiceProvider() override;
33 35
34 // BluetoothGattDescriptorServiceProvider override. 36 // BluetoothGattDescriptorServiceProvider override.
35 void SendValueChanged(const std::vector<uint8_t>& value) override; 37 void SendValueChanged(const std::vector<uint8_t>& value) override;
36 38
37 // Methods to simulate value get/set requests issued from a remote device. The 39 // Methods to simulate value get/set requests issued from a remote device. The
38 // methods do nothing, if the associated service was not registered with the 40 // methods do nothing, if the associated service was not registered with the
39 // GATT manager. 41 // GATT manager.
40 void GetValue(const Delegate::ValueCallback& callback, 42 void GetValue(
41 const Delegate::ErrorCallback& error_callback); 43 const device::BluetoothLocalGattService::Delegate::ValueCallback&
42 void SetValue(const std::vector<uint8_t>& value, 44 callback,
43 const base::Closure& callback, 45 const device::BluetoothLocalGattService::Delegate::ErrorCallback&
44 const Delegate::ErrorCallback& error_callback); 46 error_callback);
47 void SetValue(
48 const std::vector<uint8_t>& value,
49 const base::Closure& callback,
50 const device::BluetoothLocalGattService::Delegate::ErrorCallback&
51 error_callback);
45 52
46 const dbus::ObjectPath& object_path() const { return object_path_; } 53 const dbus::ObjectPath& object_path() const override;
47 const std::string& uuid() const { return uuid_; } 54 const std::string& uuid() const { return uuid_; }
48 const dbus::ObjectPath& characteristic_path() const { 55 const dbus::ObjectPath& characteristic_path() const {
49 return characteristic_path_; 56 return characteristic_path_;
50 } 57 }
51 58
52 private: 59 private:
53 // D-Bus object path of the fake GATT descriptor. 60 // D-Bus object path of the fake GATT descriptor.
54 dbus::ObjectPath object_path_; 61 dbus::ObjectPath object_path_;
55 62
56 // 128-bit GATT descriptor UUID. 63 // 128-bit GATT descriptor UUID.
57 std::string uuid_; 64 std::string uuid_;
58 65
59 // Object path of the characteristic that this descriptor belongs to. 66 // Object path of the characteristic that this descriptor belongs to.
60 dbus::ObjectPath characteristic_path_; 67 dbus::ObjectPath characteristic_path_;
61 68
62 // The delegate that method calls are passed on to. 69 // The delegate that method calls are passed on to.
63 Delegate* delegate_; 70 std::unique_ptr<BluetoothGattAttributeValueDelegate> delegate_;
64 71
65 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattDescriptorServiceProvider); 72 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattDescriptorServiceProvider);
66 }; 73 };
67 74
68 } // namespace bluez 75 } // namespace bluez
69 76
70 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER _H_ 77 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_DESCRIPTOR_SERVICE_PROVIDER _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698