bluetooth_adapter_factory.h revision 0529e5d033099cbfc42635f6f6183833b09dff6e
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 "base/callback.h"
9#include "base/memory/ref_counted.h"
10#include "device/bluetooth/bluetooth_adapter.h"
11
12namespace device {
13
14// A factory class for building a Bluetooth adapter on platforms where Bluetooth
15// is available.
16class BluetoothAdapterFactory {
17 public:
18  typedef base::Callback<void(scoped_refptr<BluetoothAdapter> adapter)>
19      AdapterCallback;
20
21  // Returns true if the Bluetooth adapter is available for the current
22  // platform.
23  static bool IsBluetoothAdapterAvailable();
24
25  // Returns the shared instance of the default adapter, creating and
26  // initializing it if necessary. |callback| is called with the adapter
27  // instance passed only once the adapter is fully initialized and ready to
28  // use.
29  static void GetAdapter(const AdapterCallback& callback);
30
31  // Returns true iff the implementation has a (non-NULL) shared instance of the
32  // adapter. Exposed for testing.
33  static bool HasSharedInstanceForTesting();
34};
35
36}  // namespace device
37
38#endif  // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_H_
39