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 CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_
API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_
API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_
API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_
API_H_ |
7 | 7 |
8 #include <memory> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_api_adver
tisement.h" |
11 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ
y_event_router.h" | 13 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ
y_event_router.h" |
12 #include "chrome/browser/extensions/browser_context_keyed_service_factories.h" | 14 #include "content/public/browser/browser_context.h" |
13 #include "device/bluetooth/bluetooth_advertisement.h" | 15 #include "device/bluetooth/bluetooth_advertisement.h" |
14 #include "extensions/browser/api/api_resource_manager.h" | 16 #include "extensions/browser/api/api_resource_manager.h" |
| 17 #include "extensions/browser/browser_context_keyed_api_factory.h" |
15 #include "extensions/browser/extension_function.h" | 18 #include "extensions/browser/extension_function.h" |
16 #include "extensions/browser/extension_function_histogram_value.h" | 19 #include "extensions/browser/extension_function_histogram_value.h" |
17 | 20 |
18 namespace extensions { | 21 namespace extensions { |
19 | 22 |
20 class BluetoothApiAdvertisement; | 23 class BluetoothApiAdvertisement; |
21 class BluetoothLowEnergyEventRouter; | 24 class BluetoothLowEnergyEventRouter; |
22 | 25 |
23 // The profile-keyed service that manages the bluetoothLowEnergy extension API. | 26 // The profile-keyed service that manages the bluetoothLowEnergy extension API. |
24 class BluetoothLowEnergyAPI : public BrowserContextKeyedAPI { | 27 class BluetoothLowEnergyAPI : public BrowserContextKeyedAPI { |
(...skipping 25 matching lines...) Expand all Loading... |
50 std::unique_ptr<BluetoothLowEnergyEventRouter> event_router_; | 53 std::unique_ptr<BluetoothLowEnergyEventRouter> event_router_; |
51 | 54 |
52 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyAPI); | 55 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyAPI); |
53 }; | 56 }; |
54 | 57 |
55 namespace api { | 58 namespace api { |
56 | 59 |
57 // Base class for bluetoothLowEnergy API functions. This class handles some of | 60 // Base class for bluetoothLowEnergy API functions. This class handles some of |
58 // the common logic involved in all API functions, such as checking for | 61 // the common logic involved in all API functions, such as checking for |
59 // platform support and returning the correct error. | 62 // platform support and returning the correct error. |
60 class BluetoothLowEnergyExtensionFunction : public AsyncExtensionFunction { | 63 // |
| 64 // DEPRECATED: This inherits from AsyncExtensionFunction, which we're trying to |
| 65 // get rid of for various reasons. Please inherit from the |
| 66 // BluetoothLowEnergyExtensionFunction class instead. |
| 67 class BluetoothLowEnergyExtensionFunctionDeprecated |
| 68 : public AsyncExtensionFunction { |
61 public: | 69 public: |
62 BluetoothLowEnergyExtensionFunction(); | 70 BluetoothLowEnergyExtensionFunctionDeprecated(); |
63 | 71 |
64 protected: | 72 protected: |
65 ~BluetoothLowEnergyExtensionFunction() override; | 73 ~BluetoothLowEnergyExtensionFunctionDeprecated() override; |
66 | 74 |
67 // ExtensionFunction override. | 75 // AsyncExtensionFunction override. |
68 bool RunAsync() override; | 76 bool RunAsync() override; |
69 | 77 |
70 // Implemented by individual bluetoothLowEnergy extension functions to perform | 78 // Implemented by individual bluetoothLowEnergy extension functions to perform |
71 // the body of the function. This invoked asynchonously after RunAsync after | 79 // the body of the function. This invoked asynchonously after RunAsync after |
72 // the BluetoothLowEnergyEventRouter has obtained a handle on the | 80 // the BluetoothLowEnergyEventRouter has obtained a handle on the |
73 // BluetoothAdapter. | 81 // BluetoothAdapter. |
74 virtual bool DoWork() = 0; | 82 virtual bool DoWork() = 0; |
75 | 83 |
76 private: | 84 private: |
| 85 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyExtensionFunctionDeprecated); |
| 86 }; |
| 87 |
| 88 // Replacement for BluetoothLowEnergyExtensionFunctionDeprecated. Has the same |
| 89 // functionality except that instead of the SendResponse/return combo, we'll |
| 90 // return our response with Respond(). |
| 91 class BluetoothLowEnergyExtensionFunction : public UIThreadExtensionFunction { |
| 92 public: |
| 93 BluetoothLowEnergyExtensionFunction(); |
| 94 |
| 95 protected: |
| 96 ~BluetoothLowEnergyExtensionFunction() override; |
| 97 |
| 98 // ExtensionFunction override. |
| 99 ExtensionFunction::ResponseAction Run() override; |
| 100 |
| 101 // Implemented by individual bluetoothLowEnergy extension functions to perform |
| 102 // the body of the function. This invoked asynchonously after Run after |
| 103 // the BluetoothLowEnergyEventRouter has obtained a handle on the |
| 104 // BluetoothAdapter. |
| 105 virtual void DoWork() = 0; |
| 106 |
| 107 private: |
77 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyExtensionFunction); | 108 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyExtensionFunction); |
78 }; | 109 }; |
79 | 110 |
80 class BluetoothLowEnergyConnectFunction | 111 class BluetoothLowEnergyConnectFunction |
81 : public BluetoothLowEnergyExtensionFunction { | 112 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
82 public: | 113 public: |
83 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.connect", | 114 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.connect", |
84 BLUETOOTHLOWENERGY_CONNECT); | 115 BLUETOOTHLOWENERGY_CONNECT); |
85 | 116 |
86 protected: | 117 protected: |
87 ~BluetoothLowEnergyConnectFunction() override {} | 118 ~BluetoothLowEnergyConnectFunction() override {} |
88 | 119 |
89 // BluetoothLowEnergyExtensionFunction override. | 120 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
90 bool DoWork() override; | 121 bool DoWork() override; |
91 | 122 |
92 private: | 123 private: |
93 // Success and error callbacks, called by | 124 // Success and error callbacks, called by |
94 // BluetoothLowEnergyEventRouter::Connect. | 125 // BluetoothLowEnergyEventRouter::Connect. |
95 void SuccessCallback(); | 126 void SuccessCallback(); |
96 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 127 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
97 }; | 128 }; |
98 | 129 |
99 class BluetoothLowEnergyDisconnectFunction | 130 class BluetoothLowEnergyDisconnectFunction |
100 : public BluetoothLowEnergyExtensionFunction { | 131 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
101 public: | 132 public: |
102 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.disconnect", | 133 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.disconnect", |
103 BLUETOOTHLOWENERGY_DISCONNECT); | 134 BLUETOOTHLOWENERGY_DISCONNECT); |
104 | 135 |
105 protected: | 136 protected: |
106 ~BluetoothLowEnergyDisconnectFunction() override {} | 137 ~BluetoothLowEnergyDisconnectFunction() override {} |
107 | 138 |
108 // BluetoothLowEnergyExtensionFunction override. | 139 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
109 bool DoWork() override; | 140 bool DoWork() override; |
110 | 141 |
111 private: | 142 private: |
112 // Success and error callbacks, called by | 143 // Success and error callbacks, called by |
113 // BluetoothLowEnergyEventRouter::Disconnect. | 144 // BluetoothLowEnergyEventRouter::Disconnect. |
114 void SuccessCallback(); | 145 void SuccessCallback(); |
115 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 146 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
116 }; | 147 }; |
117 | 148 |
118 class BluetoothLowEnergyGetServiceFunction | 149 class BluetoothLowEnergyGetServiceFunction |
119 : public BluetoothLowEnergyExtensionFunction { | 150 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
120 public: | 151 public: |
121 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getService", | 152 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getService", |
122 BLUETOOTHLOWENERGY_GETSERVICE); | 153 BLUETOOTHLOWENERGY_GETSERVICE); |
123 | 154 |
124 protected: | 155 protected: |
125 ~BluetoothLowEnergyGetServiceFunction() override {} | 156 ~BluetoothLowEnergyGetServiceFunction() override {} |
126 | 157 |
127 // BluetoothLowEnergyExtensionFunction override. | 158 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
128 bool DoWork() override; | 159 bool DoWork() override; |
129 }; | 160 }; |
130 | 161 |
131 class BluetoothLowEnergyGetServicesFunction | 162 class BluetoothLowEnergyGetServicesFunction |
132 : public BluetoothLowEnergyExtensionFunction { | 163 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
133 public: | 164 public: |
134 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getServices", | 165 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getServices", |
135 BLUETOOTHLOWENERGY_GETSERVICES); | 166 BLUETOOTHLOWENERGY_GETSERVICES); |
136 | 167 |
137 protected: | 168 protected: |
138 ~BluetoothLowEnergyGetServicesFunction() override {} | 169 ~BluetoothLowEnergyGetServicesFunction() override {} |
139 | 170 |
140 // BluetoothLowEnergyExtensionFunction override. | 171 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
141 bool DoWork() override; | 172 bool DoWork() override; |
142 }; | 173 }; |
143 | 174 |
144 class BluetoothLowEnergyGetCharacteristicFunction | 175 class BluetoothLowEnergyGetCharacteristicFunction |
145 : public BluetoothLowEnergyExtensionFunction { | 176 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
146 public: | 177 public: |
147 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristic", | 178 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristic", |
148 BLUETOOTHLOWENERGY_GETCHARACTERISTIC); | 179 BLUETOOTHLOWENERGY_GETCHARACTERISTIC); |
149 | 180 |
150 protected: | 181 protected: |
151 ~BluetoothLowEnergyGetCharacteristicFunction() override {} | 182 ~BluetoothLowEnergyGetCharacteristicFunction() override {} |
152 | 183 |
153 // BluetoothLowEnergyExtensionFunction override. | 184 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
154 bool DoWork() override; | 185 bool DoWork() override; |
155 }; | 186 }; |
156 | 187 |
157 class BluetoothLowEnergyGetCharacteristicsFunction | 188 class BluetoothLowEnergyGetCharacteristicsFunction |
158 : public BluetoothLowEnergyExtensionFunction { | 189 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
159 public: | 190 public: |
160 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristics", | 191 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristics", |
161 BLUETOOTHLOWENERGY_GETCHARACTERISTICS); | 192 BLUETOOTHLOWENERGY_GETCHARACTERISTICS); |
162 | 193 |
163 protected: | 194 protected: |
164 ~BluetoothLowEnergyGetCharacteristicsFunction() override {} | 195 ~BluetoothLowEnergyGetCharacteristicsFunction() override {} |
165 | 196 |
166 // BluetoothLowEnergyExtensionFunction override. | 197 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
167 bool DoWork() override; | 198 bool DoWork() override; |
168 }; | 199 }; |
169 | 200 |
170 class BluetoothLowEnergyGetIncludedServicesFunction | 201 class BluetoothLowEnergyGetIncludedServicesFunction |
171 : public BluetoothLowEnergyExtensionFunction { | 202 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
172 public: | 203 public: |
173 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getIncludedServices", | 204 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getIncludedServices", |
174 BLUETOOTHLOWENERGY_GETINCLUDEDSERVICES); | 205 BLUETOOTHLOWENERGY_GETINCLUDEDSERVICES); |
175 | 206 |
176 protected: | 207 protected: |
177 ~BluetoothLowEnergyGetIncludedServicesFunction() override {} | 208 ~BluetoothLowEnergyGetIncludedServicesFunction() override {} |
178 | 209 |
179 // BluetoothLowEnergyExtensionFunction override. | 210 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
180 bool DoWork() override; | 211 bool DoWork() override; |
181 }; | 212 }; |
182 | 213 |
183 class BluetoothLowEnergyGetDescriptorFunction | 214 class BluetoothLowEnergyGetDescriptorFunction |
184 : public BluetoothLowEnergyExtensionFunction { | 215 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
185 public: | 216 public: |
186 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptor", | 217 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptor", |
187 BLUETOOTHLOWENERGY_GETDESCRIPTOR); | 218 BLUETOOTHLOWENERGY_GETDESCRIPTOR); |
188 | 219 |
189 protected: | 220 protected: |
190 ~BluetoothLowEnergyGetDescriptorFunction() override {} | 221 ~BluetoothLowEnergyGetDescriptorFunction() override {} |
191 | 222 |
192 // BluetoothLowEnergyExtensionFunction override. | 223 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
193 bool DoWork() override; | 224 bool DoWork() override; |
194 }; | 225 }; |
195 | 226 |
196 class BluetoothLowEnergyGetDescriptorsFunction | 227 class BluetoothLowEnergyGetDescriptorsFunction |
197 : public BluetoothLowEnergyExtensionFunction { | 228 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
198 public: | 229 public: |
199 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptors", | 230 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptors", |
200 BLUETOOTHLOWENERGY_GETDESCRIPTORS); | 231 BLUETOOTHLOWENERGY_GETDESCRIPTORS); |
201 | 232 |
202 protected: | 233 protected: |
203 ~BluetoothLowEnergyGetDescriptorsFunction() override {} | 234 ~BluetoothLowEnergyGetDescriptorsFunction() override {} |
204 | 235 |
205 // BluetoothLowEnergyExtensionFunction override. | 236 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
206 bool DoWork() override; | 237 bool DoWork() override; |
207 }; | 238 }; |
208 | 239 |
209 class BluetoothLowEnergyReadCharacteristicValueFunction | 240 class BluetoothLowEnergyReadCharacteristicValueFunction |
210 : public BluetoothLowEnergyExtensionFunction { | 241 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
211 public: | 242 public: |
212 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readCharacteristicValue", | 243 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readCharacteristicValue", |
213 BLUETOOTHLOWENERGY_READCHARACTERISTICVALUE); | 244 BLUETOOTHLOWENERGY_READCHARACTERISTICVALUE); |
214 | 245 |
215 protected: | 246 protected: |
216 ~BluetoothLowEnergyReadCharacteristicValueFunction() override {} | 247 ~BluetoothLowEnergyReadCharacteristicValueFunction() override {} |
217 | 248 |
218 // BluetoothLowEnergyExtensionFunction override. | 249 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
219 bool DoWork() override; | 250 bool DoWork() override; |
220 | 251 |
221 private: | 252 private: |
222 // Success and error callbacks, called by | 253 // Success and error callbacks, called by |
223 // BluetoothLowEnergyEventRouter::ReadCharacteristicValue. | 254 // BluetoothLowEnergyEventRouter::ReadCharacteristicValue. |
224 void SuccessCallback(); | 255 void SuccessCallback(); |
225 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 256 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
226 | 257 |
227 // The instance ID of the requested characteristic. | 258 // The instance ID of the requested characteristic. |
228 std::string instance_id_; | 259 std::string instance_id_; |
229 }; | 260 }; |
230 | 261 |
231 class BluetoothLowEnergyWriteCharacteristicValueFunction | 262 class BluetoothLowEnergyWriteCharacteristicValueFunction |
232 : public BluetoothLowEnergyExtensionFunction { | 263 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
233 public: | 264 public: |
234 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeCharacteristicValue", | 265 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeCharacteristicValue", |
235 BLUETOOTHLOWENERGY_WRITECHARACTERISTICVALUE); | 266 BLUETOOTHLOWENERGY_WRITECHARACTERISTICVALUE); |
236 | 267 |
237 protected: | 268 protected: |
238 ~BluetoothLowEnergyWriteCharacteristicValueFunction() override {} | 269 ~BluetoothLowEnergyWriteCharacteristicValueFunction() override {} |
239 | 270 |
240 // BluetoothLowEnergyExtensionFunction override. | 271 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
241 bool DoWork() override; | 272 bool DoWork() override; |
242 | 273 |
243 private: | 274 private: |
244 // Success and error callbacks, called by | 275 // Success and error callbacks, called by |
245 // BluetoothLowEnergyEventRouter::WriteCharacteristicValue. | 276 // BluetoothLowEnergyEventRouter::WriteCharacteristicValue. |
246 void SuccessCallback(); | 277 void SuccessCallback(); |
247 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 278 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
248 | 279 |
249 // The instance ID of the requested characteristic. | 280 // The instance ID of the requested characteristic. |
250 std::string instance_id_; | 281 std::string instance_id_; |
251 }; | 282 }; |
252 | 283 |
253 class BluetoothLowEnergyStartCharacteristicNotificationsFunction | 284 class BluetoothLowEnergyStartCharacteristicNotificationsFunction |
254 : public BluetoothLowEnergyExtensionFunction { | 285 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
255 public: | 286 public: |
256 DECLARE_EXTENSION_FUNCTION( | 287 DECLARE_EXTENSION_FUNCTION( |
257 "bluetoothLowEnergy.startCharacteristicNotifications", | 288 "bluetoothLowEnergy.startCharacteristicNotifications", |
258 BLUETOOTHLOWENERGY_STARTCHARACTERISTICNOTIFICATIONS); | 289 BLUETOOTHLOWENERGY_STARTCHARACTERISTICNOTIFICATIONS); |
259 | 290 |
260 protected: | 291 protected: |
261 ~BluetoothLowEnergyStartCharacteristicNotificationsFunction() override {} | 292 ~BluetoothLowEnergyStartCharacteristicNotificationsFunction() override {} |
262 | 293 |
263 // BluetoothLowEnergyExtensionFunction override. | 294 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
264 bool DoWork() override; | 295 bool DoWork() override; |
265 | 296 |
266 private: | 297 private: |
267 // Success and error callbacks, called by | 298 // Success and error callbacks, called by |
268 // BluetoothLowEnergyEventRouter::StartCharacteristicNotifications. | 299 // BluetoothLowEnergyEventRouter::StartCharacteristicNotifications. |
269 void SuccessCallback(); | 300 void SuccessCallback(); |
270 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 301 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
271 }; | 302 }; |
272 | 303 |
273 class BluetoothLowEnergyStopCharacteristicNotificationsFunction | 304 class BluetoothLowEnergyStopCharacteristicNotificationsFunction |
274 : public BluetoothLowEnergyExtensionFunction { | 305 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
275 public: | 306 public: |
276 DECLARE_EXTENSION_FUNCTION( | 307 DECLARE_EXTENSION_FUNCTION( |
277 "bluetoothLowEnergy.stopCharacteristicNotifications", | 308 "bluetoothLowEnergy.stopCharacteristicNotifications", |
278 BLUETOOTHLOWENERGY_STOPCHARACTERISTICNOTIFICATIONS); | 309 BLUETOOTHLOWENERGY_STOPCHARACTERISTICNOTIFICATIONS); |
279 | 310 |
280 protected: | 311 protected: |
281 ~BluetoothLowEnergyStopCharacteristicNotificationsFunction() override {} | 312 ~BluetoothLowEnergyStopCharacteristicNotificationsFunction() override {} |
282 | 313 |
283 // BluetoothLowEnergyExtensionFunction override. | 314 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
284 bool DoWork() override; | 315 bool DoWork() override; |
285 | 316 |
286 private: | 317 private: |
287 // Success and error callbacks, called by | 318 // Success and error callbacks, called by |
288 // BluetoothLowEnergyEventRouter::StopCharacteristicNotifications. | 319 // BluetoothLowEnergyEventRouter::StopCharacteristicNotifications. |
289 void SuccessCallback(); | 320 void SuccessCallback(); |
290 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 321 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
291 }; | 322 }; |
292 | 323 |
293 class BluetoothLowEnergyReadDescriptorValueFunction | 324 class BluetoothLowEnergyReadDescriptorValueFunction |
294 : public BluetoothLowEnergyExtensionFunction { | 325 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
295 public: | 326 public: |
296 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readDescriptorValue", | 327 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readDescriptorValue", |
297 BLUETOOTHLOWENERGY_READDESCRIPTORVALUE); | 328 BLUETOOTHLOWENERGY_READDESCRIPTORVALUE); |
298 | 329 |
299 protected: | 330 protected: |
300 ~BluetoothLowEnergyReadDescriptorValueFunction() override {} | 331 ~BluetoothLowEnergyReadDescriptorValueFunction() override {} |
301 | 332 |
302 // BluetoothLowEnergyExtensionFunction override. | 333 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
303 bool DoWork() override; | 334 bool DoWork() override; |
304 | 335 |
305 private: | 336 private: |
306 // Success and error callbacks, called by | 337 // Success and error callbacks, called by |
307 // BluetoothLowEnergyEventRouter::ReadDescriptorValue. | 338 // BluetoothLowEnergyEventRouter::ReadDescriptorValue. |
308 void SuccessCallback(); | 339 void SuccessCallback(); |
309 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 340 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
310 | 341 |
311 // The instance ID of the requested descriptor. | 342 // The instance ID of the requested descriptor. |
312 std::string instance_id_; | 343 std::string instance_id_; |
313 }; | 344 }; |
314 | 345 |
315 class BluetoothLowEnergyWriteDescriptorValueFunction | 346 class BluetoothLowEnergyWriteDescriptorValueFunction |
316 : public BluetoothLowEnergyExtensionFunction { | 347 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
317 public: | 348 public: |
318 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeDescriptorValue", | 349 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeDescriptorValue", |
319 BLUETOOTHLOWENERGY_WRITEDESCRIPTORVALUE); | 350 BLUETOOTHLOWENERGY_WRITEDESCRIPTORVALUE); |
320 | 351 |
321 protected: | 352 protected: |
322 ~BluetoothLowEnergyWriteDescriptorValueFunction() override {} | 353 ~BluetoothLowEnergyWriteDescriptorValueFunction() override {} |
323 | 354 |
324 // BluetoothLowEnergyExtensionFunction override. | 355 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
325 bool DoWork() override; | 356 bool DoWork() override; |
326 | 357 |
327 private: | 358 private: |
328 // Success and error callbacks, called by | 359 // Success and error callbacks, called by |
329 // BluetoothLowEnergyEventRouter::WriteDescriptorValue. | 360 // BluetoothLowEnergyEventRouter::WriteDescriptorValue. |
330 void SuccessCallback(); | 361 void SuccessCallback(); |
331 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 362 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
332 | 363 |
333 // The instance ID of the requested descriptor. | 364 // The instance ID of the requested descriptor. |
334 std::string instance_id_; | 365 std::string instance_id_; |
335 }; | 366 }; |
336 | 367 |
337 class BluetoothLowEnergyAdvertisementFunction | 368 class BluetoothLowEnergyAdvertisementFunction |
338 : public BluetoothLowEnergyExtensionFunction { | 369 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
339 public: | 370 public: |
340 BluetoothLowEnergyAdvertisementFunction(); | 371 BluetoothLowEnergyAdvertisementFunction(); |
341 | 372 |
342 protected: | 373 protected: |
343 ~BluetoothLowEnergyAdvertisementFunction() override; | 374 ~BluetoothLowEnergyAdvertisementFunction() override; |
344 | 375 |
345 // Takes ownership. | 376 // Takes ownership. |
346 int AddAdvertisement(BluetoothApiAdvertisement* advertisement); | 377 int AddAdvertisement(BluetoothApiAdvertisement* advertisement); |
347 BluetoothApiAdvertisement* GetAdvertisement(int advertisement_id); | 378 BluetoothApiAdvertisement* GetAdvertisement(int advertisement_id); |
348 void RemoveAdvertisement(int advertisement_id); | 379 void RemoveAdvertisement(int advertisement_id); |
(...skipping 11 matching lines...) Expand all Loading... |
360 | 391 |
361 class BluetoothLowEnergyRegisterAdvertisementFunction | 392 class BluetoothLowEnergyRegisterAdvertisementFunction |
362 : public BluetoothLowEnergyAdvertisementFunction { | 393 : public BluetoothLowEnergyAdvertisementFunction { |
363 public: | 394 public: |
364 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.registerAdvertisement", | 395 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.registerAdvertisement", |
365 BLUETOOTHLOWENERGY_REGISTERADVERTISEMENT); | 396 BLUETOOTHLOWENERGY_REGISTERADVERTISEMENT); |
366 | 397 |
367 protected: | 398 protected: |
368 ~BluetoothLowEnergyRegisterAdvertisementFunction() override {} | 399 ~BluetoothLowEnergyRegisterAdvertisementFunction() override {} |
369 | 400 |
370 // BluetoothLowEnergyExtensionFunction override. | 401 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
371 bool DoWork() override; | 402 bool DoWork() override; |
372 | 403 |
373 private: | 404 private: |
374 void SuccessCallback(scoped_refptr<device::BluetoothAdvertisement>); | 405 void SuccessCallback(scoped_refptr<device::BluetoothAdvertisement>); |
375 void ErrorCallback(device::BluetoothAdvertisement::ErrorCode status); | 406 void ErrorCallback(device::BluetoothAdvertisement::ErrorCode status); |
376 | 407 |
377 // The instance ID of the requested descriptor. | 408 // The instance ID of the requested descriptor. |
378 std::string instance_id_; | 409 std::string instance_id_; |
379 }; | 410 }; |
380 | 411 |
381 class BluetoothLowEnergyUnregisterAdvertisementFunction | 412 class BluetoothLowEnergyUnregisterAdvertisementFunction |
382 : public BluetoothLowEnergyAdvertisementFunction { | 413 : public BluetoothLowEnergyAdvertisementFunction { |
383 public: | 414 public: |
384 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.unregisterAdvertisement", | 415 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.unregisterAdvertisement", |
385 BLUETOOTHLOWENERGY_UNREGISTERADVERTISEMENT); | 416 BLUETOOTHLOWENERGY_UNREGISTERADVERTISEMENT); |
386 | 417 |
387 protected: | 418 protected: |
388 ~BluetoothLowEnergyUnregisterAdvertisementFunction() override {} | 419 ~BluetoothLowEnergyUnregisterAdvertisementFunction() override {} |
389 | 420 |
390 // BluetoothLowEnergyExtensionFunction override. | 421 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
391 bool DoWork() override; | 422 bool DoWork() override; |
392 | 423 |
393 private: | 424 private: |
394 void SuccessCallback(int advertisement_id); | 425 void SuccessCallback(int advertisement_id); |
395 void ErrorCallback(int advertisement_id, | 426 void ErrorCallback(int advertisement_id, |
396 device::BluetoothAdvertisement::ErrorCode status); | 427 device::BluetoothAdvertisement::ErrorCode status); |
397 | 428 |
398 // The instance ID of the requested descriptor. | 429 // The instance ID of the requested descriptor. |
399 std::string instance_id_; | 430 std::string instance_id_; |
400 }; | 431 }; |
401 | 432 |
| 433 class BluetoothLowEnergyCreateServiceFunction |
| 434 : public BluetoothLowEnergyExtensionFunction { |
| 435 public: |
| 436 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.createService", |
| 437 BLUETOOTHLOWENERGY_CREATESERVICE); |
| 438 |
| 439 protected: |
| 440 ~BluetoothLowEnergyCreateServiceFunction() override {} |
| 441 |
| 442 // BluetoothLowEnergyExtensionFunction override. |
| 443 void DoWork() override; |
| 444 }; |
| 445 |
| 446 class BluetoothLowEnergyCreateCharacteristicFunction |
| 447 : public BluetoothLowEnergyExtensionFunction { |
| 448 public: |
| 449 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.createCharacteristic", |
| 450 BLUETOOTHLOWENERGY_CREATECHARACTERISTIC); |
| 451 |
| 452 protected: |
| 453 ~BluetoothLowEnergyCreateCharacteristicFunction() override {} |
| 454 |
| 455 // BluetoothLowEnergyExtensionFunction override. |
| 456 void DoWork() override; |
| 457 }; |
| 458 |
| 459 class BluetoothLowEnergyCreateDescriptorFunction |
| 460 : public BluetoothLowEnergyExtensionFunction { |
| 461 public: |
| 462 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.createDescriptor", |
| 463 BLUETOOTHLOWENERGY_CREATEDESCRIPTOR); |
| 464 |
| 465 protected: |
| 466 ~BluetoothLowEnergyCreateDescriptorFunction() override {} |
| 467 |
| 468 // BluetoothLowEnergyExtensionFunction override. |
| 469 void DoWork() override; |
| 470 }; |
| 471 |
| 472 class BluetoothLowEnergyRegisterServiceFunction |
| 473 : public BluetoothLowEnergyExtensionFunction { |
| 474 public: |
| 475 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.registerService", |
| 476 BLUETOOTHLOWENERGY_REGISTERSERVICE); |
| 477 |
| 478 protected: |
| 479 ~BluetoothLowEnergyRegisterServiceFunction() override {} |
| 480 |
| 481 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 482 void DoWork() override; |
| 483 }; |
| 484 |
| 485 class BluetoothLowEnergyUnregisterServiceFunction |
| 486 : public BluetoothLowEnergyExtensionFunction { |
| 487 public: |
| 488 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.unregisterService", |
| 489 BLUETOOTHLOWENERGY_UNREGISTERSERVICE); |
| 490 |
| 491 protected: |
| 492 ~BluetoothLowEnergyUnregisterServiceFunction() override {} |
| 493 |
| 494 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 495 void DoWork() override; |
| 496 }; |
| 497 |
| 498 class BluetoothLowEnergySendRequestResponseFunction |
| 499 : public BluetoothLowEnergyExtensionFunction { |
| 500 public: |
| 501 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.sendRequestResponse", |
| 502 BLUETOOTHLOWENERGY_SENDREQUESTRESPONSE); |
| 503 |
| 504 protected: |
| 505 ~BluetoothLowEnergySendRequestResponseFunction() override {} |
| 506 |
| 507 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 508 void DoWork() override; |
| 509 }; |
| 510 |
402 } // namespace api | 511 } // namespace api |
403 } // namespace extensions | 512 } // namespace extensions |
404 | 513 |
405 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENER
GY_API_H_ | 514 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENER
GY_API_H_ |
OLD | NEW |