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