Automated Commit: Committing new LKGM version 6953.0.0 for chromeos.
[chromium-blink-merge.git] / device / bluetooth / bluetooth_adapter_factory.h
blob3b11685fd4f120ee1c38a1359571e9eedb6ceab1
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.
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_H_
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "device/bluetooth/bluetooth_adapter.h"
11 #include "device/bluetooth/bluetooth_export.h"
13 namespace device {
15 // A factory class for building a Bluetooth adapter on platforms where Bluetooth
16 // is available.
17 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterFactory {
18 public:
19 typedef base::Callback<void(scoped_refptr<BluetoothAdapter> adapter)>
20 AdapterCallback;
22 // Returns true if the Bluetooth adapter is available for the current
23 // platform.
24 static bool IsBluetoothAdapterAvailable();
26 // Returns the shared instance of the default adapter, creating and
27 // initializing it if necessary. |callback| is called with the adapter
28 // instance passed only once the adapter is fully initialized and ready to
29 // use.
30 static void GetAdapter(const AdapterCallback& callback);
32 #if defined(OS_CHROMEOS)
33 // Calls |BluetoothAdapter::Shutdown| on the adapter if
34 // present.
35 static void Shutdown();
36 #endif
38 // Sets the shared instance of the default adapter for testing purposes only,
39 // no reference is retained after completion of the call, removing the last
40 // reference will reset the factory.
41 static void SetAdapterForTesting(scoped_refptr<BluetoothAdapter> adapter);
43 // Returns true iff the implementation has a (non-NULL) shared instance of the
44 // adapter. Exposed for testing.
45 static bool HasSharedInstanceForTesting();
48 } // namespace device
50 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_H_