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 "net/base/net_log.h" |
14 | 15 |
15 namespace device { | 16 namespace device { |
16 | 17 |
17 class BluetoothProfile; | 18 class BluetoothProfile; |
18 class BluetoothServiceRecord; | 19 class BluetoothServiceRecord; |
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 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 // all references to the BluetoothSocket are released. Note that the | 350 // all references to the BluetoothSocket are released. Note that the |
350 // BluetoothSocket object can outlive both this BluetoothDevice and the | 351 // BluetoothSocket object can outlive both this BluetoothDevice and the |
351 // BluetoothAdapter for this device. | 352 // BluetoothAdapter for this device. |
352 virtual void ConnectToService(const std::string& service_uuid, | 353 virtual void ConnectToService(const std::string& service_uuid, |
353 const SocketCallback& callback) = 0; | 354 const SocketCallback& callback) = 0; |
354 | 355 |
355 // Attempts to initiate an outgoing connection to this device for the profile | 356 // Attempts to initiate an outgoing connection to this device for the profile |
356 // identified by |profile|, on success the profile's connection callback | 357 // identified by |profile|, on success the profile's connection callback |
357 // will be called as well as |callback|; on failure |error_callback| will be | 358 // will be called as well as |callback|; on failure |error_callback| will be |
358 // called. | 359 // called. |
359 virtual void ConnectToProfile(BluetoothProfile* profile, | 360 typedef base::Callback<void(const std::string&)> |
360 const base::Closure& callback, | 361 ConnectToProfileErrorCallback; |
361 const ErrorCallback& error_callback) = 0; | 362 virtual void ConnectToProfile( |
| 363 BluetoothProfile* profile, |
| 364 const base::Closure& callback, |
| 365 const ConnectToProfileErrorCallback& error_callback) = 0; |
362 | 366 |
363 // Sets the Out Of Band pairing data for this device to |data|. Exactly one | 367 // Sets the Out Of Band pairing data for this device to |data|. Exactly one |
364 // of |callback| or |error_callback| will be run. | 368 // of |callback| or |error_callback| will be run. |
365 virtual void SetOutOfBandPairingData( | 369 virtual void SetOutOfBandPairingData( |
366 const BluetoothOutOfBandPairingData& data, | 370 const BluetoothOutOfBandPairingData& data, |
367 const base::Closure& callback, | 371 const base::Closure& callback, |
368 const ErrorCallback& error_callback) = 0; | 372 const ErrorCallback& error_callback) = 0; |
369 | 373 |
370 // Clears the Out Of Band pairing data for this device. Exactly one of | 374 // Clears the Out Of Band pairing data for this device. Exactly one of |
371 // |callback| or |error_callback| will be run. | 375 // |callback| or |error_callback| will be run. |
372 virtual void ClearOutOfBandPairingData( | 376 virtual void ClearOutOfBandPairingData( |
373 const base::Closure& callback, | 377 const base::Closure& callback, |
374 const ErrorCallback& error_callback) = 0; | 378 const ErrorCallback& error_callback) = 0; |
375 | 379 |
376 protected: | 380 protected: |
377 BluetoothDevice(); | 381 BluetoothDevice(); |
378 | 382 |
379 // Returns the internal name of the Bluetooth device, used by GetName(). | 383 // Returns the internal name of the Bluetooth device, used by GetName(). |
380 virtual std::string GetDeviceName() const = 0; | 384 virtual std::string GetDeviceName() const = 0; |
381 | 385 |
382 private: | 386 private: |
383 // Returns a localized string containing the device's bluetooth address and | 387 // Returns a localized string containing the device's bluetooth address and |
384 // a device type for display when |name_| is empty. | 388 // a device type for display when |name_| is empty. |
385 base::string16 GetAddressWithLocalizedDeviceTypeName() const; | 389 base::string16 GetAddressWithLocalizedDeviceTypeName() const; |
386 }; | 390 }; |
387 | 391 |
388 } // namespace device | 392 } // namespace device |
389 | 393 |
390 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 394 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
OLD | NEW |