Chromium Code Reviews| Index: device/bluetooth/bluetooth_mac_discovery_manager.h |
| diff --git a/device/bluetooth/bluetooth_mac_discovery_manager.h b/device/bluetooth/bluetooth_mac_discovery_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..71aa855adea646f4dd9e6f1d1246461b4e9369ed |
| --- /dev/null |
| +++ b/device/bluetooth/bluetooth_mac_discovery_manager.h |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef DEVICE_BLUETOOTH_BLUETOOTH_MAC_DISCOVERY_MANAGER_H_ |
| +#define DEVICE_BLUETOOTH_BLUETOOTH_MAC_DISCOVERY_MANAGER_H_ |
| + |
| +#include "base/observer_list.h" |
| + |
| +@class IOBluetoothDevice; |
| + |
| +namespace device { |
| + |
| +// Class used by BluetoothAdapterMac to manage classic and LE device discovery. |
| +// For Bluetooth Classic, this class is responsible for keeping device inquiry |
| +// running if device discovery is initiated. |
| +class BluetoothMacDiscoveryManager { |
| + public: |
| + // Interface for being notified of events during a device discovery session. |
| + class Observer { |
| + public: |
| + // Called when |manager| has found a device through classic device inquiry |
| + // in the form of a IOBluetoothDevice. |
| + virtual void DeviceFound(BluetoothMacDiscoveryManager* manager, |
| + IOBluetoothDevice* device) {} |
| + |
| + // Called when device discovery is no longer running, due to either a call |
| + // too BluetoothMacDiscoveryManager::StopDiscovery or an unexpected reason, |
|
Ilya Sherman
2014/06/10 01:10:59
nit: "too" -> "to"
armansito
2014/06/10 21:56:50
Done.
|
| + // such as when a user disables the controller, in which case the value of |
| + // |unexpected| will be true. |
| + virtual void DiscoveryStopped(BluetoothMacDiscoveryManager* manager, |
| + bool unexpected) {} |
| + }; |
| + |
| + virtual ~BluetoothMacDiscoveryManager(); |
| + |
| + // Returns true, if discovery is currently being performed. |
| + virtual bool IsDiscovering() const = 0; |
| + |
| + // Initiates a discovery session. Returns true on success, or if discovery |
| + // is already running. |
|
Ilya Sherman
2014/06/10 01:10:59
nit: It visually looks like this comment applies t
armansito
2014/06/10 21:56:50
Done.
|
| + virtual bool StartDiscovery() = 0; |
| + virtual bool StopDiscovery() = 0; |
| + |
| + // Add and remove observers. |
| + void AddObserver(Observer* observer); |
| + void RemoveObserver(Observer* observer); |
| + |
| + // Creates a discovery manager for Bluetooth Classic device discovery. |
| + static BluetoothMacDiscoveryManager* CreateClassic(); |
| + |
| + protected: |
| + BluetoothMacDiscoveryManager(); |
| + |
| + // List of observers interested in notifications from us. |
| + ObserverList<Observer> observers_; |
|
Ilya Sherman
2014/06/10 01:10:59
Do we really need a list of observers, or can we j
armansito
2014/06/10 21:56:50
We can have a single observer, certainly. This jus
Ilya Sherman
2014/06/10 23:23:01
I won't insist, but IMO it's better to avoid being
armansito
2014/06/13 02:14:53
Done.
|
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(BluetoothMacDiscoveryManager); |
| +}; |
| + |
| +} // namespace device |
| + |
| +#endif // DEVICE_BLUETOOTH_BLUETOOTH_MAC_DISCOVERY_MANAGER_H_ |