| 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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "device/bluetooth/bluetooth_uuid.h" | 16 #include "device/bluetooth/bluetooth_uuid.h" |
| 17 #include "net/base/net_log.h" | 17 #include "net/base/net_log.h" |
| 18 | 18 |
| 19 namespace device { | 19 namespace device { |
| 20 | 20 |
| 21 class BluetoothGattService; | 21 class BluetoothGattService; |
| 22 class BluetoothProfile; | 22 class BluetoothProfile; |
| 23 class BluetoothSocket; | 23 class BluetoothSocket; |
| 24 class BluetoothUUID; | 24 class BluetoothUUID; |
| 25 | 25 |
| 26 struct BluetoothOutOfBandPairingData; | |
| 27 | |
| 28 // BluetoothDevice represents a remote Bluetooth device, both its properties and | 26 // BluetoothDevice represents a remote Bluetooth device, both its properties and |
| 29 // capabilities as discovered by a local adapter and actions that may be | 27 // capabilities as discovered by a local adapter and actions that may be |
| 30 // performed on the remove device such as pairing, connection and disconnection. | 28 // performed on the remove device such as pairing, connection and disconnection. |
| 31 // | 29 // |
| 32 // The class is instantiated and managed by the BluetoothAdapter class | 30 // The class is instantiated and managed by the BluetoothAdapter class |
| 33 // and pointers should only be obtained from that class and not cached, | 31 // and pointers should only be obtained from that class and not cached, |
| 34 // instead use the GetAddress() method as a unique key for a device. | 32 // instead use the GetAddress() method as a unique key for a device. |
| 35 // | 33 // |
| 36 // Since the lifecycle of BluetoothDevice instances is managed by | 34 // Since the lifecycle of BluetoothDevice instances is managed by |
| 37 // BluetoothAdapter, that class rather than this provides observer methods | 35 // BluetoothAdapter, that class rather than this provides observer methods |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 // cause. | 386 // cause. |
| 389 typedef base::Callback<void(scoped_refptr<BluetoothSocket>)> | 387 typedef base::Callback<void(scoped_refptr<BluetoothSocket>)> |
| 390 ConnectToServiceCallback; | 388 ConnectToServiceCallback; |
| 391 typedef base::Callback<void(const std::string& message)> | 389 typedef base::Callback<void(const std::string& message)> |
| 392 ConnectToServiceErrorCallback; | 390 ConnectToServiceErrorCallback; |
| 393 virtual void ConnectToService( | 391 virtual void ConnectToService( |
| 394 const BluetoothUUID& uuid, | 392 const BluetoothUUID& uuid, |
| 395 const ConnectToServiceCallback& callback, | 393 const ConnectToServiceCallback& callback, |
| 396 const ConnectToServiceErrorCallback& error_callback) = 0; | 394 const ConnectToServiceErrorCallback& error_callback) = 0; |
| 397 | 395 |
| 398 // Sets the Out Of Band pairing data for this device to |data|. Exactly one | |
| 399 // of |callback| or |error_callback| will be run. | |
| 400 virtual void SetOutOfBandPairingData( | |
| 401 const BluetoothOutOfBandPairingData& data, | |
| 402 const base::Closure& callback, | |
| 403 const ErrorCallback& error_callback) = 0; | |
| 404 | |
| 405 // Clears the Out Of Band pairing data for this device. Exactly one of | |
| 406 // |callback| or |error_callback| will be run. | |
| 407 virtual void ClearOutOfBandPairingData( | |
| 408 const base::Closure& callback, | |
| 409 const ErrorCallback& error_callback) = 0; | |
| 410 | |
| 411 // Starts monitoring the connection properties, RSSI and TX power. These | 396 // Starts monitoring the connection properties, RSSI and TX power. These |
| 412 // properties will be tracked, and updated when their values change. Exactly | 397 // properties will be tracked, and updated when their values change. Exactly |
| 413 // one of |callback| or |error_callback| will be run. | 398 // one of |callback| or |error_callback| will be run. |
| 414 virtual void StartConnectionMonitor(const base::Closure& callback, | 399 virtual void StartConnectionMonitor(const base::Closure& callback, |
| 415 const ErrorCallback& error_callback) = 0; | 400 const ErrorCallback& error_callback) = 0; |
| 416 | 401 |
| 417 // Returns the list of discovered GATT services. | 402 // Returns the list of discovered GATT services. |
| 418 virtual std::vector<BluetoothGattService*> GetGattServices() const; | 403 virtual std::vector<BluetoothGattService*> GetGattServices() const; |
| 419 | 404 |
| 420 // Returns the GATT service with device-specific identifier |identifier|. | 405 // Returns the GATT service with device-specific identifier |identifier|. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 440 | 425 |
| 441 private: | 426 private: |
| 442 // Returns a localized string containing the device's bluetooth address and | 427 // Returns a localized string containing the device's bluetooth address and |
| 443 // a device type for display when |name_| is empty. | 428 // a device type for display when |name_| is empty. |
| 444 base::string16 GetAddressWithLocalizedDeviceTypeName() const; | 429 base::string16 GetAddressWithLocalizedDeviceTypeName() const; |
| 445 }; | 430 }; |
| 446 | 431 |
| 447 } // namespace device | 432 } // namespace device |
| 448 | 433 |
| 449 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 434 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| OLD | NEW |