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

Side by Side Diff: device/bluetooth/bluetooth_gatt_service.h

Issue 1872943002: Add support for local services/characteristics/descriptors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "device/bluetooth/bluetooth_export.h" 15 #include "device/bluetooth/bluetooth_export.h"
15 #include "device/bluetooth/bluetooth_uuid.h" 16 #include "device/bluetooth/bluetooth_uuid.h"
16 17
17 namespace device { 18 namespace device {
18 19
19 class BluetoothDevice; 20 class BluetoothDevice;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 GATT_ERROR_FAILED, 136 GATT_ERROR_FAILED,
136 GATT_ERROR_IN_PROGRESS, 137 GATT_ERROR_IN_PROGRESS,
137 GATT_ERROR_INVALID_LENGTH, 138 GATT_ERROR_INVALID_LENGTH,
138 GATT_ERROR_NOT_PERMITTED, 139 GATT_ERROR_NOT_PERMITTED,
139 GATT_ERROR_NOT_AUTHORIZED, 140 GATT_ERROR_NOT_AUTHORIZED,
140 GATT_ERROR_NOT_PAIRED, 141 GATT_ERROR_NOT_PAIRED,
141 GATT_ERROR_NOT_SUPPORTED 142 GATT_ERROR_NOT_SUPPORTED
142 }; 143 };
143 144
144 // The ErrorCallback is used by methods to asynchronously report errors. 145 // The ErrorCallback is used by methods to asynchronously report errors.
145 typedef base::Closure ErrorCallback; 146 using ErrorCallback = base::Callback<void(GattErrorCode error_code)>;
146 147
147 virtual ~BluetoothGattService(); 148 virtual ~BluetoothGattService();
148 149
149 // Constructs a BluetoothGattService that can be locally hosted when the local 150 // Constructs a BluetoothGattService that can be locally hosted when the local
150 // adapter is in the peripheral role. The resulting object can then be made 151 // adapter is in the peripheral role. The resulting object can then be made
151 // available by calling the "Register" method. This method constructs a 152 // available by calling the "Register" method. This method constructs a
152 // service with UUID |uuid|. Whether the constructed service is primary or 153 // service with UUID |uuid|. Whether the constructed service is primary or
153 // secondary is determined by |is_primary|. |delegate| is used to send certain 154 // secondary is determined by |is_primary|. |delegate| is used to send certain
154 // peripheral role events. If |delegate| is NULL, then this service will 155 // peripheral role events. If |delegate| is NULL, then this service will
155 // employ a default behavior when responding to read and write requests based 156 // employ a default behavior when responding to read and write requests based
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 209
209 // Registers this GATT service. Calling Register will make this service and 210 // Registers this GATT service. Calling Register will make this service and
210 // all of its associated attributes available on the local adapters GATT 211 // all of its associated attributes available on the local adapters GATT
211 // database and the service UUID will be advertised to nearby devices if the 212 // database and the service UUID will be advertised to nearby devices if the
212 // local adapter is discoverable. Call Unregister to make this service no 213 // local adapter is discoverable. Call Unregister to make this service no
213 // longer available. 214 // longer available.
214 // 215 //
215 // These methods only make sense for services that are local and will hence 216 // These methods only make sense for services that are local and will hence
216 // fail if this instance represents a remote GATT service. |callback| is 217 // fail if this instance represents a remote GATT service. |callback| is
217 // called to denote success and |error_callback| to denote failure. 218 // called to denote success and |error_callback| to denote failure.
218 virtual void Register(const base::Closure& callback, 219 virtual void Register(const base::Closure& callback,
ortuno 2016/04/14 17:42:35 I thought these were going to be moved to the adap
rkc 2016/04/14 19:27:27 All in good time. This is a refactor. The purpose
219 const ErrorCallback& error_callback) = 0; 220 const ErrorCallback& error_callback) = 0;
220 virtual void Unregister(const base::Closure& callback, 221 virtual void Unregister(const base::Closure& callback,
221 const ErrorCallback& error_callback) = 0; 222 const ErrorCallback& error_callback) = 0;
222 223
223 protected: 224 protected:
224 BluetoothGattService(); 225 BluetoothGattService();
225 226
226 private: 227 private:
227 DISALLOW_COPY_AND_ASSIGN(BluetoothGattService); 228 DISALLOW_COPY_AND_ASSIGN(BluetoothGattService);
228 }; 229 };
229 230
230 } // namespace device 231 } // namespace device
231 232
232 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_ 233 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698