Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_H_ |
| 6 | #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 10 | #include "base/callback.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 11 | #include "base/memory/ref_counted.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 12 | #include "device/bluetooth/bluetooth_adapter.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 13 | |
| 14 | namespace device { |
| 15 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 16 | // BluetoothAdapterFactory is a class that contains static methods, which |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 17 | // instantiate either a specific Bluetooth adapter, or the generic "default |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 18 | // adapter" which may change depending on availability. |
| 19 | class BluetoothAdapterFactory { |
| 20 | public: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 21 | typedef base::Callback<void(scoped_refptr<BluetoothAdapter> adapter)> |
| 22 | AdapterCallback; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 23 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 24 | // Returns true if the Bluetooth adapter is available for the current |
| 25 | // platform. |
| 26 | static bool IsBluetoothAdapterAvailable(); |
| 27 | |
| 28 | // Returns the shared instance of the default adapter, creating and |
| 29 | // initializing it if necessary. |callback| is called with the adapter |
| 30 | // instance passed only once the adapter is fully initialized and ready to |
| 31 | // use. |
| 32 | static void GetAdapter(const AdapterCallback& callback); |
| 33 | |
| 34 | // Returns the shared instance of the adapter that has already been created, |
| 35 | // but may or may not have been initialized. |
| 36 | // It returns NULL if no adapter has been created at the time. |
| 37 | static scoped_refptr<BluetoothAdapter> MaybeGetAdapter(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | } // namespace device |
| 41 | |
| 42 | #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_H_ |