| 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_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_CHROMEOS_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_CHROMEOS_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_CHROMEOS_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" | |
| 16 #include "chromeos/dbus/bluetooth_gatt_descriptor_client.h" | 15 #include "chromeos/dbus/bluetooth_gatt_descriptor_client.h" |
| 17 #include "dbus/object_path.h" | 16 #include "dbus/object_path.h" |
| 18 #include "device/bluetooth/bluetooth_gatt_characteristic.h" | 17 #include "device/bluetooth/bluetooth_gatt_characteristic.h" |
| 19 #include "device/bluetooth/bluetooth_uuid.h" | 18 #include "device/bluetooth/bluetooth_uuid.h" |
| 20 | 19 |
| 21 namespace device { | 20 namespace device { |
| 22 | 21 |
| 23 class BluetoothGattDescriptor; | 22 class BluetoothGattDescriptor; |
| 24 class BluetoothGattService; | 23 class BluetoothGattService; |
| 25 | 24 |
| 26 } // namespace device | 25 } // namespace device |
| 27 | 26 |
| 28 namespace chromeos { | 27 namespace chromeos { |
| 29 | 28 |
| 30 class BluetoothRemoteGattDescriptorChromeOS; | 29 class BluetoothRemoteGattDescriptorChromeOS; |
| 31 class BluetoothRemoteGattServiceChromeOS; | 30 class BluetoothRemoteGattServiceChromeOS; |
| 32 | 31 |
| 33 // The BluetoothRemoteGattCharacteristicChromeOS class implements | 32 // The BluetoothRemoteGattCharacteristicChromeOS class implements |
| 34 // BluetoothGattCharacteristic for remote GATT characteristics on the Chrome OS | 33 // BluetoothGattCharacteristic for remote GATT characteristics on the Chrome OS |
| 35 // platform. | 34 // platform. |
| 36 class BluetoothRemoteGattCharacteristicChromeOS | 35 class BluetoothRemoteGattCharacteristicChromeOS |
| 37 : public device::BluetoothGattCharacteristic, | 36 : public device::BluetoothGattCharacteristic, |
| 38 public BluetoothGattCharacteristicClient::Observer, | |
| 39 public BluetoothGattDescriptorClient::Observer { | 37 public BluetoothGattDescriptorClient::Observer { |
| 40 public: | 38 public: |
| 41 // device::BluetoothGattCharacteristic overrides. | 39 // device::BluetoothGattCharacteristic overrides. |
| 42 virtual std::string GetIdentifier() const override; | 40 virtual std::string GetIdentifier() const override; |
| 43 virtual device::BluetoothUUID GetUUID() const override; | 41 virtual device::BluetoothUUID GetUUID() const override; |
| 44 virtual bool IsLocal() const override; | 42 virtual bool IsLocal() const override; |
| 45 virtual const std::vector<uint8>& GetValue() const override; | 43 virtual const std::vector<uint8>& GetValue() const override; |
| 46 virtual device::BluetoothGattService* GetService() const override; | 44 virtual device::BluetoothGattService* GetService() const override; |
| 47 virtual Properties GetProperties() const override; | 45 virtual Properties GetProperties() const override; |
| 48 virtual Permissions GetPermissions() const override; | 46 virtual Permissions GetPermissions() const override; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 74 const dbus::ObjectPath& object_path() const { return object_path_; } | 72 const dbus::ObjectPath& object_path() const { return object_path_; } |
| 75 | 73 |
| 76 private: | 74 private: |
| 77 friend class BluetoothRemoteGattServiceChromeOS; | 75 friend class BluetoothRemoteGattServiceChromeOS; |
| 78 | 76 |
| 79 BluetoothRemoteGattCharacteristicChromeOS( | 77 BluetoothRemoteGattCharacteristicChromeOS( |
| 80 BluetoothRemoteGattServiceChromeOS* service, | 78 BluetoothRemoteGattServiceChromeOS* service, |
| 81 const dbus::ObjectPath& object_path); | 79 const dbus::ObjectPath& object_path); |
| 82 virtual ~BluetoothRemoteGattCharacteristicChromeOS(); | 80 virtual ~BluetoothRemoteGattCharacteristicChromeOS(); |
| 83 | 81 |
| 84 // BluetoothGattCharacteristicClient::Observer overrides. | |
| 85 virtual void GattCharacteristicValueUpdated( | |
| 86 const dbus::ObjectPath& object_path, | |
| 87 const std::vector<uint8>& value) override; | |
| 88 | |
| 89 // BluetoothGattDescriptorClient::Observer overrides. | 82 // BluetoothGattDescriptorClient::Observer overrides. |
| 90 virtual void GattDescriptorAdded( | 83 virtual void GattDescriptorAdded( |
| 91 const dbus::ObjectPath& object_path) override; | 84 const dbus::ObjectPath& object_path) override; |
| 92 virtual void GattDescriptorRemoved( | 85 virtual void GattDescriptorRemoved( |
| 93 const dbus::ObjectPath& object_path) override; | 86 const dbus::ObjectPath& object_path) override; |
| 94 | 87 virtual void GattDescriptorPropertyChanged( |
| 95 // Called by dbus:: on successful completion of a request to read | 88 const dbus::ObjectPath& object_path, |
| 96 // the characteristic value. | 89 const std::string& property_name) override; |
| 97 void OnValueSuccess(const ValueCallback& callback, | |
| 98 const std::vector<uint8>& value); | |
| 99 | 90 |
| 100 // Called by dbus:: on unsuccessful completion of a request to read or write | 91 // Called by dbus:: on unsuccessful completion of a request to read or write |
| 101 // the characteristic value. | 92 // the characteristic value. |
| 102 void OnError(const ErrorCallback& error_callback, | 93 void OnError(const ErrorCallback& error_callback, |
| 103 const std::string& error_name, | 94 const std::string& error_name, |
| 104 const std::string& error_message); | 95 const std::string& error_message); |
| 105 | 96 |
| 106 // Called by dbus:: on successful completion of a request to start | 97 // Called by dbus:: on successful completion of a request to start |
| 107 // notifications. | 98 // notifications. |
| 108 void OnStartNotifySuccess(const NotifySessionCallback& callback); | 99 void OnStartNotifySuccess(const NotifySessionCallback& callback); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 125 | 116 |
| 126 // Calls StartNotifySession for each queued request. | 117 // Calls StartNotifySession for each queued request. |
| 127 void ProcessStartNotifyQueue(); | 118 void ProcessStartNotifyQueue(); |
| 128 | 119 |
| 129 // Object path of the D-Bus characteristic object. | 120 // Object path of the D-Bus characteristic object. |
| 130 dbus::ObjectPath object_path_; | 121 dbus::ObjectPath object_path_; |
| 131 | 122 |
| 132 // The GATT service this GATT characteristic belongs to. | 123 // The GATT service this GATT characteristic belongs to. |
| 133 BluetoothRemoteGattServiceChromeOS* service_; | 124 BluetoothRemoteGattServiceChromeOS* service_; |
| 134 | 125 |
| 135 // The cached characteristic value based on the most recent read or | |
| 136 // notification. | |
| 137 std::vector<uint8> cached_value_; | |
| 138 | |
| 139 // The total number of currently active value update sessions. | 126 // The total number of currently active value update sessions. |
| 140 size_t num_notify_sessions_; | 127 size_t num_notify_sessions_; |
| 141 | 128 |
| 142 // Calls to StartNotifySession that are pending. This can happen during the | 129 // Calls to StartNotifySession that are pending. This can happen during the |
| 143 // first remote call to start notifications. | 130 // first remote call to start notifications. |
| 144 typedef std::pair<NotifySessionCallback, ErrorCallback> | 131 typedef std::pair<NotifySessionCallback, ErrorCallback> |
| 145 PendingStartNotifyCall; | 132 PendingStartNotifyCall; |
| 146 std::queue<PendingStartNotifyCall> pending_start_notify_calls_; | 133 std::queue<PendingStartNotifyCall> pending_start_notify_calls_; |
| 147 | 134 |
| 148 // True, if a Start or Stop notify call to bluetoothd is currently pending. | 135 // True, if a Start or Stop notify call to bluetoothd is currently pending. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 160 // invalidate its weak pointers before any other members are destroyed. | 147 // invalidate its weak pointers before any other members are destroyed. |
| 161 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicChromeOS> | 148 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicChromeOS> |
| 162 weak_ptr_factory_; | 149 weak_ptr_factory_; |
| 163 | 150 |
| 164 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicChromeOS); | 151 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicChromeOS); |
| 165 }; | 152 }; |
| 166 | 153 |
| 167 } // namespace chromeos | 154 } // namespace chromeos |
| 168 | 155 |
| 169 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_CHROMEOS_H_ | 156 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_CHROMEOS_H_ |
| OLD | NEW |