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_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_ | 5 #ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_ |
6 #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_ | 6 #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <cstdint> |
9 | |
10 #include <memory> | 9 #include <memory> |
11 #include <string> | 10 #include <string> |
12 #include <vector> | 11 #include <vector> |
13 | 12 |
14 #include "base/callback.h" | 13 #include "base/callback.h" |
xiyuan
2016/06/22 15:53:06
Move to cc since we include callback_forward.h her
rkc
2016/06/22 21:06:38
Done.
| |
14 #include "base/callback_forward.h" | |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/observer_list.h" | |
17 #include "base/values.h" | |
18 #include "dbus/object_path.h" | 16 #include "dbus/object_path.h" |
17 #include "dbus/object_proxy.h" | |
xiyuan
2016/06/22 15:53:06
nit: forward declare dbus::ObjectProxy and move th
rkc
2016/06/22 21:06:37
Done.
| |
19 #include "dbus/property.h" | 18 #include "dbus/property.h" |
20 #include "device/bluetooth/bluetooth_export.h" | 19 #include "device/bluetooth/bluetooth_export.h" |
21 #include "device/bluetooth/dbus/bluez_dbus_client.h" | 20 #include "device/bluetooth/dbus/bluez_dbus_client.h" |
22 | 21 |
23 namespace bluez { | 22 namespace bluez { |
24 | 23 |
24 class BluetoothServiceRecordBlueZ; | |
25 | |
25 // BluetoothAdapterClient is used to communicate with objects representing | 26 // BluetoothAdapterClient is used to communicate with objects representing |
26 // local Bluetooth Adapters. | 27 // local Bluetooth Adapters. |
27 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterClient : public BluezDBusClient { | 28 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterClient : public BluezDBusClient { |
28 public: | 29 public: |
29 // A DiscoveryFilter represents a filter passed to the SetDiscoveryFilter | 30 // A DiscoveryFilter represents a filter passed to the SetDiscoveryFilter |
30 // method. | 31 // method. |
31 struct DiscoveryFilter { | 32 struct DiscoveryFilter { |
32 DiscoveryFilter(); | 33 DiscoveryFilter(); |
33 ~DiscoveryFilter(); | 34 ~DiscoveryFilter(); |
34 | 35 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 virtual void AddObserver(Observer* observer) = 0; | 128 virtual void AddObserver(Observer* observer) = 0; |
128 virtual void RemoveObserver(Observer* observer) = 0; | 129 virtual void RemoveObserver(Observer* observer) = 0; |
129 | 130 |
130 // Returns the list of adapter object paths known to the system. | 131 // Returns the list of adapter object paths known to the system. |
131 virtual std::vector<dbus::ObjectPath> GetAdapters() = 0; | 132 virtual std::vector<dbus::ObjectPath> GetAdapters() = 0; |
132 | 133 |
133 // Obtain the properties for the adapter with object path |object_path|, | 134 // Obtain the properties for the adapter with object path |object_path|, |
134 // any values should be copied if needed. | 135 // any values should be copied if needed. |
135 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0; | 136 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0; |
136 | 137 |
138 // Callback used to send back the handle of a created service record. | |
139 using ServiceRecordCallback = base::Callback<void(uint32_t)>; | |
140 | |
137 // The ErrorCallback is used by adapter methods to indicate failure. | 141 // The ErrorCallback is used by adapter methods to indicate failure. |
138 // It receives two arguments: the name of the error in |error_name| and | 142 // It receives two arguments: the name of the error in |error_name| and |
139 // an optional message in |error_message|. | 143 // an optional message in |error_message|. |
140 typedef base::Callback<void(const std::string& error_name, | 144 typedef base::Callback<void(const std::string& error_name, |
141 const std::string& error_message)> ErrorCallback; | 145 const std::string& error_message)> ErrorCallback; |
142 | 146 |
143 // Starts a device discovery on the adapter with object path |object_path|. | 147 // Starts a device discovery on the adapter with object path |object_path|. |
144 virtual void StartDiscovery(const dbus::ObjectPath& object_path, | 148 virtual void StartDiscovery(const dbus::ObjectPath& object_path, |
145 const base::Closure& callback, | 149 const base::Closure& callback, |
146 const ErrorCallback& error_callback) = 0; | 150 const ErrorCallback& error_callback) = 0; |
(...skipping 16 matching lines...) Expand all Loading... | |
163 // |object_path|. When this method is called with no filter parameter, filter | 167 // |object_path|. When this method is called with no filter parameter, filter |
164 // is removed. | 168 // is removed. |
165 // SetDiscoveryFilter can be called before StartDiscovery. It is useful when | 169 // SetDiscoveryFilter can be called before StartDiscovery. It is useful when |
166 // client will create first discovery session, to ensure that proper scan | 170 // client will create first discovery session, to ensure that proper scan |
167 // will be started right after call to StartDiscovery. | 171 // will be started right after call to StartDiscovery. |
168 virtual void SetDiscoveryFilter(const dbus::ObjectPath& object_path, | 172 virtual void SetDiscoveryFilter(const dbus::ObjectPath& object_path, |
169 const DiscoveryFilter& discovery_filter, | 173 const DiscoveryFilter& discovery_filter, |
170 const base::Closure& callback, | 174 const base::Closure& callback, |
171 const ErrorCallback& error_callback) = 0; | 175 const ErrorCallback& error_callback) = 0; |
172 | 176 |
177 // Creates the service record |record| on the adapter with the object path | |
178 // |object_path|. | |
179 virtual void CreateServiceRecord(const dbus::ObjectPath& object_path, | |
180 const BluetoothServiceRecordBlueZ& record, | |
181 const ServiceRecordCallback& callback, | |
182 const ErrorCallback& error_callback) = 0; | |
183 | |
184 // Removes the service record with the uuid |uuid| on the adapter with the | |
185 // object path |object_path|. | |
186 virtual void RemoveServiceRecord(const dbus::ObjectPath& object_path, | |
187 uint32_t handle, | |
188 const base::Closure& callback, | |
189 const ErrorCallback& error_callback) = 0; | |
190 | |
173 // Creates the instance. | 191 // Creates the instance. |
174 static BluetoothAdapterClient* Create(); | 192 static BluetoothAdapterClient* Create(); |
175 | 193 |
176 // Constants used to indicate exceptional error conditions. | 194 // Constants used to indicate exceptional error conditions. |
177 static const char kNoResponseError[]; | 195 static const char kNoResponseError[]; |
178 static const char kUnknownAdapterError[]; | 196 static const char kUnknownAdapterError[]; |
179 | 197 |
180 protected: | 198 protected: |
181 BluetoothAdapterClient(); | 199 BluetoothAdapterClient(); |
182 | 200 |
183 private: | 201 private: |
184 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterClient); | 202 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterClient); |
185 }; | 203 }; |
186 | 204 |
187 } // namespace bluez | 205 } // namespace bluez |
188 | 206 |
189 #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_ | 207 #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_ |
OLD | NEW |