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_SERVICE_CHROMEOS_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 const ErrorCallback& error_callback) OVERRIDE; | 62 const ErrorCallback& error_callback) OVERRIDE; |
63 | 63 |
64 // Object path of the underlying service. | 64 // Object path of the underlying service. |
65 const dbus::ObjectPath& object_path() const { return object_path_; } | 65 const dbus::ObjectPath& object_path() const { return object_path_; } |
66 | 66 |
67 // Notifies its observers that the GATT service has changed. This is mainly | 67 // Notifies its observers that the GATT service has changed. This is mainly |
68 // used by BluetoothRemoteGattCharacteristicChromeOS instances to notify | 68 // used by BluetoothRemoteGattCharacteristicChromeOS instances to notify |
69 // service observers when characteristic descriptors get added and removed. | 69 // service observers when characteristic descriptors get added and removed. |
70 void NotifyServiceChanged(); | 70 void NotifyServiceChanged(); |
71 | 71 |
| 72 // Notifies its observers that the value of a characteristic has changed. |
| 73 // Called by BluetoothRemoteGattCharacteristicChromeOS instances to notify |
| 74 // service observers when their cached value is updated after a successful |
| 75 // read request or when a "ValueUpdated" signal is received. |
| 76 void NotifyCharacteristicValueChanged( |
| 77 BluetoothRemoteGattCharacteristicChromeOS* characteristic, |
| 78 const std::vector<uint8>& value); |
| 79 |
72 // Notifies its observers that a descriptor |descriptor| belonging to | 80 // Notifies its observers that a descriptor |descriptor| belonging to |
73 // characteristic |characteristic| has been added or removed. This is used | 81 // characteristic |characteristic| has been added or removed. This is used |
74 // by BluetoothRemoteGattCharacteristicChromeOS instances to notify service | 82 // by BluetoothRemoteGattCharacteristicChromeOS instances to notify service |
75 // observers when characteristic descriptors get added and removed. If |added| | 83 // observers when characteristic descriptors get added and removed. If |added| |
76 // is true, an "Added" event will be sent. Otherwise, a "Removed" event will | 84 // is true, an "Added" event will be sent. Otherwise, a "Removed" event will |
77 // be sent. | 85 // be sent. |
78 void NotifyDescriptorAddedOrRemoved( | 86 void NotifyDescriptorAddedOrRemoved( |
79 BluetoothRemoteGattCharacteristicChromeOS* characteristic, | 87 BluetoothRemoteGattCharacteristicChromeOS* characteristic, |
80 BluetoothRemoteGattDescriptorChromeOS* descriptor, | 88 BluetoothRemoteGattDescriptorChromeOS* descriptor, |
81 bool added); | 89 bool added); |
(...skipping 16 matching lines...) Expand all Loading... |
98 // BluetoothGattServiceClient::Observer override. | 106 // BluetoothGattServiceClient::Observer override. |
99 virtual void GattServicePropertyChanged( | 107 virtual void GattServicePropertyChanged( |
100 const dbus::ObjectPath& object_path, | 108 const dbus::ObjectPath& object_path, |
101 const std::string& property_name) OVERRIDE; | 109 const std::string& property_name) OVERRIDE; |
102 | 110 |
103 // BluetoothGattCharacteristicClient::Observer override. | 111 // BluetoothGattCharacteristicClient::Observer override. |
104 virtual void GattCharacteristicAdded( | 112 virtual void GattCharacteristicAdded( |
105 const dbus::ObjectPath& object_path) OVERRIDE; | 113 const dbus::ObjectPath& object_path) OVERRIDE; |
106 virtual void GattCharacteristicRemoved( | 114 virtual void GattCharacteristicRemoved( |
107 const dbus::ObjectPath& object_path) OVERRIDE; | 115 const dbus::ObjectPath& object_path) OVERRIDE; |
108 virtual void GattCharacteristicPropertyChanged( | |
109 const dbus::ObjectPath& object_path, | |
110 const std::string& property_name) OVERRIDE; | |
111 | 116 |
112 // Object path of the GATT service. | 117 // Object path of the GATT service. |
113 dbus::ObjectPath object_path_; | 118 dbus::ObjectPath object_path_; |
114 | 119 |
115 // List of observers interested in event notifications from us. | 120 // List of observers interested in event notifications from us. |
116 ObserverList<device::BluetoothGattService::Observer> observers_; | 121 ObserverList<device::BluetoothGattService::Observer> observers_; |
117 | 122 |
118 // The device this GATT service belongs to. | 123 // The device this GATT service belongs to. |
119 BluetoothDeviceChromeOS* device_; | 124 BluetoothDeviceChromeOS* device_; |
120 | 125 |
121 // Mapping from GATT characteristic object paths to characteristic objects. | 126 // Mapping from GATT characteristic object paths to characteristic objects. |
122 // owned by this service. Since the Chrome OS implementation uses object | 127 // owned by this service. Since the Chrome OS implementation uses object |
123 // paths as unique identifiers, we also use this mapping to return | 128 // paths as unique identifiers, we also use this mapping to return |
124 // characteristics by identifier. | 129 // characteristics by identifier. |
125 typedef std::map<dbus::ObjectPath, BluetoothRemoteGattCharacteristicChromeOS*> | 130 typedef std::map<dbus::ObjectPath, BluetoothRemoteGattCharacteristicChromeOS*> |
126 CharacteristicMap; | 131 CharacteristicMap; |
127 CharacteristicMap characteristics_; | 132 CharacteristicMap characteristics_; |
128 | 133 |
129 // Note: This should remain the last member so it'll be destroyed and | 134 // Note: This should remain the last member so it'll be destroyed and |
130 // invalidate its weak pointers before any other members are destroyed. | 135 // invalidate its weak pointers before any other members are destroyed. |
131 base::WeakPtrFactory<BluetoothRemoteGattServiceChromeOS> weak_ptr_factory_; | 136 base::WeakPtrFactory<BluetoothRemoteGattServiceChromeOS> weak_ptr_factory_; |
132 | 137 |
133 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceChromeOS); | 138 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceChromeOS); |
134 }; | 139 }; |
135 | 140 |
136 } // namespace chromeos | 141 } // namespace chromeos |
137 | 142 |
138 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ | 143 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ |
OLD | NEW |