Chromium Code Reviews| Index: device/bluetooth/bluetooth_adapter_profile_chromeos.h |
| diff --git a/device/bluetooth/bluetooth_adapter_profile_chromeos.h b/device/bluetooth/bluetooth_adapter_profile_chromeos.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e96a4283886ef0d02a067a8a9e6e8dcfa4e030d7 |
| --- /dev/null |
| +++ b/device/bluetooth/bluetooth_adapter_profile_chromeos.h |
| @@ -0,0 +1,101 @@ |
| +// Copyright 2015 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_ADAPTER_PROFILE_CHROMEOS_H_ |
| +#define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_PROFILE_CHROMEOS_H_ |
| + |
| +#include "base/memory/weak_ptr.h" |
| +#include "chromeos/dbus/bluetooth_profile_manager_client.h" |
| +#include "chromeos/dbus/bluetooth_profile_service_provider.h" |
| +#include "device/bluetooth/bluetooth_export.h" |
| + |
| +namespace device { |
| +class BluetoothUUID; |
| +} // namespace device |
| + |
| +namespace chromeos { |
| + |
| +class BluetoothAdapterChromeOS; |
| + |
| +// The BluetoothAdapterProfileChromeOS class implements a multiplexing |
| +// profile for custom bluetooth services managed by a BluetoothAdapter. |
|
armansito
2015/01/21 01:44:47
nit: s/bluetooth/Bluetooth/
Marie Janssen
2015/01/22 21:55:33
Done.
|
| +// Maintains a list of delegates which may serve the profile. |
| +// One delegate is allowed for each device. |
| +class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS |
| + : public chromeos::BluetoothProfileServiceProvider::Delegate { |
| + public: |
| + // Registers a profile with the BlueZ server for |uuid| with the |
| + // options |options|. Returns a newly allocated pointer, or NULL |
| + // if there was a problem. |
| + static BluetoothAdapterProfileChromeOS* Register( |
| + BluetoothAdapterChromeOS* adapter, |
| + const device::BluetoothUUID& uuid, |
| + const BluetoothProfileManagerClient::Options* options, |
|
armansito
2015/01/21 01:44:47
I'd pass |options| as a const reference rather tha
Marie Janssen
2015/01/22 21:55:33
Done.
|
| + const base::Closure& success_callback, |
| + const BluetoothProfileManagerClient::ErrorCallback& error_callback); |
| + |
| + virtual ~BluetoothAdapterProfileChromeOS(); |
| + |
| + // The object path of the profile. |
| + const dbus::ObjectPath& object_path() const { return object_path_; } |
| + |
| + // Add a delegate for a device associated with this profile. |
| + // An empty |device_path| indicates a local listening service. |
| + // Returns true if the delegate was set, and false if the |device_path| |
| + // already had a delegate set. |
| + bool SetDelegate(const dbus::ObjectPath& device_path, |
| + BluetoothProfileServiceProvider::Delegate* delegate); |
| + |
| + // Remove the delegate for a device. |
| + void RemoveDelegate(const dbus::ObjectPath& device_path); |
| + |
| + // Returns the number of delegates for this profile. |
| + size_t DelegateCount() const { return delegates_.size(); } |
| + |
| + // BluetoothProfileServiceProvider::Delegate: |
|
armansito
2015/01/21 01:44:47
I'd define these as private methods.
Marie Janssen
2015/01/22 21:55:33
Done.
|
| + virtual void Released() 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; |
|
armansito
2015/01/21 01:44:47
I'd define these as private methods.
armansito
2015/01/21 01:44:47
nit: Remove "virtual" when using "override".
Marie Janssen
2015/01/22 21:55:33
Done.
Marie Janssen
2015/01/22 21:55:33
Done.
|
| + |
| + private: |
| + BluetoothAdapterProfileChromeOS(BluetoothAdapterChromeOS* adapter, |
| + const device::BluetoothUUID& uuid); |
| + |
| + // Called by dbus:: on completion of the D-Bus method to unregister a profile. |
| + void OnUnregisterProfile(); |
| + void OnUnregisterProfileError(const std::string& error_name, |
| + const std::string& error_message); |
| + |
| + // List of delegates which this profile is multiplexing to. |
| + std::map<std::string, BluetoothProfileServiceProvider::Delegate*> delegates_; |
| + |
| + // The UUID that this profile represents. |
| + const device::BluetoothUUID& uuid_; |
| + |
| + // Registered dbus object path for this profile. |
|
armansito
2015/01/21 01:44:47
nit: s/dbus/D-Bus/
Or just be generally consisten
Marie Janssen
2015/01/22 21:55:33
Done.
|
| + dbus::ObjectPath object_path_; |
| + |
| + // Profile D-Bus object for receiving profile method calls from BlueZ |
| + scoped_ptr<BluetoothProfileServiceProvider> profile_; |
| + |
| + // Adapter that owns this profile. |
| + BluetoothAdapterChromeOS* adapter_; |
| + |
| + // 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<BluetoothAdapterProfileChromeOS> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterProfileChromeOS); |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif |