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

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

Issue 1919683002: Adapter changes for implementing local GATT attributes and tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dbus_classes
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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_ADAPTER_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <utility> 14 #include <utility>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/containers/scoped_ptr_hash_map.h" 18 #include "base/containers/scoped_ptr_hash_map.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
21 #include "build/build_config.h" 21 #include "build/build_config.h"
22 #include "device/bluetooth/bluetooth_advertisement.h" 22 #include "device/bluetooth/bluetooth_advertisement.h"
23 #include "device/bluetooth/bluetooth_audio_sink.h" 23 #include "device/bluetooth/bluetooth_audio_sink.h"
24 #include "device/bluetooth/bluetooth_device.h" 24 #include "device/bluetooth/bluetooth_device.h"
25 #include "device/bluetooth/bluetooth_export.h" 25 #include "device/bluetooth/bluetooth_export.h"
26 #include "device/bluetooth/bluetooth_local_gatt_service.h"
26 27
27 namespace device { 28 namespace device {
28 29
29 class BluetoothAdvertisement; 30 class BluetoothAdvertisement;
30 class BluetoothDiscoveryFilter; 31 class BluetoothDiscoveryFilter;
31 class BluetoothDiscoverySession; 32 class BluetoothDiscoverySession;
32 class BluetoothRemoteGattCharacteristic; 33 class BluetoothRemoteGattCharacteristic;
33 class BluetoothRemoteGattDescriptor; 34 class BluetoothRemoteGattDescriptor;
34 class BluetoothRemoteGattService; 35 class BluetoothRemoteGattService;
35 class BluetoothSocket; 36 class BluetoothSocket;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 ServiceOptions(); 200 ServiceOptions();
200 ~ServiceOptions(); 201 ~ServiceOptions();
201 202
202 std::unique_ptr<int> channel; 203 std::unique_ptr<int> channel;
203 std::unique_ptr<int> psm; 204 std::unique_ptr<int> psm;
204 std::unique_ptr<std::string> name; 205 std::unique_ptr<std::string> name;
205 }; 206 };
206 207
207 // The ErrorCallback is used for methods that can fail in which case it is 208 // The ErrorCallback is used for methods that can fail in which case it is
208 // called, in the success case the callback is simply not called. 209 // called, in the success case the callback is simply not called.
209 typedef base::Closure ErrorCallback; 210 using ErrorCallback = base::Closure;
210 211
211 // The InitCallback is used to trigger a callback after asynchronous 212 // The InitCallback is used to trigger a callback after asynchronous
212 // initialization, if initialization is asynchronous on the platform. 213 // initialization, if initialization is asynchronous on the platform.
213 typedef base::Callback<void()> InitCallback; 214 using InitCallback = base::Callback<void()>;
214 215
215 typedef base::Callback<void(std::unique_ptr<BluetoothDiscoverySession>)> 216 using DiscoverySessionCallback =
216 DiscoverySessionCallback; 217 base::Callback<void(std::unique_ptr<BluetoothDiscoverySession>)>;
217 typedef std::vector<BluetoothDevice*> DeviceList; 218 using DeviceList = std::vector<BluetoothDevice*>;
218 typedef std::vector<const BluetoothDevice*> ConstDeviceList; 219 using ConstDeviceList = std::vector<const BluetoothDevice*>;
219 typedef std::vector<BluetoothUUID> UUIDList; 220 using UUIDList = std::vector<BluetoothUUID>;
220 typedef base::Callback<void(scoped_refptr<BluetoothSocket>)> 221 using CreateServiceCallback =
221 CreateServiceCallback; 222 base::Callback<void(scoped_refptr<BluetoothSocket>)>;
222 typedef base::Callback<void(const std::string& message)> 223 using CreateServiceErrorCallback =
223 CreateServiceErrorCallback; 224 base::Callback<void(const std::string& message)>;
224 typedef base::Callback<void(scoped_refptr<BluetoothAudioSink>)> 225 using AcquiredCallback =
225 AcquiredCallback; 226 base::Callback<void(scoped_refptr<BluetoothAudioSink>)>;
226 typedef base::Callback<void(scoped_refptr<BluetoothAdvertisement>)> 227 using CreateAdvertisementCallback =
227 CreateAdvertisementCallback; 228 base::Callback<void(scoped_refptr<BluetoothAdvertisement>)>;
228 typedef base::Callback<void(BluetoothAdvertisement::ErrorCode)> 229 using CreateAdvertisementErrorCallback =
229 CreateAdvertisementErrorCallback; 230 base::Callback<void(BluetoothAdvertisement::ErrorCode)>;
230 231
231 // Returns a weak pointer to a new adapter. For platforms with asynchronous 232 // Returns a weak pointer to a new adapter. For platforms with asynchronous
232 // initialization, the returned adapter will run the |init_callback| once 233 // initialization, the returned adapter will run the |init_callback| once
233 // asynchronous initialization is complete. 234 // asynchronous initialization is complete.
234 // Caution: The returned pointer also transfers ownership of the adapter. The 235 // Caution: The returned pointer also transfers ownership of the adapter. The
235 // caller is expected to call |AddRef()| on the returned pointer, typically by 236 // caller is expected to call |AddRef()| on the returned pointer, typically by
236 // storing it into a |scoped_refptr|. 237 // storing it into a |scoped_refptr|.
237 static base::WeakPtr<BluetoothAdapter> CreateAdapter( 238 static base::WeakPtr<BluetoothAdapter> CreateAdapter(
238 const InitCallback& init_callback); 239 const InitCallback& init_callback);
239 240
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 // |options| are not specified, the default values will be used. |callback| 406 // |options| are not specified, the default values will be used. |callback|
406 // will be called on success with a BluetoothAudioSink which is to be owned by 407 // will be called on success with a BluetoothAudioSink which is to be owned by
407 // the caller of this method. |error_callback| will be called on failure with 408 // the caller of this method. |error_callback| will be called on failure with
408 // a message indicating the cause. 409 // a message indicating the cause.
409 virtual void RegisterAudioSink( 410 virtual void RegisterAudioSink(
410 const BluetoothAudioSink::Options& options, 411 const BluetoothAudioSink::Options& options,
411 const AcquiredCallback& callback, 412 const AcquiredCallback& callback,
412 const BluetoothAudioSink::ErrorCallback& error_callback) = 0; 413 const BluetoothAudioSink::ErrorCallback& error_callback) = 0;
413 414
414 // Creates and registers an advertisement for broadcast over the LE channel. 415 // Creates and registers an advertisement for broadcast over the LE channel.
415 // The created advertisement will be returned via the success callback. 416 // The created advertisement will be returned via the success callback. An
417 // advertisement can unregister itself at any time by calling its unregister
418 // function.
416 virtual void RegisterAdvertisement( 419 virtual void RegisterAdvertisement(
417 std::unique_ptr<BluetoothAdvertisement::Data> advertisement_data, 420 std::unique_ptr<BluetoothAdvertisement::Data> advertisement_data,
418 const CreateAdvertisementCallback& callback, 421 const CreateAdvertisementCallback& callback,
419 const CreateAdvertisementErrorCallback& error_callback) = 0; 422 const CreateAdvertisementErrorCallback& error_callback) = 0;
420 423
421 // The following methods are used to send various events to observers. 424 // The following methods are used to send various events to observers.
422 void NotifyAdapterStateChanged(bool powered); 425 void NotifyAdapterStateChanged(bool powered);
423 #if defined(OS_CHROMEOS) || defined(OS_LINUX) 426 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
424 // This function is implemented for ChromeOS only, and the support on 427 // This function is implemented for ChromeOS only, and the support on
425 // Android, MaxOS and Windows should be added on demand in the future. 428 // Android, MaxOS and Windows should be added on demand in the future.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 std::set<BluetoothDiscoverySession*> discovery_sessions_; 578 std::set<BluetoothDiscoverySession*> discovery_sessions_;
576 579
577 // Note: This should remain the last member so it'll be destroyed and 580 // Note: This should remain the last member so it'll be destroyed and
578 // invalidate its weak pointers before any other members are destroyed. 581 // invalidate its weak pointers before any other members are destroyed.
579 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_; 582 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_;
580 }; 583 };
581 584
582 } // namespace device 585 } // namespace device
583 586
584 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ 587 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698