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