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