| 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 DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "device/bluetooth/bluetooth_uuid.h" | 14 #include "device/bluetooth/bluetooth_uuid.h" |
| 15 #include "net/base/net_log.h" | |
| 16 | 15 |
| 17 namespace device { | 16 namespace device { |
| 18 | 17 |
| 19 class BluetoothProfile; | 18 class BluetoothProfile; |
| 20 class BluetoothSocket; | 19 class BluetoothSocket; |
| 21 | 20 |
| 22 struct BluetoothOutOfBandPairingData; | 21 struct BluetoothOutOfBandPairingData; |
| 23 | 22 |
| 24 // BluetoothDevice represents a remote Bluetooth device, both its properties and | 23 // BluetoothDevice represents a remote Bluetooth device, both its properties and |
| 25 // capabilities as discovered by a local adapter and actions that may be | 24 // capabilities as discovered by a local adapter and actions that may be |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // all references to the BluetoothSocket are released. Note that the | 328 // all references to the BluetoothSocket are released. Note that the |
| 330 // BluetoothSocket object can outlive both this BluetoothDevice and the | 329 // BluetoothSocket object can outlive both this BluetoothDevice and the |
| 331 // BluetoothAdapter for this device. | 330 // BluetoothAdapter for this device. |
| 332 virtual void ConnectToService(const BluetoothUUID& service_uuid, | 331 virtual void ConnectToService(const BluetoothUUID& service_uuid, |
| 333 const SocketCallback& callback) = 0; | 332 const SocketCallback& callback) = 0; |
| 334 | 333 |
| 335 // Attempts to initiate an outgoing connection to this device for the profile | 334 // Attempts to initiate an outgoing connection to this device for the profile |
| 336 // identified by |profile|, on success the profile's connection callback | 335 // identified by |profile|, on success the profile's connection callback |
| 337 // will be called as well as |callback|; on failure |error_callback| will be | 336 // will be called as well as |callback|; on failure |error_callback| will be |
| 338 // called. | 337 // called. |
| 339 typedef base::Callback<void(const std::string&)> | 338 virtual void ConnectToProfile(BluetoothProfile* profile, |
| 340 ConnectToProfileErrorCallback; | 339 const base::Closure& callback, |
| 341 virtual void ConnectToProfile( | 340 const ErrorCallback& error_callback) = 0; |
| 342 BluetoothProfile* profile, | |
| 343 const base::Closure& callback, | |
| 344 const ConnectToProfileErrorCallback& error_callback) = 0; | |
| 345 | 341 |
| 346 // Sets the Out Of Band pairing data for this device to |data|. Exactly one | 342 // Sets the Out Of Band pairing data for this device to |data|. Exactly one |
| 347 // of |callback| or |error_callback| will be run. | 343 // of |callback| or |error_callback| will be run. |
| 348 virtual void SetOutOfBandPairingData( | 344 virtual void SetOutOfBandPairingData( |
| 349 const BluetoothOutOfBandPairingData& data, | 345 const BluetoothOutOfBandPairingData& data, |
| 350 const base::Closure& callback, | 346 const base::Closure& callback, |
| 351 const ErrorCallback& error_callback) = 0; | 347 const ErrorCallback& error_callback) = 0; |
| 352 | 348 |
| 353 // Clears the Out Of Band pairing data for this device. Exactly one of | 349 // Clears the Out Of Band pairing data for this device. Exactly one of |
| 354 // |callback| or |error_callback| will be run. | 350 // |callback| or |error_callback| will be run. |
| 355 virtual void ClearOutOfBandPairingData( | 351 virtual void ClearOutOfBandPairingData( |
| 356 const base::Closure& callback, | 352 const base::Closure& callback, |
| 357 const ErrorCallback& error_callback) = 0; | 353 const ErrorCallback& error_callback) = 0; |
| 358 | 354 |
| 359 protected: | 355 protected: |
| 360 BluetoothDevice(); | 356 BluetoothDevice(); |
| 361 | 357 |
| 362 // Returns the internal name of the Bluetooth device, used by GetName(). | 358 // Returns the internal name of the Bluetooth device, used by GetName(). |
| 363 virtual std::string GetDeviceName() const = 0; | 359 virtual std::string GetDeviceName() const = 0; |
| 364 | 360 |
| 365 private: | 361 private: |
| 366 // Returns a localized string containing the device's bluetooth address and | 362 // Returns a localized string containing the device's bluetooth address and |
| 367 // a device type for display when |name_| is empty. | 363 // a device type for display when |name_| is empty. |
| 368 base::string16 GetAddressWithLocalizedDeviceTypeName() const; | 364 base::string16 GetAddressWithLocalizedDeviceTypeName() const; |
| 369 }; | 365 }; |
| 370 | 366 |
| 371 } // namespace device | 367 } // namespace device |
| 372 | 368 |
| 373 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 369 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| OLD | NEW |