OLD | NEW |
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 "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
23 #include "device/bluetooth/bluetooth_advertisement.h" | 23 #include "device/bluetooth/bluetooth_advertisement.h" |
24 #include "device/bluetooth/bluetooth_audio_sink.h" | |
25 #include "device/bluetooth/bluetooth_device.h" | 24 #include "device/bluetooth/bluetooth_device.h" |
26 #include "device/bluetooth/bluetooth_export.h" | 25 #include "device/bluetooth/bluetooth_export.h" |
27 | 26 |
28 namespace device { | 27 namespace device { |
29 | 28 |
30 class BluetoothAdvertisement; | 29 class BluetoothAdvertisement; |
31 class BluetoothDiscoveryFilter; | 30 class BluetoothDiscoveryFilter; |
32 class BluetoothDiscoverySession; | 31 class BluetoothDiscoverySession; |
33 class BluetoothLocalGattService; | 32 class BluetoothLocalGattService; |
34 class BluetoothRemoteGattCharacteristic; | 33 class BluetoothRemoteGattCharacteristic; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 233 |
235 using DiscoverySessionCallback = | 234 using DiscoverySessionCallback = |
236 base::Callback<void(std::unique_ptr<BluetoothDiscoverySession>)>; | 235 base::Callback<void(std::unique_ptr<BluetoothDiscoverySession>)>; |
237 using DeviceList = std::vector<BluetoothDevice*>; | 236 using DeviceList = std::vector<BluetoothDevice*>; |
238 using ConstDeviceList = std::vector<const BluetoothDevice*>; | 237 using ConstDeviceList = std::vector<const BluetoothDevice*>; |
239 using UUIDList = std::vector<BluetoothUUID>; | 238 using UUIDList = std::vector<BluetoothUUID>; |
240 using CreateServiceCallback = | 239 using CreateServiceCallback = |
241 base::Callback<void(scoped_refptr<BluetoothSocket>)>; | 240 base::Callback<void(scoped_refptr<BluetoothSocket>)>; |
242 using CreateServiceErrorCallback = | 241 using CreateServiceErrorCallback = |
243 base::Callback<void(const std::string& message)>; | 242 base::Callback<void(const std::string& message)>; |
244 using AcquiredCallback = | |
245 base::Callback<void(scoped_refptr<BluetoothAudioSink>)>; | |
246 using CreateAdvertisementCallback = | 243 using CreateAdvertisementCallback = |
247 base::Callback<void(scoped_refptr<BluetoothAdvertisement>)>; | 244 base::Callback<void(scoped_refptr<BluetoothAdvertisement>)>; |
248 using AdvertisementErrorCallback = | 245 using AdvertisementErrorCallback = |
249 base::Callback<void(BluetoothAdvertisement::ErrorCode)>; | 246 base::Callback<void(BluetoothAdvertisement::ErrorCode)>; |
250 | 247 |
251 // Returns a weak pointer to a new adapter. For platforms with asynchronous | 248 // Returns a weak pointer to a new adapter. For platforms with asynchronous |
252 // initialization, the returned adapter will run the |init_callback| once | 249 // initialization, the returned adapter will run the |init_callback| once |
253 // asynchronous initialization is complete. | 250 // asynchronous initialization is complete. |
254 // Caution: The returned pointer also transfers ownership of the adapter. The | 251 // Caution: The returned pointer also transfers ownership of the adapter. The |
255 // caller is expected to call |AddRef()| on the returned pointer, typically by | 252 // caller is expected to call |AddRef()| on the returned pointer, typically by |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 // English name of the service. |callback| will be called on success with a | 412 // English name of the service. |callback| will be called on success with a |
416 // BluetoothSocket instance that is to be owned by the received. | 413 // BluetoothSocket instance that is to be owned by the received. |
417 // |error_callback| will be called on failure with a message indicating the | 414 // |error_callback| will be called on failure with a message indicating the |
418 // cause. | 415 // cause. |
419 virtual void CreateL2capService( | 416 virtual void CreateL2capService( |
420 const BluetoothUUID& uuid, | 417 const BluetoothUUID& uuid, |
421 const ServiceOptions& options, | 418 const ServiceOptions& options, |
422 const CreateServiceCallback& callback, | 419 const CreateServiceCallback& callback, |
423 const CreateServiceErrorCallback& error_callback) = 0; | 420 const CreateServiceErrorCallback& error_callback) = 0; |
424 | 421 |
425 // Creates and registers a BluetoothAudioSink with |options|. If the fields in | |
426 // |options| are not specified, the default values will be used. |callback| | |
427 // will be called on success with a BluetoothAudioSink which is to be owned by | |
428 // the caller of this method. |error_callback| will be called on failure with | |
429 // a message indicating the cause. | |
430 virtual void RegisterAudioSink( | |
431 const BluetoothAudioSink::Options& options, | |
432 const AcquiredCallback& callback, | |
433 const BluetoothAudioSink::ErrorCallback& error_callback) = 0; | |
434 | |
435 // Creates and registers an advertisement for broadcast over the LE channel. | 422 // Creates and registers an advertisement for broadcast over the LE channel. |
436 // The created advertisement will be returned via the success callback. An | 423 // The created advertisement will be returned via the success callback. An |
437 // advertisement can unregister itself at any time by calling its unregister | 424 // advertisement can unregister itself at any time by calling its unregister |
438 // function. | 425 // function. |
439 virtual void RegisterAdvertisement( | 426 virtual void RegisterAdvertisement( |
440 std::unique_ptr<BluetoothAdvertisement::Data> advertisement_data, | 427 std::unique_ptr<BluetoothAdvertisement::Data> advertisement_data, |
441 const CreateAdvertisementCallback& callback, | 428 const CreateAdvertisementCallback& callback, |
442 const AdvertisementErrorCallback& error_callback) = 0; | 429 const AdvertisementErrorCallback& error_callback) = 0; |
443 | 430 |
444 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | 431 #if defined(OS_CHROMEOS) || defined(OS_LINUX) |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 std::set<BluetoothDiscoverySession*> discovery_sessions_; | 611 std::set<BluetoothDiscoverySession*> discovery_sessions_; |
625 | 612 |
626 // Note: This should remain the last member so it'll be destroyed and | 613 // Note: This should remain the last member so it'll be destroyed and |
627 // invalidate its weak pointers before any other members are destroyed. | 614 // invalidate its weak pointers before any other members are destroyed. |
628 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_; | 615 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_; |
629 }; | 616 }; |
630 | 617 |
631 } // namespace device | 618 } // namespace device |
632 | 619 |
633 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ | 620 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
OLD | NEW |