| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_CHROMEOS_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_CHROMEOS_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_CHROMEOS_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "chromeos/chromeos_export.h" | 14 #include "chromeos/chromeos_export.h" |
| 15 #include "chromeos/dbus/bluetooth_profile_manager_client.h" | 15 #include "chromeos/dbus/bluetooth_profile_manager_client.h" |
| 16 #include "chromeos/dbus/bluetooth_profile_service_provider.h" | 16 #include "chromeos/dbus/bluetooth_profile_service_provider.h" |
| 17 #include "dbus/object_path.h" | 17 #include "dbus/object_path.h" |
| 18 #include "device/bluetooth/bluetooth_adapter.h" | 18 #include "device/bluetooth/bluetooth_adapter.h" |
| 19 #include "device/bluetooth/bluetooth_profile.h" | 19 #include "device/bluetooth/bluetooth_profile.h" |
| 20 #include "device/bluetooth/bluetooth_uuid.h" | |
| 21 | 20 |
| 22 namespace dbus { | 21 namespace dbus { |
| 23 | 22 |
| 24 class FileDescriptor; | 23 class FileDescriptor; |
| 25 | 24 |
| 26 } // namespace dbus | 25 } // namespace dbus |
| 27 | 26 |
| 28 namespace chromeos { | 27 namespace chromeos { |
| 29 | 28 |
| 30 // The BluetoothProfileChromeOS class implements BluetoothProfile for the | 29 // The BluetoothProfileChromeOS class implements BluetoothProfile for the |
| 31 // Chrome OS platform. | 30 // Chrome OS platform. |
| 32 class CHROMEOS_EXPORT BluetoothProfileChromeOS | 31 class CHROMEOS_EXPORT BluetoothProfileChromeOS |
| 33 : public device::BluetoothProfile, | 32 : public device::BluetoothProfile, |
| 34 private device::BluetoothAdapter::Observer, | 33 private device::BluetoothAdapter::Observer, |
| 35 private BluetoothProfileServiceProvider::Delegate { | 34 private BluetoothProfileServiceProvider::Delegate { |
| 36 public: | 35 public: |
| 37 // BluetoothProfile override. | 36 // BluetoothProfile override. |
| 38 virtual void Unregister() OVERRIDE; | 37 virtual void Unregister() OVERRIDE; |
| 39 virtual void SetConnectionCallback( | 38 virtual void SetConnectionCallback( |
| 40 const ConnectionCallback& callback) OVERRIDE; | 39 const ConnectionCallback& callback) OVERRIDE; |
| 41 | 40 |
| 42 // Return the UUID of the profile. | 41 // Return the UUID of the profile. |
| 43 const device::BluetoothUUID& uuid() const { return uuid_; } | 42 const std::string& uuid() const { return uuid_; } |
| 44 | 43 |
| 45 private: | 44 private: |
| 46 friend class BluetoothProfile; | 45 friend class BluetoothProfile; |
| 47 | 46 |
| 48 BluetoothProfileChromeOS(); | 47 BluetoothProfileChromeOS(); |
| 49 virtual ~BluetoothProfileChromeOS(); | 48 virtual ~BluetoothProfileChromeOS(); |
| 50 | 49 |
| 51 // Called by BluetoothProfile::Register to initialize the profile object | 50 // Called by BluetoothProfile::Register to initialize the profile object |
| 52 // asynchronously. |uuid|, |options| and |callback| are the arguments to | 51 // asynchronously. |uuid|, |options| and |callback| are the arguments to |
| 53 // BluetoothProfile::Register. | 52 // BluetoothProfile::Register. |
| 54 void Init(const device::BluetoothUUID& uuid, | 53 void Init(const std::string& uuid, |
| 55 const device::BluetoothProfile::Options& options, | 54 const device::BluetoothProfile::Options& options, |
| 56 const ProfileCallback& callback); | 55 const ProfileCallback& callback); |
| 57 | 56 |
| 58 // BluetoothProfileServiceProvider::Delegate override. | 57 // BluetoothProfileServiceProvider::Delegate override. |
| 59 virtual void Release() OVERRIDE; | 58 virtual void Release() OVERRIDE; |
| 60 virtual void NewConnection( | 59 virtual void NewConnection( |
| 61 const dbus::ObjectPath& device_path, | 60 const dbus::ObjectPath& device_path, |
| 62 scoped_ptr<dbus::FileDescriptor> fd, | 61 scoped_ptr<dbus::FileDescriptor> fd, |
| 63 const BluetoothProfileServiceProvider::Delegate::Options& options, | 62 const BluetoothProfileServiceProvider::Delegate::Options& options, |
| 64 const ConfirmationCallback& callback) OVERRIDE; | 63 const ConfirmationCallback& callback) OVERRIDE; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // | 98 // |
| 100 // The |fd| argument is moved compared to the NewConnection() call since it | 99 // The |fd| argument is moved compared to the NewConnection() call since it |
| 101 // becomes the result of a PostTaskAndReplyWithResult() call. | 100 // becomes the result of a PostTaskAndReplyWithResult() call. |
| 102 void OnCheckValidity( | 101 void OnCheckValidity( |
| 103 const dbus::ObjectPath& device_path, | 102 const dbus::ObjectPath& device_path, |
| 104 const BluetoothProfileServiceProvider::Delegate::Options& options, | 103 const BluetoothProfileServiceProvider::Delegate::Options& options, |
| 105 const ConfirmationCallback& callback, | 104 const ConfirmationCallback& callback, |
| 106 scoped_ptr<dbus::FileDescriptor> fd); | 105 scoped_ptr<dbus::FileDescriptor> fd); |
| 107 | 106 |
| 108 // UUID of the profile passed during initialization. | 107 // UUID of the profile passed during initialization. |
| 109 device::BluetoothUUID uuid_; | 108 std::string uuid_; |
| 110 | 109 |
| 111 // Copy of the profile options passed during initialization. | 110 // Copy of the profile options passed during initialization. |
| 112 BluetoothProfileManagerClient::Options options_; | 111 BluetoothProfileManagerClient::Options options_; |
| 113 | 112 |
| 114 // Object path of the local profile D-Bus object. | 113 // Object path of the local profile D-Bus object. |
| 115 dbus::ObjectPath object_path_; | 114 dbus::ObjectPath object_path_; |
| 116 | 115 |
| 117 // Local profile D-Bus object used for receiving profile delegate methods | 116 // Local profile D-Bus object used for receiving profile delegate methods |
| 118 // from BlueZ. | 117 // from BlueZ. |
| 119 scoped_ptr<BluetoothProfileServiceProvider> profile_; | 118 scoped_ptr<BluetoothProfileServiceProvider> profile_; |
| 120 | 119 |
| 121 // Reference to the adapter object, the profile is re-registered when the | 120 // Reference to the adapter object, the profile is re-registered when the |
| 122 // adapter changes. | 121 // adapter changes. |
| 123 scoped_refptr<device::BluetoothAdapter> adapter_; | 122 scoped_refptr<device::BluetoothAdapter> adapter_; |
| 124 | 123 |
| 125 // Callback used on both outgoing and incoming connections to pass the | 124 // Callback used on both outgoing and incoming connections to pass the |
| 126 // connected socket to profile object owner. | 125 // connected socket to profile object owner. |
| 127 ConnectionCallback connection_callback_; | 126 ConnectionCallback connection_callback_; |
| 128 | 127 |
| 129 // Note: This should remain the last member so it'll be destroyed and | 128 // Note: This should remain the last member so it'll be destroyed and |
| 130 // invalidate its weak pointers before any other members are destroyed. | 129 // invalidate its weak pointers before any other members are destroyed. |
| 131 base::WeakPtrFactory<BluetoothProfileChromeOS> weak_ptr_factory_; | 130 base::WeakPtrFactory<BluetoothProfileChromeOS> weak_ptr_factory_; |
| 132 | 131 |
| 133 DISALLOW_COPY_AND_ASSIGN(BluetoothProfileChromeOS); | 132 DISALLOW_COPY_AND_ASSIGN(BluetoothProfileChromeOS); |
| 134 }; | 133 }; |
| 135 | 134 |
| 136 } // namespace chromeos | 135 } // namespace chromeos |
| 137 | 136 |
| 138 #endif // DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_CHROMEOS_H_ | 137 #endif // DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_CHROMEOS_H_ |
| OLD | NEW |