| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_IMP
L_H_ | 5 #ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_IMP
L_H_ |
| 6 #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_IMP
L_H_ | 6 #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_IMP
L_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // production. | 26 // production. |
| 27 class DEVICE_BLUETOOTH_EXPORT BluetoothGattCharacteristicServiceProviderImpl | 27 class DEVICE_BLUETOOTH_EXPORT BluetoothGattCharacteristicServiceProviderImpl |
| 28 : public BluetoothGattCharacteristicServiceProvider { | 28 : public BluetoothGattCharacteristicServiceProvider { |
| 29 public: | 29 public: |
| 30 BluetoothGattCharacteristicServiceProviderImpl( | 30 BluetoothGattCharacteristicServiceProviderImpl( |
| 31 dbus::Bus* bus, | 31 dbus::Bus* bus, |
| 32 const dbus::ObjectPath& object_path, | 32 const dbus::ObjectPath& object_path, |
| 33 std::unique_ptr<BluetoothGattAttributeValueDelegate> delegate, | 33 std::unique_ptr<BluetoothGattAttributeValueDelegate> delegate, |
| 34 const std::string& uuid, | 34 const std::string& uuid, |
| 35 const std::vector<std::string>& flags, | 35 const std::vector<std::string>& flags, |
| 36 const std::vector<std::string>& permissions, | |
| 37 const dbus::ObjectPath& service_path); | 36 const dbus::ObjectPath& service_path); |
| 38 | 37 |
| 39 ~BluetoothGattCharacteristicServiceProviderImpl() override; | 38 ~BluetoothGattCharacteristicServiceProviderImpl() override; |
| 40 | 39 |
| 41 // For testing. | |
| 42 BluetoothGattCharacteristicServiceProviderImpl( | |
| 43 const dbus::ObjectPath& object_path, | |
| 44 const std::string& uuid, | |
| 45 const dbus::ObjectPath& service_path); | |
| 46 | |
| 47 // BluetoothGattCharacteristicServiceProvider override. | 40 // BluetoothGattCharacteristicServiceProvider override. |
| 48 void SendValueChanged(const std::vector<uint8_t>& value) override; | 41 void SendValueChanged(const std::vector<uint8_t>& value) override; |
| 49 | 42 |
| 50 private: | 43 private: |
| 51 // Returns true if the current thread is on the origin thread. | 44 // Returns true if the current thread is on the origin thread. |
| 52 bool OnOriginThread(); | 45 bool OnOriginThread(); |
| 53 | 46 |
| 54 // Called by dbus:: when the Bluetooth daemon fetches a single property of | 47 // Called by dbus:: when the Bluetooth daemon fetches a single property of |
| 55 // the characteristic. | 48 // the characteristic. |
| 56 void Get(dbus::MethodCall* method_call, | 49 void Get(dbus::MethodCall* method_call, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 dbus::ExportedObject::ResponseSender response_sender); | 92 dbus::ExportedObject::ResponseSender response_sender); |
| 100 | 93 |
| 101 const dbus::ObjectPath& object_path() const override; | 94 const dbus::ObjectPath& object_path() const override; |
| 102 | 95 |
| 103 // Origin thread (i.e. the UI thread in production). | 96 // Origin thread (i.e. the UI thread in production). |
| 104 base::PlatformThreadId origin_thread_id_; | 97 base::PlatformThreadId origin_thread_id_; |
| 105 | 98 |
| 106 // 128-bit characteristic UUID of this object. | 99 // 128-bit characteristic UUID of this object. |
| 107 std::string uuid_; | 100 std::string uuid_; |
| 108 | 101 |
| 102 // Properties and permissions for this characteristic. |
| 103 std::vector<std::string> flags_; |
| 104 |
| 109 // D-Bus bus object is exported on, not owned by this object and must | 105 // D-Bus bus object is exported on, not owned by this object and must |
| 110 // outlive it. | 106 // outlive it. |
| 111 dbus::Bus* bus_; | 107 dbus::Bus* bus_; |
| 112 | 108 |
| 113 // Incoming methods to get and set the "Value" property are passed on to the | 109 // Incoming methods to get and set the "Value" property are passed on to the |
| 114 // delegate and callbacks passed to generate a reply. |delegate_| is generally | 110 // delegate and callbacks passed to generate a reply. |delegate_| is generally |
| 115 // the object that owns this one and must outlive it. | 111 // the object that owns this one and must outlive it. |
| 116 std::unique_ptr<BluetoothGattAttributeValueDelegate> delegate_; | 112 std::unique_ptr<BluetoothGattAttributeValueDelegate> delegate_; |
| 117 | 113 |
| 118 // D-Bus object path of object we are exporting, kept so we can unregister | 114 // D-Bus object path of object we are exporting, kept so we can unregister |
| (...skipping 13 matching lines...) Expand all Loading... |
| 132 // invalidate its weak pointers before any other members are destroyed. | 128 // invalidate its weak pointers before any other members are destroyed. |
| 133 base::WeakPtrFactory<BluetoothGattCharacteristicServiceProviderImpl> | 129 base::WeakPtrFactory<BluetoothGattCharacteristicServiceProviderImpl> |
| 134 weak_ptr_factory_; | 130 weak_ptr_factory_; |
| 135 | 131 |
| 136 DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristicServiceProviderImpl); | 132 DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristicServiceProviderImpl); |
| 137 }; | 133 }; |
| 138 | 134 |
| 139 } // namespace bluez | 135 } // namespace bluez |
| 140 | 136 |
| 141 #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_
IMPL_H_ | 137 #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_SERVICE_PROVIDER_
IMPL_H_ |
| OLD | NEW |