Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.h

Issue 1915243003: API Bindings for GATT server functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@adapter_and_tests
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
20 class BluetoothApiAdvertisement; 22 class BluetoothApiAdvertisement;
21 class BluetoothLowEnergyEventRouter; 23 class BluetoothLowEnergyEventRouter;
22 24
25 namespace api {
26 namespace bluetooth_low_energy {
27 namespace CreateService {
28 struct Params;
29 }
30 namespace CreateCharacteristic {
31 struct Params;
32 }
33 namespace CreateDescriptor {
34 struct Params;
35 }
36 namespace RegisterService {
37 struct Params;
38 }
39 namespace UnregisterService {
40 struct Params;
41 }
42 namespace SendRequestResponse {
43 struct Params;
44 }
45 } // namespace bluetooth_low_energy
46 } // namespace api
47
23 // The profile-keyed service that manages the bluetoothLowEnergy extension API. 48 // The profile-keyed service that manages the bluetoothLowEnergy extension API.
24 class BluetoothLowEnergyAPI : public BrowserContextKeyedAPI { 49 class BluetoothLowEnergyAPI : public BrowserContextKeyedAPI {
25 public: 50 public:
26 static BrowserContextKeyedAPIFactory<BluetoothLowEnergyAPI>* 51 static BrowserContextKeyedAPIFactory<BluetoothLowEnergyAPI>*
27 GetFactoryInstance(); 52 GetFactoryInstance();
28 53
29 // Convenience method to get the BluetoothLowEnergy API for a browser context. 54 // Convenience method to get the BluetoothLowEnergy API for a browser context.
30 static BluetoothLowEnergyAPI* Get(content::BrowserContext* context); 55 static BluetoothLowEnergyAPI* Get(content::BrowserContext* context);
31 56
32 explicit BluetoothLowEnergyAPI(content::BrowserContext* context); 57 explicit BluetoothLowEnergyAPI(content::BrowserContext* context);
(...skipping 17 matching lines...) Expand all
50 std::unique_ptr<BluetoothLowEnergyEventRouter> event_router_; 75 std::unique_ptr<BluetoothLowEnergyEventRouter> event_router_;
51 76
52 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyAPI); 77 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyAPI);
53 }; 78 };
54 79
55 namespace api { 80 namespace api {
56 81
57 // Base class for bluetoothLowEnergy API functions. This class handles some of 82 // Base class for bluetoothLowEnergy API functions. This class handles some of
58 // the common logic involved in all API functions, such as checking for 83 // the common logic involved in all API functions, such as checking for
59 // platform support and returning the correct error. 84 // platform support and returning the correct error.
60 class BluetoothLowEnergyExtensionFunction : public AsyncExtensionFunction { 85 //
86 // DEPRECATED: This inherits from AsyncExtensionFunction, which we're trying to
87 // get rid of for various reasons. Please inherit from the
88 // BluetoothLowEnergyExtensionFunction class instead.
89 class BluetoothLowEnergyExtensionFunctionDeprecated
90 : public AsyncExtensionFunction {
61 public: 91 public:
62 BluetoothLowEnergyExtensionFunction(); 92 BluetoothLowEnergyExtensionFunctionDeprecated();
63 93
64 protected: 94 protected:
65 ~BluetoothLowEnergyExtensionFunction() override; 95 ~BluetoothLowEnergyExtensionFunctionDeprecated() override;
66 96
67 // ExtensionFunction override. 97 // AsyncExtensionFunction override.
68 bool RunAsync() override; 98 bool RunAsync() override;
69 99
70 // Implemented by individual bluetoothLowEnergy extension functions to perform 100 // Implemented by individual bluetoothLowEnergy extension functions to perform
71 // the body of the function. This invoked asynchonously after RunAsync after 101 // the body of the function. This invoked asynchonously after RunAsync after
72 // the BluetoothLowEnergyEventRouter has obtained a handle on the 102 // the BluetoothLowEnergyEventRouter has obtained a handle on the
73 // BluetoothAdapter. 103 // BluetoothAdapter.
74 virtual bool DoWork() = 0; 104 virtual bool DoWork() = 0;
75 105
76 private: 106 private:
107 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyExtensionFunctionDeprecated);
108 };
109
110 // Replacement for BluetoothLowEnergyExtensionFunctionDeprecated. Has the same
111 // functionality except that instead of the SendResponse/return combo, we'll
112 // return our response with Respond().
113 class BluetoothLowEnergyExtensionFunction : public UIThreadExtensionFunction {
114 public:
115 BluetoothLowEnergyExtensionFunction();
116
117 protected:
118 ~BluetoothLowEnergyExtensionFunction() override;
119
120 // ExtensionFunction override.
121 ResponseAction Run() override;
122
123 // Implemented by individual bluetoothLowEnergy extension functions to perform
124 // the body of the function. This invoked asynchonously after Run after
125 // the BluetoothLowEnergyEventRouter has obtained a handle on the
126 // BluetoothAdapter.
127 virtual void DoWork() = 0;
128
129 private:
77 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyExtensionFunction); 130 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyExtensionFunction);
78 }; 131 };
79 132
133 // Base class for bluetoothLowEnergy API peripheral mode functions. This class
134 // handles some of the common logic involved in all API peripheral mode
135 // functions, such as checking for peripheral permissions and returning the
136 // correct error.
137 template <typename Params>
138 class BLEPeripheralExtensionFunction
139 : public BluetoothLowEnergyExtensionFunction {
140 public:
141 BLEPeripheralExtensionFunction();
142
143 protected:
144 ~BLEPeripheralExtensionFunction() override;
145
146 // ExtensionFunction override.
147 ResponseAction Run() override;
148
149 // Causes link error on Windows. API will never be on Windows, so #ifdefing.
150 #if !defined(OS_WIN)
151 std::unique_ptr<Params> params_;
152 #else
153 Params* params_;
154 #endif
155
156 private:
157 DISALLOW_COPY_AND_ASSIGN(BLEPeripheralExtensionFunction);
158 };
159
80 class BluetoothLowEnergyConnectFunction 160 class BluetoothLowEnergyConnectFunction
81 : public BluetoothLowEnergyExtensionFunction { 161 : public BluetoothLowEnergyExtensionFunctionDeprecated {
82 public: 162 public:
83 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.connect", 163 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.connect",
84 BLUETOOTHLOWENERGY_CONNECT); 164 BLUETOOTHLOWENERGY_CONNECT);
85 165
86 protected: 166 protected:
87 ~BluetoothLowEnergyConnectFunction() override {} 167 ~BluetoothLowEnergyConnectFunction() override {}
88 168
89 // BluetoothLowEnergyExtensionFunction override. 169 // BluetoothLowEnergyExtensionFunctionDeprecated override.
90 bool DoWork() override; 170 bool DoWork() override;
91 171
92 private: 172 private:
93 // Success and error callbacks, called by 173 // Success and error callbacks, called by
94 // BluetoothLowEnergyEventRouter::Connect. 174 // BluetoothLowEnergyEventRouter::Connect.
95 void SuccessCallback(); 175 void SuccessCallback();
96 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); 176 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status);
97 }; 177 };
98 178
99 class BluetoothLowEnergyDisconnectFunction 179 class BluetoothLowEnergyDisconnectFunction
100 : public BluetoothLowEnergyExtensionFunction { 180 : public BluetoothLowEnergyExtensionFunctionDeprecated {
101 public: 181 public:
102 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.disconnect", 182 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.disconnect",
103 BLUETOOTHLOWENERGY_DISCONNECT); 183 BLUETOOTHLOWENERGY_DISCONNECT);
104 184
105 protected: 185 protected:
106 ~BluetoothLowEnergyDisconnectFunction() override {} 186 ~BluetoothLowEnergyDisconnectFunction() override {}
107 187
108 // BluetoothLowEnergyExtensionFunction override. 188 // BluetoothLowEnergyExtensionFunctionDeprecated override.
109 bool DoWork() override; 189 bool DoWork() override;
110 190
111 private: 191 private:
112 // Success and error callbacks, called by 192 // Success and error callbacks, called by
113 // BluetoothLowEnergyEventRouter::Disconnect. 193 // BluetoothLowEnergyEventRouter::Disconnect.
114 void SuccessCallback(); 194 void SuccessCallback();
115 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); 195 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status);
116 }; 196 };
117 197
118 class BluetoothLowEnergyGetServiceFunction 198 class BluetoothLowEnergyGetServiceFunction
119 : public BluetoothLowEnergyExtensionFunction { 199 : public BluetoothLowEnergyExtensionFunctionDeprecated {
120 public: 200 public:
121 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getService", 201 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getService",
122 BLUETOOTHLOWENERGY_GETSERVICE); 202 BLUETOOTHLOWENERGY_GETSERVICE);
123 203
124 protected: 204 protected:
125 ~BluetoothLowEnergyGetServiceFunction() override {} 205 ~BluetoothLowEnergyGetServiceFunction() override {}
126 206
127 // BluetoothLowEnergyExtensionFunction override. 207 // BluetoothLowEnergyExtensionFunctionDeprecated override.
128 bool DoWork() override; 208 bool DoWork() override;
129 }; 209 };
130 210
131 class BluetoothLowEnergyGetServicesFunction 211 class BluetoothLowEnergyGetServicesFunction
132 : public BluetoothLowEnergyExtensionFunction { 212 : public BluetoothLowEnergyExtensionFunctionDeprecated {
133 public: 213 public:
134 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getServices", 214 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getServices",
135 BLUETOOTHLOWENERGY_GETSERVICES); 215 BLUETOOTHLOWENERGY_GETSERVICES);
136 216
137 protected: 217 protected:
138 ~BluetoothLowEnergyGetServicesFunction() override {} 218 ~BluetoothLowEnergyGetServicesFunction() override {}
139 219
140 // BluetoothLowEnergyExtensionFunction override. 220 // BluetoothLowEnergyExtensionFunctionDeprecated override.
141 bool DoWork() override; 221 bool DoWork() override;
142 }; 222 };
143 223
144 class BluetoothLowEnergyGetCharacteristicFunction 224 class BluetoothLowEnergyGetCharacteristicFunction
145 : public BluetoothLowEnergyExtensionFunction { 225 : public BluetoothLowEnergyExtensionFunctionDeprecated {
146 public: 226 public:
147 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristic", 227 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristic",
148 BLUETOOTHLOWENERGY_GETCHARACTERISTIC); 228 BLUETOOTHLOWENERGY_GETCHARACTERISTIC);
149 229
150 protected: 230 protected:
151 ~BluetoothLowEnergyGetCharacteristicFunction() override {} 231 ~BluetoothLowEnergyGetCharacteristicFunction() override {}
152 232
153 // BluetoothLowEnergyExtensionFunction override. 233 // BluetoothLowEnergyExtensionFunctionDeprecated override.
154 bool DoWork() override; 234 bool DoWork() override;
155 }; 235 };
156 236
157 class BluetoothLowEnergyGetCharacteristicsFunction 237 class BluetoothLowEnergyGetCharacteristicsFunction
158 : public BluetoothLowEnergyExtensionFunction { 238 : public BluetoothLowEnergyExtensionFunctionDeprecated {
159 public: 239 public:
160 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristics", 240 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristics",
161 BLUETOOTHLOWENERGY_GETCHARACTERISTICS); 241 BLUETOOTHLOWENERGY_GETCHARACTERISTICS);
162 242
163 protected: 243 protected:
164 ~BluetoothLowEnergyGetCharacteristicsFunction() override {} 244 ~BluetoothLowEnergyGetCharacteristicsFunction() override {}
165 245
166 // BluetoothLowEnergyExtensionFunction override. 246 // BluetoothLowEnergyExtensionFunctionDeprecated override.
167 bool DoWork() override; 247 bool DoWork() override;
168 }; 248 };
169 249
170 class BluetoothLowEnergyGetIncludedServicesFunction 250 class BluetoothLowEnergyGetIncludedServicesFunction
171 : public BluetoothLowEnergyExtensionFunction { 251 : public BluetoothLowEnergyExtensionFunctionDeprecated {
172 public: 252 public:
173 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getIncludedServices", 253 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getIncludedServices",
174 BLUETOOTHLOWENERGY_GETINCLUDEDSERVICES); 254 BLUETOOTHLOWENERGY_GETINCLUDEDSERVICES);
175 255
176 protected: 256 protected:
177 ~BluetoothLowEnergyGetIncludedServicesFunction() override {} 257 ~BluetoothLowEnergyGetIncludedServicesFunction() override {}
178 258
179 // BluetoothLowEnergyExtensionFunction override. 259 // BluetoothLowEnergyExtensionFunctionDeprecated override.
180 bool DoWork() override; 260 bool DoWork() override;
181 }; 261 };
182 262
183 class BluetoothLowEnergyGetDescriptorFunction 263 class BluetoothLowEnergyGetDescriptorFunction
184 : public BluetoothLowEnergyExtensionFunction { 264 : public BluetoothLowEnergyExtensionFunctionDeprecated {
185 public: 265 public:
186 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptor", 266 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptor",
187 BLUETOOTHLOWENERGY_GETDESCRIPTOR); 267 BLUETOOTHLOWENERGY_GETDESCRIPTOR);
188 268
189 protected: 269 protected:
190 ~BluetoothLowEnergyGetDescriptorFunction() override {} 270 ~BluetoothLowEnergyGetDescriptorFunction() override {}
191 271
192 // BluetoothLowEnergyExtensionFunction override. 272 // BluetoothLowEnergyExtensionFunctionDeprecated override.
193 bool DoWork() override; 273 bool DoWork() override;
194 }; 274 };
195 275
196 class BluetoothLowEnergyGetDescriptorsFunction 276 class BluetoothLowEnergyGetDescriptorsFunction
197 : public BluetoothLowEnergyExtensionFunction { 277 : public BluetoothLowEnergyExtensionFunctionDeprecated {
198 public: 278 public:
199 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptors", 279 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptors",
200 BLUETOOTHLOWENERGY_GETDESCRIPTORS); 280 BLUETOOTHLOWENERGY_GETDESCRIPTORS);
201 281
202 protected: 282 protected:
203 ~BluetoothLowEnergyGetDescriptorsFunction() override {} 283 ~BluetoothLowEnergyGetDescriptorsFunction() override {}
204 284
205 // BluetoothLowEnergyExtensionFunction override. 285 // BluetoothLowEnergyExtensionFunctionDeprecated override.
206 bool DoWork() override; 286 bool DoWork() override;
207 }; 287 };
208 288
209 class BluetoothLowEnergyReadCharacteristicValueFunction 289 class BluetoothLowEnergyReadCharacteristicValueFunction
210 : public BluetoothLowEnergyExtensionFunction { 290 : public BluetoothLowEnergyExtensionFunctionDeprecated {
211 public: 291 public:
212 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readCharacteristicValue", 292 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readCharacteristicValue",
213 BLUETOOTHLOWENERGY_READCHARACTERISTICVALUE); 293 BLUETOOTHLOWENERGY_READCHARACTERISTICVALUE);
214 294
215 protected: 295 protected:
216 ~BluetoothLowEnergyReadCharacteristicValueFunction() override {} 296 ~BluetoothLowEnergyReadCharacteristicValueFunction() override {}
217 297
218 // BluetoothLowEnergyExtensionFunction override. 298 // BluetoothLowEnergyExtensionFunctionDeprecated override.
219 bool DoWork() override; 299 bool DoWork() override;
220 300
221 private: 301 private:
222 // Success and error callbacks, called by 302 // Success and error callbacks, called by
223 // BluetoothLowEnergyEventRouter::ReadCharacteristicValue. 303 // BluetoothLowEnergyEventRouter::ReadCharacteristicValue.
224 void SuccessCallback(); 304 void SuccessCallback();
225 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); 305 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status);
226 306
227 // The instance ID of the requested characteristic. 307 // The instance ID of the requested characteristic.
228 std::string instance_id_; 308 std::string instance_id_;
229 }; 309 };
230 310
231 class BluetoothLowEnergyWriteCharacteristicValueFunction 311 class BluetoothLowEnergyWriteCharacteristicValueFunction
232 : public BluetoothLowEnergyExtensionFunction { 312 : public BluetoothLowEnergyExtensionFunctionDeprecated {
233 public: 313 public:
234 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeCharacteristicValue", 314 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeCharacteristicValue",
235 BLUETOOTHLOWENERGY_WRITECHARACTERISTICVALUE); 315 BLUETOOTHLOWENERGY_WRITECHARACTERISTICVALUE);
236 316
237 protected: 317 protected:
238 ~BluetoothLowEnergyWriteCharacteristicValueFunction() override {} 318 ~BluetoothLowEnergyWriteCharacteristicValueFunction() override {}
239 319
240 // BluetoothLowEnergyExtensionFunction override. 320 // BluetoothLowEnergyExtensionFunctionDeprecated override.
241 bool DoWork() override; 321 bool DoWork() override;
242 322
243 private: 323 private:
244 // Success and error callbacks, called by 324 // Success and error callbacks, called by
245 // BluetoothLowEnergyEventRouter::WriteCharacteristicValue. 325 // BluetoothLowEnergyEventRouter::WriteCharacteristicValue.
246 void SuccessCallback(); 326 void SuccessCallback();
247 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); 327 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status);
248 328
249 // The instance ID of the requested characteristic. 329 // The instance ID of the requested characteristic.
250 std::string instance_id_; 330 std::string instance_id_;
251 }; 331 };
252 332
253 class BluetoothLowEnergyStartCharacteristicNotificationsFunction 333 class BluetoothLowEnergyStartCharacteristicNotificationsFunction
254 : public BluetoothLowEnergyExtensionFunction { 334 : public BluetoothLowEnergyExtensionFunctionDeprecated {
255 public: 335 public:
256 DECLARE_EXTENSION_FUNCTION( 336 DECLARE_EXTENSION_FUNCTION(
257 "bluetoothLowEnergy.startCharacteristicNotifications", 337 "bluetoothLowEnergy.startCharacteristicNotifications",
258 BLUETOOTHLOWENERGY_STARTCHARACTERISTICNOTIFICATIONS); 338 BLUETOOTHLOWENERGY_STARTCHARACTERISTICNOTIFICATIONS);
259 339
260 protected: 340 protected:
261 ~BluetoothLowEnergyStartCharacteristicNotificationsFunction() override {} 341 ~BluetoothLowEnergyStartCharacteristicNotificationsFunction() override {}
262 342
263 // BluetoothLowEnergyExtensionFunction override. 343 // BluetoothLowEnergyExtensionFunctionDeprecated override.
264 bool DoWork() override; 344 bool DoWork() override;
265 345
266 private: 346 private:
267 // Success and error callbacks, called by 347 // Success and error callbacks, called by
268 // BluetoothLowEnergyEventRouter::StartCharacteristicNotifications. 348 // BluetoothLowEnergyEventRouter::StartCharacteristicNotifications.
269 void SuccessCallback(); 349 void SuccessCallback();
270 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); 350 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status);
271 }; 351 };
272 352
273 class BluetoothLowEnergyStopCharacteristicNotificationsFunction 353 class BluetoothLowEnergyStopCharacteristicNotificationsFunction
274 : public BluetoothLowEnergyExtensionFunction { 354 : public BluetoothLowEnergyExtensionFunctionDeprecated {
275 public: 355 public:
276 DECLARE_EXTENSION_FUNCTION( 356 DECLARE_EXTENSION_FUNCTION(
277 "bluetoothLowEnergy.stopCharacteristicNotifications", 357 "bluetoothLowEnergy.stopCharacteristicNotifications",
278 BLUETOOTHLOWENERGY_STOPCHARACTERISTICNOTIFICATIONS); 358 BLUETOOTHLOWENERGY_STOPCHARACTERISTICNOTIFICATIONS);
279 359
280 protected: 360 protected:
281 ~BluetoothLowEnergyStopCharacteristicNotificationsFunction() override {} 361 ~BluetoothLowEnergyStopCharacteristicNotificationsFunction() override {}
282 362
283 // BluetoothLowEnergyExtensionFunction override. 363 // BluetoothLowEnergyExtensionFunctionDeprecated override.
284 bool DoWork() override; 364 bool DoWork() override;
285 365
286 private: 366 private:
287 // Success and error callbacks, called by 367 // Success and error callbacks, called by
288 // BluetoothLowEnergyEventRouter::StopCharacteristicNotifications. 368 // BluetoothLowEnergyEventRouter::StopCharacteristicNotifications.
289 void SuccessCallback(); 369 void SuccessCallback();
290 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); 370 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status);
291 }; 371 };
292 372
293 class BluetoothLowEnergyReadDescriptorValueFunction 373 class BluetoothLowEnergyReadDescriptorValueFunction
294 : public BluetoothLowEnergyExtensionFunction { 374 : public BluetoothLowEnergyExtensionFunctionDeprecated {
295 public: 375 public:
296 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readDescriptorValue", 376 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readDescriptorValue",
297 BLUETOOTHLOWENERGY_READDESCRIPTORVALUE); 377 BLUETOOTHLOWENERGY_READDESCRIPTORVALUE);
298 378
299 protected: 379 protected:
300 ~BluetoothLowEnergyReadDescriptorValueFunction() override {} 380 ~BluetoothLowEnergyReadDescriptorValueFunction() override {}
301 381
302 // BluetoothLowEnergyExtensionFunction override. 382 // BluetoothLowEnergyExtensionFunctionDeprecated override.
303 bool DoWork() override; 383 bool DoWork() override;
304 384
305 private: 385 private:
306 // Success and error callbacks, called by 386 // Success and error callbacks, called by
307 // BluetoothLowEnergyEventRouter::ReadDescriptorValue. 387 // BluetoothLowEnergyEventRouter::ReadDescriptorValue.
308 void SuccessCallback(); 388 void SuccessCallback();
309 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); 389 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status);
310 390
311 // The instance ID of the requested descriptor. 391 // The instance ID of the requested descriptor.
312 std::string instance_id_; 392 std::string instance_id_;
313 }; 393 };
314 394
315 class BluetoothLowEnergyWriteDescriptorValueFunction 395 class BluetoothLowEnergyWriteDescriptorValueFunction
316 : public BluetoothLowEnergyExtensionFunction { 396 : public BluetoothLowEnergyExtensionFunctionDeprecated {
317 public: 397 public:
318 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeDescriptorValue", 398 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeDescriptorValue",
319 BLUETOOTHLOWENERGY_WRITEDESCRIPTORVALUE); 399 BLUETOOTHLOWENERGY_WRITEDESCRIPTORVALUE);
320 400
321 protected: 401 protected:
322 ~BluetoothLowEnergyWriteDescriptorValueFunction() override {} 402 ~BluetoothLowEnergyWriteDescriptorValueFunction() override {}
323 403
324 // BluetoothLowEnergyExtensionFunction override. 404 // BluetoothLowEnergyExtensionFunctionDeprecated override.
325 bool DoWork() override; 405 bool DoWork() override;
326 406
327 private: 407 private:
328 // Success and error callbacks, called by 408 // Success and error callbacks, called by
329 // BluetoothLowEnergyEventRouter::WriteDescriptorValue. 409 // BluetoothLowEnergyEventRouter::WriteDescriptorValue.
330 void SuccessCallback(); 410 void SuccessCallback();
331 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); 411 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status);
332 412
333 // The instance ID of the requested descriptor. 413 // The instance ID of the requested descriptor.
334 std::string instance_id_; 414 std::string instance_id_;
335 }; 415 };
336 416
337 class BluetoothLowEnergyAdvertisementFunction 417 class BluetoothLowEnergyAdvertisementFunction
338 : public BluetoothLowEnergyExtensionFunction { 418 : public BluetoothLowEnergyExtensionFunctionDeprecated {
339 public: 419 public:
340 BluetoothLowEnergyAdvertisementFunction(); 420 BluetoothLowEnergyAdvertisementFunction();
341 421
342 protected: 422 protected:
343 ~BluetoothLowEnergyAdvertisementFunction() override; 423 ~BluetoothLowEnergyAdvertisementFunction() override;
344 424
345 // Takes ownership. 425 // Takes ownership.
346 int AddAdvertisement(BluetoothApiAdvertisement* advertisement); 426 int AddAdvertisement(BluetoothApiAdvertisement* advertisement);
347 BluetoothApiAdvertisement* GetAdvertisement(int advertisement_id); 427 BluetoothApiAdvertisement* GetAdvertisement(int advertisement_id);
348 void RemoveAdvertisement(int advertisement_id); 428 void RemoveAdvertisement(int advertisement_id);
(...skipping 11 matching lines...) Expand all
360 440
361 class BluetoothLowEnergyRegisterAdvertisementFunction 441 class BluetoothLowEnergyRegisterAdvertisementFunction
362 : public BluetoothLowEnergyAdvertisementFunction { 442 : public BluetoothLowEnergyAdvertisementFunction {
363 public: 443 public:
364 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.registerAdvertisement", 444 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.registerAdvertisement",
365 BLUETOOTHLOWENERGY_REGISTERADVERTISEMENT); 445 BLUETOOTHLOWENERGY_REGISTERADVERTISEMENT);
366 446
367 protected: 447 protected:
368 ~BluetoothLowEnergyRegisterAdvertisementFunction() override {} 448 ~BluetoothLowEnergyRegisterAdvertisementFunction() override {}
369 449
370 // BluetoothLowEnergyExtensionFunction override. 450 // BluetoothLowEnergyExtensionFunctionDeprecated override.
371 bool DoWork() override; 451 bool DoWork() override;
372 452
373 private: 453 private:
374 void SuccessCallback(scoped_refptr<device::BluetoothAdvertisement>); 454 void SuccessCallback(scoped_refptr<device::BluetoothAdvertisement>);
375 void ErrorCallback(device::BluetoothAdvertisement::ErrorCode status); 455 void ErrorCallback(device::BluetoothAdvertisement::ErrorCode status);
376 456
377 // The instance ID of the requested descriptor. 457 // The instance ID of the requested descriptor.
378 std::string instance_id_; 458 std::string instance_id_;
379 }; 459 };
380 460
381 class BluetoothLowEnergyUnregisterAdvertisementFunction 461 class BluetoothLowEnergyUnregisterAdvertisementFunction
382 : public BluetoothLowEnergyAdvertisementFunction { 462 : public BluetoothLowEnergyAdvertisementFunction {
383 public: 463 public:
384 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.unregisterAdvertisement", 464 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.unregisterAdvertisement",
385 BLUETOOTHLOWENERGY_UNREGISTERADVERTISEMENT); 465 BLUETOOTHLOWENERGY_UNREGISTERADVERTISEMENT);
386 466
387 protected: 467 protected:
388 ~BluetoothLowEnergyUnregisterAdvertisementFunction() override {} 468 ~BluetoothLowEnergyUnregisterAdvertisementFunction() override {}
389 469
390 // BluetoothLowEnergyExtensionFunction override. 470 // BluetoothLowEnergyExtensionFunctionDeprecated override.
391 bool DoWork() override; 471 bool DoWork() override;
392 472
393 private: 473 private:
394 void SuccessCallback(int advertisement_id); 474 void SuccessCallback(int advertisement_id);
395 void ErrorCallback(int advertisement_id, 475 void ErrorCallback(int advertisement_id,
396 device::BluetoothAdvertisement::ErrorCode status); 476 device::BluetoothAdvertisement::ErrorCode status);
397 477
398 // The instance ID of the requested descriptor. 478 // The instance ID of the requested descriptor.
399 std::string instance_id_; 479 std::string instance_id_;
400 }; 480 };
401 481
482 class BluetoothLowEnergyCreateServiceFunction
483 : public BLEPeripheralExtensionFunction<
484 extensions::api::bluetooth_low_energy::CreateService::Params> {
485 public:
486 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.createService",
487 BLUETOOTHLOWENERGY_CREATESERVICE);
488
489 protected:
490 ~BluetoothLowEnergyCreateServiceFunction() override {}
491
492 // BluetoothLowEnergyPeripheralExtensionFunction override.
493 void DoWork() override;
494 };
495
496 class BluetoothLowEnergyCreateCharacteristicFunction
497 : public BLEPeripheralExtensionFunction<
498 extensions::api::bluetooth_low_energy::CreateCharacteristic::Params> {
499 public:
500 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.createCharacteristic",
501 BLUETOOTHLOWENERGY_CREATECHARACTERISTIC);
502
503 protected:
504 ~BluetoothLowEnergyCreateCharacteristicFunction() override {}
505
506 // BluetoothLowEnergyPeripheralExtensionFunction override.
507 void DoWork() override;
508 };
509
510 class BluetoothLowEnergyCreateDescriptorFunction
511 : public BLEPeripheralExtensionFunction<
512 extensions::api::bluetooth_low_energy::CreateDescriptor::Params> {
513 public:
514 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.createDescriptor",
515 BLUETOOTHLOWENERGY_CREATEDESCRIPTOR);
516
517 protected:
518 ~BluetoothLowEnergyCreateDescriptorFunction() override {}
519
520 // BluetoothLowEnergyPeripheralExtensionFunction override.
521 void DoWork() override;
522 };
523
524 class BluetoothLowEnergyRegisterServiceFunction
525 : public BLEPeripheralExtensionFunction<
526 extensions::api::bluetooth_low_energy::RegisterService::Params> {
527 public:
528 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.registerService",
529 BLUETOOTHLOWENERGY_REGISTERSERVICE);
530
531 protected:
532 ~BluetoothLowEnergyRegisterServiceFunction() override {}
533
534 // BluetoothLowEnergyPeripheralExtensionFunction override.
535 void DoWork() override;
536 };
537
538 class BluetoothLowEnergyUnregisterServiceFunction
539 : public BLEPeripheralExtensionFunction<
540 extensions::api::bluetooth_low_energy::UnregisterService::Params> {
541 public:
542 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.unregisterService",
543 BLUETOOTHLOWENERGY_UNREGISTERSERVICE);
544
545 protected:
546 ~BluetoothLowEnergyUnregisterServiceFunction() override {}
547
548 // BluetoothLowEnergyPeripheralExtensionFunction override.
549 void DoWork() override;
550 };
551
552 class BluetoothLowEnergySendRequestResponseFunction
553 : public BLEPeripheralExtensionFunction<
554 extensions::api::bluetooth_low_energy::SendRequestResponse::Params> {
555 public:
556 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.sendRequestResponse",
557 BLUETOOTHLOWENERGY_SENDREQUESTRESPONSE);
558
559 protected:
560 ~BluetoothLowEnergySendRequestResponseFunction() override {}
561
562 // BluetoothLowEnergyPeripheralExtensionFunction override.
563 void DoWork() override;
564 };
565
402 } // namespace api 566 } // namespace api
403 } // namespace extensions 567 } // namespace extensions
404 568
405 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENER GY_API_H_ 569 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENER GY_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698