| 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_export.h" | 16 #include "device/bluetooth/bluetooth_export.h" |
| 17 #include "device/bluetooth/bluetooth_uuid.h" | 17 #include "device/bluetooth/bluetooth_uuid.h" |
| 18 #include "net/log/net_log.h" | 18 #include "net/log/net_log.h" |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class BinaryValue; | 21 class BinaryValue; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace device { | 24 namespace device { |
| 25 | 25 |
| 26 class BluetoothAdapter; |
| 26 class BluetoothGattConnection; | 27 class BluetoothGattConnection; |
| 27 class BluetoothGattService; | 28 class BluetoothGattService; |
| 28 class BluetoothSocket; | 29 class BluetoothSocket; |
| 29 class BluetoothUUID; | 30 class BluetoothUUID; |
| 30 | 31 |
| 31 // BluetoothDevice represents a remote Bluetooth device, both its properties and | 32 // BluetoothDevice represents a remote Bluetooth device, both its properties and |
| 32 // capabilities as discovered by a local adapter and actions that may be | 33 // capabilities as discovered by a local adapter and actions that may be |
| 33 // performed on the remove device such as pairing, connection and disconnection. | 34 // performed on the remove device such as pairing, connection and disconnection. |
| 34 // | 35 // |
| 35 // The class is instantiated and managed by the BluetoothAdapter class | 36 // The class is instantiated and managed by the BluetoothAdapter class |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 | 424 |
| 424 // Returns the list UUIDs of services that have service data. | 425 // Returns the list UUIDs of services that have service data. |
| 425 virtual UUIDList GetServiceDataUUIDs() const; | 426 virtual UUIDList GetServiceDataUUIDs() const; |
| 426 | 427 |
| 427 // Returns the |address| in the canonical format: XX:XX:XX:XX:XX:XX, where | 428 // Returns the |address| in the canonical format: XX:XX:XX:XX:XX:XX, where |
| 428 // each 'X' is a hex digit. If the input |address| is invalid, returns an | 429 // each 'X' is a hex digit. If the input |address| is invalid, returns an |
| 429 // empty string. | 430 // empty string. |
| 430 static std::string CanonicalizeAddress(const std::string& address); | 431 static std::string CanonicalizeAddress(const std::string& address); |
| 431 | 432 |
| 432 protected: | 433 protected: |
| 433 BluetoothDevice(); | 434 BluetoothDevice(BluetoothAdapter* adapter); |
| 434 | 435 |
| 435 // Returns the internal name of the Bluetooth device, used by GetName(). | 436 // Returns the internal name of the Bluetooth device, used by GetName(). |
| 436 virtual std::string GetDeviceName() const = 0; | 437 virtual std::string GetDeviceName() const = 0; |
| 437 | 438 |
| 438 // Clears the list of service data. | 439 // Clears the list of service data. |
| 439 void ClearServiceData(); | 440 void ClearServiceData(); |
| 440 | 441 |
| 441 // Set the data of a given service designated by its UUID. | 442 // Set the data of a given service designated by its UUID. |
| 442 void SetServiceData(BluetoothUUID serviceUUID, const char* buffer, | 443 void SetServiceData(BluetoothUUID serviceUUID, const char* buffer, |
| 443 size_t size); | 444 size_t size); |
| 444 | 445 |
| 446 // Raw pointer to adapter owning this device object. Subclasses use platform |
| 447 // specific pointers via adapter_. |
| 448 BluetoothAdapter* adapter_; |
| 449 |
| 445 // Mapping from the platform-specific GATT service identifiers to | 450 // Mapping from the platform-specific GATT service identifiers to |
| 446 // BluetoothGattService objects. | 451 // BluetoothGattService objects. |
| 447 typedef std::map<std::string, BluetoothGattService*> GattServiceMap; | 452 typedef std::map<std::string, BluetoothGattService*> GattServiceMap; |
| 448 GattServiceMap gatt_services_; | 453 GattServiceMap gatt_services_; |
| 449 | 454 |
| 450 // Mapping from service UUID represented as a std::string of a bluetooth | 455 // Mapping from service UUID represented as a std::string of a bluetooth |
| 451 // service to | 456 // service to |
| 452 // the specific data. The data is stored as BinaryValue. | 457 // the specific data. The data is stored as BinaryValue. |
| 453 scoped_ptr<base::DictionaryValue> services_data_; | 458 scoped_ptr<base::DictionaryValue> services_data_; |
| 454 | 459 |
| 455 private: | 460 private: |
| 456 // Returns a localized string containing the device's bluetooth address and | 461 // Returns a localized string containing the device's bluetooth address and |
| 457 // a device type for display when |name_| is empty. | 462 // a device type for display when |name_| is empty. |
| 458 base::string16 GetAddressWithLocalizedDeviceTypeName() const; | 463 base::string16 GetAddressWithLocalizedDeviceTypeName() const; |
| 459 }; | 464 }; |
| 460 | 465 |
| 461 } // namespace device | 466 } // namespace device |
| 462 | 467 |
| 463 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 468 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| OLD | NEW |