#ifndef DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_CHROMEOS_H_
#define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_CHROMEOS_H_
#include <string>
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/bluetooth_profile_manager_client.h"
#include "chromeos/dbus/bluetooth_profile_service_provider.h"
#include "dbus/object_path.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_profile.h"
#include "device/bluetooth/bluetooth_uuid.h"
namespace dbus {
class FileDescriptor;
}
namespace chromeos {
class CHROMEOS_EXPORT BluetoothProfileChromeOS
: public device::BluetoothProfile,
private device::BluetoothAdapter::Observer,
private BluetoothProfileServiceProvider::Delegate {
public:
virtual void Unregister() OVERRIDE;
virtual void SetConnectionCallback(
const ConnectionCallback& callback) OVERRIDE;
const device::BluetoothUUID& uuid() const { return uuid_; }
private:
friend class BluetoothProfile;
BluetoothProfileChromeOS();
virtual ~BluetoothProfileChromeOS();
void Init(const device::BluetoothUUID& uuid,
const device::BluetoothProfile::Options& options,
const ProfileCallback& callback);
virtual void Release() OVERRIDE;
virtual void NewConnection(
const dbus::ObjectPath& device_path,
scoped_ptr<dbus::FileDescriptor> fd,
const BluetoothProfileServiceProvider::Delegate::Options& options,
const ConfirmationCallback& callback) OVERRIDE;
virtual void RequestDisconnection(
const dbus::ObjectPath& device_path,
const ConfirmationCallback& callback) OVERRIDE;
virtual void Cancel() OVERRIDE;
virtual void AdapterPresentChanged(device::BluetoothAdapter* adapter,
bool present) OVERRIDE;
void OnInternalRegisterProfile();
void OnInternalRegisterProfileError(const std::string& error_name,
const std::string& error_message);
void OnGetAdapter(const ProfileCallback& callback,
scoped_refptr<device::BluetoothAdapter> adapter);
void OnRegisterProfile(const ProfileCallback& callback);
void OnRegisterProfileError(const ProfileCallback& callback,
const std::string& error_name,
const std::string& error_message);
void OnUnregisterProfile();
void OnUnregisterProfileError(const std::string& error_name,
const std::string& error_message);
void OnCheckValidity(
const dbus::ObjectPath& device_path,
const BluetoothProfileServiceProvider::Delegate::Options& options,
const ConfirmationCallback& callback,
scoped_ptr<dbus::FileDescriptor> fd);
device::BluetoothUUID uuid_;
BluetoothProfileManagerClient::Options options_;
dbus::ObjectPath object_path_;
scoped_ptr<BluetoothProfileServiceProvider> profile_;
scoped_refptr<device::BluetoothAdapter> adapter_;
ConnectionCallback connection_callback_;
base::WeakPtrFactory<BluetoothProfileChromeOS> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(BluetoothProfileChromeOS);
};
}
#endif