| Index: chrome/browser/chromeos/bluetooth/bluetooth_device_interface.h
|
| diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_device_interface.h b/chrome/browser/chromeos/bluetooth/bluetooth_device_interface.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..59095088e7920cef5b690e79d5c9063cb2646b0f
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/bluetooth/bluetooth_device_interface.h
|
| @@ -0,0 +1,107 @@
|
| +// Copyright (c) 2012 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 CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_INTERFACE_H_
|
| +#define CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_INTERFACE_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/callback.h"
|
| +#include "base/string16.h"
|
| +#include "base/memory/ref_counted.h"
|
| +
|
| +namespace chromeos {
|
| +
|
| +class BluetoothServiceRecordDBus;
|
| +class BluetoothSocketPosix;
|
| +
|
| +struct BluetoothOutOfBandPairingData;
|
| +
|
| +// The BluetoothDeviceInterface represents a remote Bluetooth device, both its
|
| +// properties and capabilities as discovered by a local adapter and actions that
|
| +// may be performed on the remove device such as pairing, connection and
|
| +// disconnection.
|
| +class BluetoothDeviceInterface {
|
| + public:
|
| + virtual ~BluetoothDeviceInterface() {}
|
| +
|
| + // Returns the Bluetooth of address the device. This should be used as
|
| + // a unique key to identify the device and copied where needed.
|
| + virtual const std::string& address() const = 0;
|
| +
|
| + // Returns the name of the device suitable for displaying, this may
|
| + // be a synthesied string containing the address and localized type name
|
| + // if the device has no obtained name.
|
| + virtual string16 GetName() const = 0;
|
| +
|
| + // Indicates whether the device is paired to the adapter, whether or not
|
| + // that pairing is permanent or temporary.
|
| + virtual bool IsPaired() const = 0;
|
| +
|
| + // Indicates whether the device is bonded to the adapter, bonding is
|
| + // formed by pairing and exchanging high-security link keys so that
|
| + // connections may be encrypted.
|
| + virtual bool IsBonded() const = 0;
|
| +
|
| + // Indicates whether the device is currently connected to the adapter
|
| + // and at least one service available for use.
|
| + virtual bool IsConnected() const = 0;
|
| +
|
| + // 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;
|
| +
|
| + // Returns the services (as BluetoothServiceRecordDBus objects) that this
|
| + // device provides.
|
| + typedef ScopedVector<BluetoothServiceRecordDBus> ServiceRecordList;
|
| + typedef base::Callback<void(const ServiceRecordList&)> ServiceRecordsCallback;
|
| + virtual void GetServiceRecords(const ServiceRecordsCallback& callback,
|
| + const ErrorCallback& error_callback) = 0;
|
| +
|
| + // Indicates whether this device provides the given service. |uuid| should
|
| + // be in canonical form (see bluetooth_utils::CanonicalUuid).
|
| + virtual bool ProvidesServiceWithUUID(const std::string& uuid) const = 0;
|
| +
|
| + // The ProvidesServiceCallback is used by ProvidesServiceWithName to indicate
|
| + // whether or not a matching service was found.
|
| + typedef base::Callback<void(bool)> ProvidesServiceCallback;
|
| +
|
| + // Indicates whether this device provides the given service.
|
| + virtual void ProvidesServiceWithName(
|
| + const std::string& name,
|
| + const ProvidesServiceCallback& callback) = 0;
|
| +
|
| + // SocketCallback is used by ConnectToService to return a BluetoothSocketPosix
|
| + // to the caller, or NULL if there was an error. The socket will remain open
|
| + // until the last reference to the returned BluetoothSocketPosix is released.
|
| + typedef base::Callback<void(scoped_refptr<BluetoothSocketPosix>)>
|
| + SocketCallback;
|
| +
|
| + // Attempts to open a socket to a service matching |uuid| on this device. If
|
| + // the connection is successful, |callback| is called with a
|
| + // BluetoothSocketPosix.
|
| + // Otherwise |callback| is called with NULL. The socket is closed as soon as
|
| + // all references to the BluetoothSocketPosix are released. Note that the
|
| + // BluetoothSocketPosix object can outlive both this BluetoothDeviceDBus and
|
| + // the BluetoothAdapterDBus for this device.
|
| + virtual void ConnectToService(const std::string& service_uuid,
|
| + const SocketCallback& callback) = 0;
|
| +
|
| + // Sets the Out Of Band pairing data for this device to |data|. Exactly one
|
| + // of |callback| or |error_callback| will be run.
|
| + virtual void SetOutOfBandPairingData(
|
| + const BluetoothOutOfBandPairingData& data,
|
| + const base::Closure& callback,
|
| + const ErrorCallback& error_callback) = 0;
|
| +
|
| + // Clears the Out Of Band pairing data for this device. Exactly one of
|
| + // |callback| or |error_callback| will be run.
|
| + virtual void ClearOutOfBandPairingData(
|
| + const base::Closure& callback,
|
| + const ErrorCallback& error_callback) = 0;
|
| +};
|
| +
|
| +} // namespace chromeos
|
| +
|
| +#endif // CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_INTERFACE_H_
|
|
|