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

Unified Diff: chrome/browser/chromeos/bluetooth/bluetooth_adapter_dbus.h

Issue 10899037: Refactoring bluetooth API code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated the interfaces with class-level comments. Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
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 80%
rename from chrome/browser/chromeos/bluetooth/bluetooth_adapter.h
rename to chrome/browser/chromeos/bluetooth/bluetooth_adapter_dbus.h
index 9204282ba66a8db14fd59094ce91643187b919ea..ca0313a9257ba0c348eb0fa7ef31d48d3af401b0 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>
@@ -13,6 +13,7 @@
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
+#include "chrome/browser/chromeos/bluetooth/bluetooth_adapter_interface.h"
#include "chromeos/dbus/bluetooth_adapter_client.h"
#include "chromeos/dbus/bluetooth_device_client.h"
#include "chromeos/dbus/bluetooth_manager_client.h"
@@ -21,21 +22,20 @@
namespace chromeos {
-class BluetoothDevice;
+class BluetoothDeviceDBus;
-// 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
+// BluetoothAdapterInterface using DBus for Linux/ChromeOS platform.
//
-// 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 base::RefCounted<BluetoothAdapterDBus>,
+ public BluetoothAdapterInterface,
+ public BluetoothManagerClient::Observer,
+ public BluetoothAdapterClient::Observer,
+ public BluetoothDeviceClient::Observer {
public:
// Interface for observing changes from bluetooth adapters.
class Observer {
@@ -45,13 +45,13 @@ class BluetoothAdapter : public base::RefCounted<BluetoothAdapter>,
// 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,
+ virtual void AdapterPresentChanged(BluetoothAdapterDBus* 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,
+ virtual void AdapterPoweredChanged(BluetoothAdapterDBus* adapter,
bool powered) {}
// Called when the discovering state of the adapter |adapter| changes,
@@ -59,26 +59,26 @@ class BluetoothAdapter : public base::RefCounted<BluetoothAdapter>,
// 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,
+ virtual void AdapterDiscoveringChanged(BluetoothAdapterDBus* 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) {}
+ virtual void DeviceAdded(BluetoothAdapterDBus* adapter,
+ BluetoothDeviceDBus* 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) {}
+ virtual void DeviceChanged(BluetoothAdapterDBus* adapter,
+ BluetoothDeviceDBus* 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) {}
+ virtual void DeviceRemoved(BluetoothAdapterDBus* adapter,
+ BluetoothDeviceDBus* device) {}
};
// Adds and removes observers for events on this bluetooth adapter,
@@ -87,21 +87,12 @@ class BluetoothAdapter : public base::RefCounted<BluetoothAdapter>,
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;
-
// 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 { return address_; }
kevers 2012/09/07 15:39:25 Virtual methods with non-empty bodies shouldn't be
youngki 2012/09/07 18:18:37 Done.
// The name of the adapter.
- const std::string& name() const { return name_; }
+ virtual const std::string& name() const { return name_; }
// Indicates whether the adapter is actually present on the system, for
// the default adapter this indicates whether any adapter is present.
@@ -133,15 +124,14 @@ class BluetoothAdapter : public base::RefCounted<BluetoothAdapter>,
// 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;
// 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 BluetoothDeviceInterface* GetDevice(const std::string& address);
+ virtual const BluetoothDeviceInterface* GetDevice(
+ const std::string& address) const;
// Requests the local Out Of Band pairing data.
virtual void ReadLocalOutOfBandPairingData(
@@ -151,20 +141,20 @@ class BluetoothAdapter : public base::RefCounted<BluetoothAdapter>,
// Returns the shared instance for the default adapter, whichever that may
// be at the time. Use IsPresent() and the AdapterPresentChanged() observer
// method to determine whether an adapter is actually available or not.
- static scoped_refptr<BluetoothAdapter> DefaultAdapter();
+ static scoped_refptr<BluetoothAdapterDBus> DefaultAdapter();
// 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 MockBluetoothAdapter;
+ friend class base::RefCounted<BluetoothAdapterDBus>;
+ friend class BluetoothDeviceDBus;
+ friend class MockBluetoothAdapterDBus;
- BluetoothAdapter();
- virtual ~BluetoothAdapter();
+ BluetoothAdapterDBus();
+ virtual ~BluetoothAdapterDBus();
// Obtains the default adapter object path from the Bluetooth Daemon
// and tracks future changes to it.
@@ -304,11 +294,11 @@ class BluetoothAdapter : public base::RefCounted<BluetoothAdapter>,
const std::string& address) OVERRIDE;
// List of observers interested in event notifications from us.
- ObserverList<BluetoothAdapter::Observer> observers_;
+ ObserverList<BluetoothAdapterDBus::Observer> observers_;
// Weak pointer factory for generating 'this' pointers that might live longer
// than we do.
- base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_;
+ base::WeakPtrFactory<BluetoothAdapterDBus> weak_ptr_factory_;
// Object path of adapter for this instance, this is fixed at creation time
// unless |track_default_| is true in which case we update it to always
@@ -329,14 +319,14 @@ 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_;
- 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_

Powered by Google App Engine
This is Rietveld 408576698