Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | |
| 15 #include "base/string16.h" | 16 #include "base/string16.h" |
| 16 #include "chromeos/dbus/bluetooth_agent_service_provider.h" | 17 #include "chromeos/dbus/bluetooth_agent_service_provider.h" |
| 17 #include "chromeos/dbus/bluetooth_device_client.h" | 18 #include "chromeos/dbus/bluetooth_device_client.h" |
| 18 #include "dbus/object_path.h" | 19 #include "dbus/object_path.h" |
| 19 | 20 |
| 20 namespace chromeos { | 21 namespace chromeos { |
| 21 | 22 |
| 22 class BluetoothAdapter; | 23 class BluetoothAdapter; |
| 24 class BluetoothSocket; | |
| 23 | 25 |
| 24 // The BluetoothDevice class represents a remote Bluetooth device, both | 26 // The BluetoothDevice class represents a remote Bluetooth device, both |
| 25 // its properties and capabilities as discovered by a local adapter and | 27 // its properties and capabilities as discovered by a local adapter and |
| 26 // actions that may be performed on the remove device such as pairing, | 28 // actions that may be performed on the remove device such as pairing, |
| 27 // connection and disconnection. | 29 // connection and disconnection. |
| 28 // | 30 // |
| 29 // The class is instantiated and managed by the BluetoothAdapter class | 31 // The class is instantiated and managed by the BluetoothAdapter class |
| 30 // and pointers should only be obtained from that class and not cached, | 32 // and pointers should only be obtained from that class and not cached, |
| 31 // instead use the address() method as a unique key for a device. | 33 // instead use the address() method as a unique key for a device. |
| 32 // | 34 // |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 // If the request fails, |error_callback| will be called. | 240 // If the request fails, |error_callback| will be called. |
| 239 void Disconnect(ErrorCallback error_callback); | 241 void Disconnect(ErrorCallback error_callback); |
| 240 | 242 |
| 241 // Disconnects the device, terminating the low-level ACL connection | 243 // Disconnects the device, terminating the low-level ACL connection |
| 242 // and any application connections using it, and then discards link keys | 244 // and any application connections using it, and then discards link keys |
| 243 // and other pairing information. The device object remainds valid until | 245 // and other pairing information. The device object remainds valid until |
| 244 // returing from the calling function, after which it should be assumed to | 246 // returing from the calling function, after which it should be assumed to |
| 245 // have been deleted. If the request fails, |error_callback| will be called. | 247 // have been deleted. If the request fails, |error_callback| will be called. |
| 246 void Forget(ErrorCallback error_callback); | 248 void Forget(ErrorCallback error_callback); |
| 247 | 249 |
| 250 // Attempts to open a socket to a service matching |uuid| on this device. If | |
| 251 // the connection is successful, |callback| is called with a BluetoothSocket. | |
| 252 // Otherwise |callback| is called with NULL. The socket is closed as soon as | |
| 253 // all references to the BluetoothSocket are released. | |
| 254 void ConnectToService(const std::string& service_uuid, | |
| 255 base::Callback<void(scoped_refptr<BluetoothSocket>)> callback); | |
|
keybuk
2012/04/19 01:05:40
Comment should explain ownership, that the socket
bryeung
2012/04/19 19:42:43
Done.
| |
| 256 | |
| 248 private: | 257 private: |
| 249 friend class BluetoothAdapter; | 258 friend class BluetoothAdapter; |
| 250 | 259 |
| 251 explicit BluetoothDevice(BluetoothAdapter* adapter); | 260 explicit BluetoothDevice(BluetoothAdapter* adapter); |
| 252 | 261 |
| 253 // Sets the dbus object path for the device to |object_path|, indicating | 262 // Sets the dbus object path for the device to |object_path|, indicating |
| 254 // that the device has gone from being discovered to paired or bonded. | 263 // that the device has gone from being discovered to paired or bonded. |
| 255 void SetObjectPath(const dbus::ObjectPath& object_path); | 264 void SetObjectPath(const dbus::ObjectPath& object_path); |
| 256 | 265 |
| 257 // Updates device information from the properties in |properties|, device | 266 // Updates device information from the properties in |properties|, device |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 const dbus::ObjectPath& adapter_path, bool success); | 321 const dbus::ObjectPath& adapter_path, bool success); |
| 313 | 322 |
| 314 // Called by BluetoothDeviceClient when a call to DiscoverServices() that was | 323 // Called by BluetoothDeviceClient when a call to DiscoverServices() that was |
| 315 // initated from ProvidesServiceWithName completes. The |result_callback| is | 324 // initated from ProvidesServiceWithName completes. The |result_callback| is |
| 316 // called with true iff a service with name matching |name| is discovered. | 325 // called with true iff a service with name matching |name| is discovered. |
| 317 // The rest of the parameters are as documented for a | 326 // The rest of the parameters are as documented for a |
| 318 // BluetoothDeviceClient::ServicesCallback. | 327 // BluetoothDeviceClient::ServicesCallback. |
| 319 void SearchServicesForNameCallback( | 328 void SearchServicesForNameCallback( |
| 320 const std::string& name, | 329 const std::string& name, |
| 321 base::Callback<void(bool)> result_callback, | 330 base::Callback<void(bool)> result_callback, |
| 322 const dbus::ObjectPath &object_path, | 331 const dbus::ObjectPath& object_path, |
| 323 const BluetoothDeviceClient::ServiceMap& service_map, | 332 const BluetoothDeviceClient::ServiceMap& service_map, |
| 324 bool success); | 333 bool success); |
| 325 | 334 |
| 335 // Opens a socket to this device on the provided |channel|. | |
| 336 scoped_refptr<BluetoothSocket> OpenSocket(const std::string& service_uuid, | |
| 337 uint8_t channel); | |
|
keybuk
2012/04/19 01:05:40
this seems RFCOMM specific (channel), L2CAP uses P
bryeung
2012/04/19 19:42:43
Yep: I was going to make it more generic when I ad
| |
| 338 | |
| 339 // Called by BluetoothDeviceClient when a call to DiscoverServices() that was | |
| 340 // initated from ConnectToService completes. The |callback| is called with | |
| 341 // true iff a connection was successfully established. The rest of the | |
| 342 // parameters are as documented for a BluetoothDeviceClient::ServicesCallback. | |
| 343 void ConnectToMatchingService( | |
| 344 const std::string& service_uuid, | |
| 345 base::Callback<void(scoped_refptr<BluetoothSocket>)> callback, | |
|
keybuk
2012/04/19 01:05:40
typedef
bryeung
2012/04/19 19:42:43
Done.
| |
| 346 const dbus::ObjectPath& object_path, | |
| 347 const BluetoothDeviceClient::ServiceMap& service_map, | |
| 348 bool success); | |
| 349 | |
| 326 // BluetoothDeviceClient::Observer override. | 350 // BluetoothDeviceClient::Observer override. |
| 327 // | 351 // |
| 328 // Called when the device with object path |object_path| is about | 352 // Called when the device with object path |object_path| is about |
| 329 // to be disconnected, giving a chance for application layers to | 353 // to be disconnected, giving a chance for application layers to |
| 330 // shut down cleanly. | 354 // shut down cleanly. |
| 331 virtual void DisconnectRequested( | 355 virtual void DisconnectRequested( |
| 332 const dbus::ObjectPath& object_path) OVERRIDE; | 356 const dbus::ObjectPath& object_path) OVERRIDE; |
| 333 | 357 |
| 334 // BluetoothAgentServiceProvider::Delegate override. | 358 // BluetoothAgentServiceProvider::Delegate override. |
| 335 // | 359 // |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 PinCodeCallback pincode_callback_; | 520 PinCodeCallback pincode_callback_; |
| 497 PasskeyCallback passkey_callback_; | 521 PasskeyCallback passkey_callback_; |
| 498 ConfirmationCallback confirmation_callback_; | 522 ConfirmationCallback confirmation_callback_; |
| 499 | 523 |
| 500 DISALLOW_COPY_AND_ASSIGN(BluetoothDevice); | 524 DISALLOW_COPY_AND_ASSIGN(BluetoothDevice); |
| 501 }; | 525 }; |
| 502 | 526 |
| 503 } // namespace chromeos | 527 } // namespace chromeos |
| 504 | 528 |
| 505 #endif // CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 529 #endif // CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| OLD | NEW |