| 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 EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_EVENT_R
OUTER_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_EVENT_R
OUTER_H_ |
| 6 #define EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_EVENT_R
OUTER_H_ | 6 #define EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_EVENT_R
OUTER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // Disconnects the currently open GATT connection of extension |extension| to | 105 // Disconnects the currently open GATT connection of extension |extension| to |
| 106 // device with address |device_address|. |error_callback| is called with an | 106 // device with address |device_address|. |error_callback| is called with an |
| 107 // error status in case of failure, e.g. if the device is not found or the | 107 // error status in case of failure, e.g. if the device is not found or the |
| 108 // given | 108 // given |
| 109 // extension does not have an open connection to the device. | 109 // extension does not have an open connection to the device. |
| 110 void Disconnect(const Extension* extension, | 110 void Disconnect(const Extension* extension, |
| 111 const std::string& device_address, | 111 const std::string& device_address, |
| 112 const base::Closure& callback, | 112 const base::Closure& callback, |
| 113 const ErrorCallback& error_callback); | 113 const ErrorCallback& error_callback); |
| 114 | 114 |
| 115 // Returns the list of core_api::bluetooth_low_energy::Service objects | 115 // Returns the list of api::bluetooth_low_energy::Service objects |
| 116 // associated with the Bluetooth device with address |device_address| in | 116 // associated with the Bluetooth device with address |device_address| in |
| 117 // |out_services|. | 117 // |out_services|. |
| 118 // Returns false, if no device with the given address is known. If the device | 118 // Returns false, if no device with the given address is known. If the device |
| 119 // is found but it has no GATT services, then returns true and leaves | 119 // is found but it has no GATT services, then returns true and leaves |
| 120 // |out_services| empty. Returns true, on success. |out_services| must not | 120 // |out_services| empty. Returns true, on success. |out_services| must not |
| 121 // be NULL. If it is non-empty, then its contents will be cleared. | 121 // be NULL. If it is non-empty, then its contents will be cleared. |
| 122 typedef std::vector<linked_ptr<core_api::bluetooth_low_energy::Service> > | 122 typedef std::vector<linked_ptr<api::bluetooth_low_energy::Service>> |
| 123 ServiceList; | 123 ServiceList; |
| 124 bool GetServices(const std::string& device_address, | 124 bool GetServices(const std::string& device_address, |
| 125 ServiceList* out_services) const; | 125 ServiceList* out_services) const; |
| 126 | 126 |
| 127 // Populates |out_service| based on GATT service with instance ID | 127 // Populates |out_service| based on GATT service with instance ID |
| 128 // |instance_id|. |out_service| must not be NULL. | 128 // |instance_id|. |out_service| must not be NULL. |
| 129 Status GetService(const std::string& instance_id, | 129 Status GetService(const std::string& instance_id, |
| 130 core_api::bluetooth_low_energy::Service* out_service) const; | 130 api::bluetooth_low_energy::Service* out_service) const; |
| 131 | 131 |
| 132 // Populates |out_services| with the list of GATT services that are included | 132 // Populates |out_services| with the list of GATT services that are included |
| 133 // by the GATT service with instance ID |instance_id|. Returns false, if not | 133 // by the GATT service with instance ID |instance_id|. Returns false, if not |
| 134 // GATT service with the given ID is known. If the given service has no | 134 // GATT service with the given ID is known. If the given service has no |
| 135 // included services, then |out_service| will be empty. |out_service| must not | 135 // included services, then |out_service| will be empty. |out_service| must not |
| 136 // be NULL. If it is non-empty, then its contents will be cleared. | 136 // be NULL. If it is non-empty, then its contents will be cleared. |
| 137 Status GetIncludedServices(const std::string& instance_id, | 137 Status GetIncludedServices(const std::string& instance_id, |
| 138 ServiceList* out_services) const; | 138 ServiceList* out_services) const; |
| 139 | 139 |
| 140 // Returns the list of core_api::bluetooth_low_energy::Characteristic objects | 140 // Returns the list of api::bluetooth_low_energy::Characteristic objects |
| 141 // associated with the GATT service with instance ID |instance_id| in | 141 // associated with the GATT service with instance ID |instance_id| in |
| 142 // |out_characteristics|. Returns false, if no service with the given instance | 142 // |out_characteristics|. Returns false, if no service with the given instance |
| 143 // ID is known. If the service is found but it has no characteristics, then | 143 // ID is known. If the service is found but it has no characteristics, then |
| 144 // returns true and leaves |out_characteristics| empty. | 144 // returns true and leaves |out_characteristics| empty. |
| 145 // |out_characteristics| must not be NULL and if it is non-empty, | 145 // |out_characteristics| must not be NULL and if it is non-empty, |
| 146 // then its contents will be cleared. |extension| is the extension that made | 146 // then its contents will be cleared. |extension| is the extension that made |
| 147 // the call. | 147 // the call. |
| 148 typedef std::vector< | 148 typedef std::vector<linked_ptr<api::bluetooth_low_energy::Characteristic>> |
| 149 linked_ptr<core_api::bluetooth_low_energy::Characteristic> > | |
| 150 CharacteristicList; | 149 CharacteristicList; |
| 151 Status GetCharacteristics(const Extension* extension, | 150 Status GetCharacteristics(const Extension* extension, |
| 152 const std::string& instance_id, | 151 const std::string& instance_id, |
| 153 CharacteristicList* out_characteristics) const; | 152 CharacteristicList* out_characteristics) const; |
| 154 | 153 |
| 155 // Populates |out_characteristic| based on GATT characteristic with instance | 154 // Populates |out_characteristic| based on GATT characteristic with instance |
| 156 // ID |instance_id|. |out_characteristic| must not be NULL. |extension| is the | 155 // ID |instance_id|. |out_characteristic| must not be NULL. |extension| is the |
| 157 // extension that made the call. | 156 // extension that made the call. |
| 158 Status GetCharacteristic( | 157 Status GetCharacteristic( |
| 159 const Extension* extension, | 158 const Extension* extension, |
| 160 const std::string& instance_id, | 159 const std::string& instance_id, |
| 161 core_api::bluetooth_low_energy::Characteristic* out_characteristic) const; | 160 api::bluetooth_low_energy::Characteristic* out_characteristic) const; |
| 162 | 161 |
| 163 // Returns the list of core_api::bluetooth_low_energy::Descriptor objects | 162 // Returns the list of api::bluetooth_low_energy::Descriptor objects |
| 164 // associated with the GATT characteristic with instance ID |instance_id| in | 163 // associated with the GATT characteristic with instance ID |instance_id| in |
| 165 // |out_descriptors|. If the characteristic is found but it has no | 164 // |out_descriptors|. If the characteristic is found but it has no |
| 166 // descriptors, then returns true and leaves |out_descriptors| empty. | 165 // descriptors, then returns true and leaves |out_descriptors| empty. |
| 167 // |out_descriptors| must not be NULL and if it is non-empty, | 166 // |out_descriptors| must not be NULL and if it is non-empty, |
| 168 // then its contents will be cleared. |extension| is the extension that made | 167 // then its contents will be cleared. |extension| is the extension that made |
| 169 // the call. | 168 // the call. |
| 170 typedef std::vector<linked_ptr<core_api::bluetooth_low_energy::Descriptor> > | 169 typedef std::vector<linked_ptr<api::bluetooth_low_energy::Descriptor>> |
| 171 DescriptorList; | 170 DescriptorList; |
| 172 Status GetDescriptors(const Extension* extension, | 171 Status GetDescriptors(const Extension* extension, |
| 173 const std::string& instance_id, | 172 const std::string& instance_id, |
| 174 DescriptorList* out_descriptors) const; | 173 DescriptorList* out_descriptors) const; |
| 175 | 174 |
| 176 // Populates |out_descriptor| based on GATT characteristic descriptor with | 175 // Populates |out_descriptor| based on GATT characteristic descriptor with |
| 177 // instance ID |instance_id|. |out_descriptor| must not be NULL. | 176 // instance ID |instance_id|. |out_descriptor| must not be NULL. |
| 178 // |extension| is the extension that made the call. | 177 // |extension| is the extension that made the call. |
| 179 Status GetDescriptor( | 178 Status GetDescriptor( |
| 180 const Extension* extension, | 179 const Extension* extension, |
| 181 const std::string& instance_id, | 180 const std::string& instance_id, |
| 182 core_api::bluetooth_low_energy::Descriptor* out_descriptor) const; | 181 api::bluetooth_low_energy::Descriptor* out_descriptor) const; |
| 183 | 182 |
| 184 // Sends a request to read the value of the characteristic with intance ID | 183 // Sends a request to read the value of the characteristic with intance ID |
| 185 // |instance_id|. Invokes |callback| on success and |error_callback| on | 184 // |instance_id|. Invokes |callback| on success and |error_callback| on |
| 186 // failure. |extension| is the extension that made the call. | 185 // failure. |extension| is the extension that made the call. |
| 187 void ReadCharacteristicValue(const Extension* extension, | 186 void ReadCharacteristicValue(const Extension* extension, |
| 188 const std::string& instance_id, | 187 const std::string& instance_id, |
| 189 const base::Closure& callback, | 188 const base::Closure& callback, |
| 190 const ErrorCallback& error_callback); | 189 const ErrorCallback& error_callback); |
| 191 | 190 |
| 192 // Sends a request to write the value of the characteristic with instance ID | 191 // Sends a request to write the value of the characteristic with instance ID |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 // Note: This should remain the last member so it'll be destroyed and | 419 // Note: This should remain the last member so it'll be destroyed and |
| 421 // invalidate its weak pointers before any other members are destroyed. | 420 // invalidate its weak pointers before any other members are destroyed. |
| 422 base::WeakPtrFactory<BluetoothLowEnergyEventRouter> weak_ptr_factory_; | 421 base::WeakPtrFactory<BluetoothLowEnergyEventRouter> weak_ptr_factory_; |
| 423 | 422 |
| 424 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyEventRouter); | 423 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyEventRouter); |
| 425 }; | 424 }; |
| 426 | 425 |
| 427 } // namespace extensions | 426 } // namespace extensions |
| 428 | 427 |
| 429 #endif // EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_EVEN
T_ROUTER_H_ | 428 #endif // EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_EVEN
T_ROUTER_H_ |
| OLD | NEW |