Bluetooth: clean up Bluetooth classes
The abstract BluetoothDevice class has a few problems inherited from
its origin as a ChromeOS-specific class split between implementation
and platform-specific components.
Clean those problems up, specifically:
- replace bluetooth_class_, name_ and address_ non-abstract members
with getter functions that the platform should implement.
- also make IsConnected(), IsConnectable() and IsConnecting()
abstract functions rather than providing an implementation
- remove IsVisible() which was a CrOS-specific hack
- remove IsBonded(), use IsPaired() instead
- remove service_uuids_ non-abstract member; make GetServices return
a copy of the list to allow implementations to fetch it on demand
BluetoothDevice retains implementations for GetName(), GetDisplayType()
and ProvidesServiceWithUUID() since those can be implemented entirely
using platform-provided information functions and would be identical
in each platform.
Also rename BluetoothAdapter::address() and BluetoothAdapter::name() to
GetAddress() and GetName() to match since they are also pure virtual.
BUG=none
TEST=device_unittests, browser_tests, unit_tests
Review URL: https://chromiumcodereview.appspot.com/13416005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192474 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/device/bluetooth/bluetooth_device_win.h b/device/bluetooth/bluetooth_device_win.h
index b1e9d80..7213cd1 100644
--- a/device/bluetooth/bluetooth_device_win.h
+++ b/device/bluetooth/bluetooth_device_win.h
@@ -22,11 +22,13 @@
const BluetoothTaskManagerWin::DeviceState& state);
virtual ~BluetoothDeviceWin();
- void SetVisible(bool visible);
-
// BluetoothDevice override
+ virtual std::string GetAddress() const OVERRIDE;
virtual bool IsPaired() const OVERRIDE;
- virtual const ServiceList& GetServices() const OVERRIDE;
+ virtual bool IsConnected() const OVERRIDE;
+ virtual bool IsConnectable() const OVERRIDE;
+ virtual bool IsConnecting() const OVERRIDE;
+ virtual ServiceList GetServices() const OVERRIDE;
virtual void GetServiceRecords(
const ServiceRecordsCallback& callback,
const ErrorCallback& error_callback) OVERRIDE;
@@ -60,9 +62,18 @@
const base::Closure& callback,
const ErrorCallback& error_callback) OVERRIDE;
+ protected:
+ // BluetoothDevice override
+ virtual uint32 GetBluetoothClass() const OVERRIDE;
+ virtual std::string GetDeviceName() const OVERRIDE;
+
private:
friend class BluetoothAdapterWin;
+ // Used by BluetoothAdapterWin to update the visible state during
+ // discovery.
+ void SetVisible(bool visible);
+
// Computes the fingerprint that can be used to compare the devices.
static uint32 ComputeDeviceFingerprint(
const BluetoothTaskManagerWin::DeviceState& state);
@@ -71,6 +82,28 @@
return device_fingerprint_;
}
+ // The Bluetooth class of the device, a bitmask that may be decoded using
+ // https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm
+ uint32 bluetooth_class_;
+
+ // The name of the device, as supplied by the remote device.
+ std::string name_;
+
+ // The Bluetooth address of the device.
+ std::string address_;
+
+ // Tracked device state, updated by the adapter managing the lifecyle of
+ // the device.
+ bool paired_;
+ bool connected_;
+
+ // Used to send change notifications when a device disappears during
+ // discovery.
+ bool visible_;
+
+ // The services (identified by UUIDs) that this device provides.
+ ServiceList service_uuids_;
+
// Used to compare the devices.
uint32 device_fingerprint_;
ServiceRecordList service_record_list_;