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