Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: device/bluetooth/bluetooth_adapter_factory.h

Issue 180163009: chrome.bluetooth API improvements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address code review feedback. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "device/bluetooth/bluetooth_adapter.h" 12 #include "device/bluetooth/bluetooth_adapter.h"
13 13
14 namespace device { 14 namespace device {
15 15
16 // BluetoothAdapterFactory is a class that contains static methods, which 16 // BluetoothAdapterFactory is a class that contains static methods, which
17 // instantiate either a specific Bluetooth adapter, or the generic "default 17 // instantiate either a specific Bluetooth adapter, or the generic "default
18 // adapter" which may change depending on availability. 18 // adapter" which may change depending on availability.
19 class BluetoothAdapterFactory { 19 class BluetoothAdapterFactory {
20 public: 20 public:
21 typedef base::Callback<void(BluetoothAdapter* adapter)> AdapterInitializer;
21 typedef base::Callback<void(scoped_refptr<BluetoothAdapter> adapter)> 22 typedef base::Callback<void(scoped_refptr<BluetoothAdapter> adapter)>
22 AdapterCallback; 23 AdapterCallback;
23 24
25 // Sets a global initializer to run just after the default adapter instance is
26 // created.
27 static void SetAdapterInitializer(AdapterInitializer initializer);
28
24 // Returns true if the Bluetooth adapter is available for the current 29 // Returns true if the Bluetooth adapter is available for the current
25 // platform. 30 // platform.
26 static bool IsBluetoothAdapterAvailable(); 31 static bool IsBluetoothAdapterAvailable();
27 32
28 // Returns the shared instance of the default adapter, creating and 33 // Returns the shared instance of the default adapter, creating and
29 // initializing it if necessary. |callback| is called with the adapter 34 // initializing it if necessary. |callback| is called with the adapter
30 // instance passed only once the adapter is fully initialized and ready to 35 // instance passed only once the adapter is fully initialized and ready to
31 // use. 36 // use.
32 static void GetAdapter(const AdapterCallback& callback); 37 static void GetAdapter(const AdapterCallback& callback);
33 38
34 // Returns the shared instance of the adapter that has already been created, 39 // Returns the shared instance of the adapter that has already been created,
35 // but may or may not have been initialized. 40 // but may or may not have been initialized.
36 // It returns NULL if no adapter has been created at the time. 41 // It returns NULL if no adapter has been created at the time.
37 static scoped_refptr<BluetoothAdapter> MaybeGetAdapter(); 42 static scoped_refptr<BluetoothAdapter> MaybeGetAdapter();
43
44 private:
45 AdapterInitializer adapter_initializer_;
38 }; 46 };
39 47
40 } // namespace device 48 } // namespace device
41 49
42 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_H_ 50 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698