| 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_FACTORY_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "device/bluetooth/bluetooth_adapter.h" | 11 #include "device/bluetooth/bluetooth_adapter.h" |
| 12 #include "device/bluetooth/bluetooth_export.h" | 12 #include "device/bluetooth/bluetooth_export.h" |
| 13 | 13 |
| 14 namespace device { | 14 namespace device { |
| 15 | 15 |
| 16 // A factory class for building a Bluetooth adapter on platforms where Bluetooth | 16 // A factory class for building a Bluetooth adapter on platforms where Bluetooth |
| 17 // is available. | 17 // is available. |
| 18 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterFactory { | 18 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterFactory { |
| 19 public: | 19 public: |
| 20 typedef base::Callback<void(scoped_refptr<BluetoothAdapter> adapter)> | 20 typedef base::Callback<void(scoped_refptr<BluetoothAdapter> adapter)> |
| 21 AdapterCallback; | 21 AdapterCallback; |
| 22 | 22 |
| 23 // Returns true if the Bluetooth adapter is available for the current | 23 // Returns true if the Bluetooth adapter is available for the current |
| 24 // platform. | 24 // platform. |
| 25 static bool IsBluetoothAdapterAvailable(); | 25 static bool IsBluetoothAdapterAvailable(); |
| 26 | 26 |
| 27 // Returns true if Bluetooth Low Energy is available for the current |
| 28 // platform. |
| 29 static bool IsLowEnergyAvailable(); |
| 30 |
| 27 // Returns the shared instance of the default adapter, creating and | 31 // Returns the shared instance of the default adapter, creating and |
| 28 // initializing it if necessary. |callback| is called with the adapter | 32 // initializing it if necessary. |callback| is called with the adapter |
| 29 // instance passed only once the adapter is fully initialized and ready to | 33 // instance passed only once the adapter is fully initialized and ready to |
| 30 // use. | 34 // use. |
| 31 static void GetAdapter(const AdapterCallback& callback); | 35 static void GetAdapter(const AdapterCallback& callback); |
| 32 | 36 |
| 33 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | 37 #if defined(OS_CHROMEOS) || defined(OS_LINUX) |
| 34 // Calls |BluetoothAdapter::Shutdown| on the adapter if | 38 // Calls |BluetoothAdapter::Shutdown| on the adapter if |
| 35 // present. | 39 // present. |
| 36 static void Shutdown(); | 40 static void Shutdown(); |
| 37 #endif | 41 #endif |
| 38 | 42 |
| 39 // Sets the shared instance of the default adapter for testing purposes only, | 43 // Sets the shared instance of the default adapter for testing purposes only, |
| 40 // no reference is retained after completion of the call, removing the last | 44 // no reference is retained after completion of the call, removing the last |
| 41 // reference will reset the factory. | 45 // reference will reset the factory. |
| 42 static void SetAdapterForTesting(scoped_refptr<BluetoothAdapter> adapter); | 46 static void SetAdapterForTesting(scoped_refptr<BluetoothAdapter> adapter); |
| 43 | 47 |
| 44 // Returns true iff the implementation has a (non-NULL) shared instance of the | 48 // Returns true iff the implementation has a (non-NULL) shared instance of the |
| 45 // adapter. Exposed for testing. | 49 // adapter. Exposed for testing. |
| 46 static bool HasSharedInstanceForTesting(); | 50 static bool HasSharedInstanceForTesting(); |
| 47 }; | 51 }; |
| 48 | 52 |
| 49 } // namespace device | 53 } // namespace device |
| 50 | 54 |
| 51 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_H_ | 55 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_H_ |
| OLD | NEW |