Index: chrome/browser/chromeos/bluetooth/bluetooth_adapter_dbus.h |
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_adapter.h b/chrome/browser/chromeos/bluetooth/bluetooth_adapter_dbus.h |
similarity index 68% |
copy from chrome/browser/chromeos/bluetooth/bluetooth_adapter.h |
copy to chrome/browser/chromeos/bluetooth/bluetooth_adapter_dbus.h |
index 673aac547d3583fd9cd35dfb31e43c733dba1601..f5ab8f6eb20e4c07e0ca60eab9d9487d580759c8 100644 |
--- a/chrome/browser/chromeos/bluetooth/bluetooth_adapter.h |
+++ b/chrome/browser/chromeos/bluetooth/bluetooth_adapter_dbus.h |
@@ -2,8 +2,8 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
-#define CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
+#ifndef CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_ADAPTER_DBUS_H_ |
+#define CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_ADAPTER_DBUS_H_ |
#include <map> |
#include <string> |
@@ -11,8 +11,8 @@ |
#include "base/basictypes.h" |
#include "base/callback.h" |
-#include "base/memory/ref_counted.h" |
#include "base/observer_list.h" |
+#include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" |
#include "chromeos/dbus/bluetooth_adapter_client.h" |
#include "chromeos/dbus/bluetooth_device_client.h" |
#include "chromeos/dbus/bluetooth_manager_client.h" |
@@ -21,133 +21,77 @@ |
namespace chromeos { |
-class BluetoothDevice; |
+class BluetoothDeviceDBus; |
keybuk
2012/09/13 23:57:30
This class should not be named ...DBus, that's inc
bryeung
2012/09/14 12:00:21
Will this remain true even when we want to use the
keybuk
2012/09/14 17:13:17
Yes, even on Linux the implementation will likely
youngki
2012/09/17 21:53:02
Done.
|
-// The BluetoothAdapter class represents a local Bluetooth adapter which |
-// may be used to interact with remote Bluetooth devices. As well as |
-// providing support for determining whether an adapter is present, and |
-// whether the radio is powered, this class also provides support for |
-// obtaining the list of remote devices known to the adapter, discovering |
-// new devices, and providing notification of updates to device information. |
+struct BluetoothOutOfBandPairingData; |
+ |
+// The BluetoothAdapterDBus class is an implementation of |
+// BluetoothAdapter using DBus for Linux/ChromeOS platform. |
keybuk
2012/09/13 23:57:30
Chrome OS only currently
youngki
2012/09/17 21:53:02
Done.
|
// |
-// The class may be instantiated for either a specific adapter, or for the |
+// This class may be instantiated for either a specific adapter, or for the |
// generic "default adapter" which may change depending on availability. |
-class BluetoothAdapter : public base::RefCounted<BluetoothAdapter>, |
- public BluetoothManagerClient::Observer, |
- public BluetoothAdapterClient::Observer, |
- public BluetoothDeviceClient::Observer { |
+class BluetoothAdapterDBus : public BluetoothAdapter, |
keybuk
2012/09/13 23:57:30
This class should not be named ...DBus, that's inc
youngki
2012/09/17 21:53:02
Done.
|
+ public BluetoothManagerClient::Observer, |
+ public BluetoothAdapterClient::Observer, |
+ public BluetoothDeviceClient::Observer { |
public: |
- // Interface for observing changes from bluetooth adapters. |
- class Observer { |
- public: |
- virtual ~Observer() {} |
- |
- // Called when the presence of the adapter |adapter| changes, when |
- // |present| is true the adapter is now present, false means the adapter |
- // has been removed from the system. |
- virtual void AdapterPresentChanged(BluetoothAdapter* adapter, |
- bool present) {} |
- |
- // Called when the radio power state of the adapter |adapter| changes, |
- // when |powered| is true the adapter radio is powered, false means the |
- // adapter radio is off. |
- virtual void AdapterPoweredChanged(BluetoothAdapter* adapter, |
- bool powered) {} |
- |
- // Called when the discovering state of the adapter |adapter| changes, |
- // when |discovering| is true the adapter is seeking new devices, false |
- // means it is not. Note that device discovery involves both states when |
- // the adapter is seeking new devices and states when it is not because |
- // it is interrogating the devices it found. |
- virtual void AdapterDiscoveringChanged(BluetoothAdapter* adapter, |
- bool discovering) {} |
- |
- // Called when a new device |device| is added to the adapter |adapter|, |
- // either because it has been discovered or a connection made. |device| |
- // should not be cached, instead copy its address. |
- virtual void DeviceAdded(BluetoothAdapter* adapter, |
- BluetoothDevice* device) {} |
- |
- // Called when properties of the device |device| known to the adapter |
- // |adapter| change. |device| should not be cached, instead copy its |
- // address. |
- virtual void DeviceChanged(BluetoothAdapter* adapter, |
- BluetoothDevice* device) {} |
- |
- // Called when the device |device| is removed from the adapter |adapter|, |
- // either as a result of a discovered device being lost between discovering |
- // phases or pairing information deleted. |device| should not be cached. |
- virtual void DeviceRemoved(BluetoothAdapter* adapter, |
- BluetoothDevice* device) {} |
- }; |
- |
// Adds and removes observers for events on this bluetooth adapter, |
bryeung
2012/09/13 19:52:57
In many places blocks of methods will be marked wi
keybuk
2012/09/13 23:57:30
Chrome style says this should be
// BluetoothAdap
youngki
2012/09/17 21:53:02
Done.
|
// if monitoring multiple adapters check the |adapter| parameter of |
// observer methods to determine which adapter is issuing the event. |
- void AddObserver(Observer* observer); |
- void RemoveObserver(Observer* observer); |
- |
- // The ErrorCallback is used for methods that can fail in which case it |
- // is called, in the success case the callback is simply not called. |
- typedef base::Callback<void()> ErrorCallback; |
- |
- // The BluetoothOutOfBandPairingDataCallback is used to return |
- // BluetoothOutOfBandPairingData to the caller. |
- typedef base::Callback<void(const BluetoothOutOfBandPairingData& data)> |
- BluetoothOutOfBandPairingDataCallback; |
+ virtual void AddObserver(BluetoothAdapter::Observer* observer) OVERRIDE; |
+ virtual void RemoveObserver(BluetoothAdapter::Observer* observer) OVERRIDE; |
// The address of this adapter. The address format is "XX:XX:XX:XX:XX:XX", |
// where each XX is a hexadecimal number. |
- const std::string& address() const { return address_; } |
+ virtual const std::string& address() const OVERRIDE; |
// The name of the adapter. |
- const std::string& name() const { return name_; } |
+ virtual const std::string& name() const OVERRIDE; |
// Indicates whether the adapter is actually present on the system, for |
// the default adapter this indicates whether any adapter is present. An |
// adapter is only considered present if the address has been obtained. |
- virtual bool IsPresent() const; |
+ virtual bool IsPresent() const OVERRIDE; |
// Indicates whether the adapter radio is powered. |
- virtual bool IsPowered() const; |
+ virtual bool IsPowered() const OVERRIDE; |
// Requests a change to the adapter radio power, setting |powered| to true |
// will turn on the radio and false will turn it off. On success, callback |
// will be called. On failure, |error_callback| will be called. |
- void SetPowered(bool powered, |
- const base::Closure& callback, |
- const ErrorCallback& error_callback); |
+ virtual void SetPowered(bool powered, |
+ const base::Closure& callback, |
+ const ErrorCallback& error_callback) OVERRIDE; |
// Indicates whether the adapter is currently discovering new devices, |
// note that a typical discovery process has phases of this being true |
// followed by phases of being false when the adapter interrogates the |
// devices found. |
- virtual bool IsDiscovering() const; |
+ virtual bool IsDiscovering() const OVERRIDE; |
// Requests that the adapter either begin discovering new devices when |
// |discovering| is true, or cease any discovery when false. On success, |
// callback will be called. On failure, |error_callback| will be called. |
virtual void SetDiscovering(bool discovering, |
const base::Closure& callback, |
- const ErrorCallback& error_callback); |
+ const ErrorCallback& error_callback) OVERRIDE; |
// Requests the list of devices from the adapter, all are returned |
// including those currently connected and those paired. Use the |
// returned device pointers to determine which they are. |
- typedef std::vector<BluetoothDevice*> DeviceList; |
- virtual DeviceList GetDevices(); |
- typedef std::vector<const BluetoothDevice*> ConstDeviceList; |
- virtual ConstDeviceList GetDevices() const; |
+ virtual DeviceList GetDevices() OVERRIDE; |
+ virtual ConstDeviceList GetDevices() const OVERRIDE; |
// Returns a pointer to the device with the given address |address| or |
// NULL if no such device is known. |
- virtual BluetoothDevice* GetDevice(const std::string& address); |
- virtual const BluetoothDevice* GetDevice(const std::string& address) const; |
+ virtual BluetoothDevice* GetDevice(const std::string& address) OVERRIDE; |
+ virtual const BluetoothDevice* GetDevice( |
+ const std::string& address) const OVERRIDE; |
// Requests the local Out Of Band pairing data. |
virtual void ReadLocalOutOfBandPairingData( |
const BluetoothOutOfBandPairingDataCallback& callback, |
- const ErrorCallback& error_callback); |
+ const ErrorCallback& error_callback) OVERRIDE; |
// Returns the shared instance for the default adapter, whichever that may |
// be at the time. Use IsPresent() and the AdapterPresentChanged() observer |
@@ -157,15 +101,15 @@ class BluetoothAdapter : public base::RefCounted<BluetoothAdapter>, |
// Creates an instance for a specific adapter named by |address|, which |
// may be the bluetooth address of the adapter or a device name such as |
// "hci0". |
- static BluetoothAdapter* Create(const std::string& address); |
+ static BluetoothAdapterDBus* Create(const std::string& address); |
private: |
- friend class base::RefCounted<BluetoothAdapter>; |
- friend class BluetoothDevice; |
+ friend class base::RefCounted<BluetoothAdapterDBus>; |
+ friend class BluetoothDeviceDBus; |
friend class MockBluetoothAdapter; |
- BluetoothAdapter(); |
- virtual ~BluetoothAdapter(); |
+ BluetoothAdapterDBus(); |
+ virtual ~BluetoothAdapterDBus(); |
// Obtains the default adapter object path from the Bluetooth Daemon |
// and tracks future changes to it. |
@@ -326,18 +270,18 @@ class BluetoothAdapter : public base::RefCounted<BluetoothAdapter>, |
// Devices paired with, connected to, discovered by, or visible to the |
// adapter. The key is the Bluetooth address of the device and the value |
- // is the BluetoothDevice object whose lifetime is managed by the adapter |
+ // is the BluetoothDeviceDBus object whose lifetime is managed by the adapter |
// instance. |
- typedef std::map<const std::string, BluetoothDevice*> DevicesMap; |
+ typedef std::map<const std::string, BluetoothDeviceDBus*> DevicesMap; |
DevicesMap devices_; |
// Note: This should remain the last member so it'll be destroyed and |
// invalidate its weak pointers before any other members are destroyed. |
- base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_; |
+ base::WeakPtrFactory<BluetoothAdapterDBus> weak_ptr_factory_; |
- DISALLOW_COPY_AND_ASSIGN(BluetoothAdapter); |
+ DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterDBus); |
}; |
} // namespace chromeos |
-#endif // CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
+#endif // CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_ADAPTER_DBUS_H_ |