| Index: device/bluetooth/bluetooth_profile_experimental_chromeos.h
|
| diff --git a/device/bluetooth/bluetooth_profile_experimental_chromeos.h b/device/bluetooth/bluetooth_profile_experimental_chromeos.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e8634838ed35ad33ba2444bcba34706f7f3603f2
|
| --- /dev/null
|
| +++ b/device/bluetooth/bluetooth_profile_experimental_chromeos.h
|
| @@ -0,0 +1,132 @@
|
| +// Copyright (c) 2013 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 DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_EXPERIMENTAL_CHROMEOS_H_
|
| +#define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_EXPERIMENTAL_CHROMEOS_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/callback.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "chromeos/chromeos_export.h"
|
| +#include "chromeos/dbus/experimental_bluetooth_profile_service_provider.h"
|
| +#include "dbus/object_path.h"
|
| +#include "device/bluetooth/bluetooth_profile.h"
|
| +
|
| +namespace dbus {
|
| +
|
| +class FileDescriptor;
|
| +
|
| +} // namespace dbus
|
| +
|
| +namespace device {
|
| +
|
| +class BluetoothAdapter;
|
| +
|
| +} // namespace device
|
| +
|
| +namespace chromeos {
|
| +
|
| +class CHROMEOS_EXPORT BluetoothProfileExperimentalChromeOS
|
| + : public device::BluetoothProfile,
|
| + private ExperimentalBluetoothProfileServiceProvider::Delegate {
|
| + public:
|
| + // BluetoothProfile override.
|
| + virtual void Unregister() OVERRIDE;
|
| + virtual void SetConnectionCallback(
|
| + const ConnectionCallback& callback) OVERRIDE;
|
| +
|
| + // Return the UUID of the profile.
|
| + const std::string& uuid() const { return uuid_; }
|
| +
|
| + private:
|
| + friend BluetoothProfile;
|
| +
|
| + BluetoothProfileExperimentalChromeOS();
|
| + virtual ~BluetoothProfileExperimentalChromeOS();
|
| +
|
| + // Called by BluetoothProfile::Register to initialize the profile object
|
| + // asynchronously. |uuid|, |options| and |callback| are the arguments to
|
| + // BluetoothProfile::Register.
|
| + void Init(const std::string& uuid,
|
| + const device::BluetoothProfile::Options& options,
|
| + const ProfileCallback& callback);
|
| +
|
| + // ExperimentalBluetoothProfileServiceProvider::Delegate override.
|
| + virtual void Release() OVERRIDE;
|
| + virtual void NewConnection(
|
| + const dbus::ObjectPath& device_path,
|
| + dbus::FileDescriptor* fd,
|
| + const ExperimentalBluetoothProfileServiceProvider::Delegate::Options&
|
| + options,
|
| + const ConfirmationCallback& callback) OVERRIDE;
|
| + virtual void RequestDisconnection(
|
| + const dbus::ObjectPath& device_path,
|
| + const ConfirmationCallback& callback) OVERRIDE;
|
| + virtual void Cancel() OVERRIDE;
|
| +
|
| + // Called by dbus:: on completion of the D-Bus method call to register the
|
| + // profile object.
|
| + void OnRegisterProfile(const ProfileCallback& callback);
|
| + void OnRegisterProfileError(const ProfileCallback& callback,
|
| + const std::string& error_name,
|
| + const std::string& error_message);
|
| +
|
| + // Called by dbus:: on completion of the D-Bus method call to unregister
|
| + // the profile object.
|
| + void OnUnregisterProfile();
|
| + void OnUnregisterProfileError(const std::string& error_name,
|
| + const std::string& error_message);
|
| +
|
| + // Method run on a thread where i/o is permitted to verify the validity of
|
| + // the file descriptor obtained over D-Bus, and method run once that is
|
| + // complete back on the origin thread.
|
| + //
|
| + // These methods do not own the file descriptor |fd|; it is owned by the
|
| + // base::Bind call used to call them.
|
| + void CheckValidity(dbus::FileDescriptor* fd);
|
| + void OnCheckValidity(
|
| + const dbus::ObjectPath& device_path,
|
| + dbus::FileDescriptor* fd,
|
| + const ExperimentalBluetoothProfileServiceProvider::Delegate::Options&
|
| + options,
|
| + const ConfirmationCallback& callback);
|
| +
|
| + // Method run once the default adapter has been obtained, obtains the device
|
| + // to be passed to the created BluetoothSocket.
|
| + //
|
| + // Does not own the file descriptor |fd| but can take the value.
|
| + void OnGetAdapter(
|
| + const dbus::ObjectPath& device_path,
|
| + dbus::FileDescriptor* fd,
|
| + const ExperimentalBluetoothProfileServiceProvider::Delegate::Options&
|
| + options,
|
| + const ConfirmationCallback& callback,
|
| + scoped_refptr<device::BluetoothAdapter>);
|
| +
|
| + // UUID of the profile passed during initialization.
|
| + std::string uuid_;
|
| +
|
| + // Object path of the local profile D-Bus object.
|
| + dbus::ObjectPath object_path_;
|
| +
|
| + // Local profile D-Bus object used for receiving profile delegate methods
|
| + // from BlueZ.
|
| + scoped_ptr<ExperimentalBluetoothProfileServiceProvider> profile_;
|
| +
|
| + // Callback used on both outgoing and incoming connections to pass the
|
| + // connected socket to profile object owner.
|
| + ConnectionCallback connection_callback_;
|
| +
|
| + // 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<BluetoothProfileExperimentalChromeOS> weak_ptr_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(BluetoothProfileExperimentalChromeOS);
|
| +};
|
| +
|
| +} // namespace chromeos
|
| +
|
| +#endif // DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_EXPERIMENTAL_CHROMEOS_H_
|
|
|