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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "net/log/net_log.h" | 23 #include "net/log/net_log.h" |
24 | 24 |
25 namespace base { | 25 namespace base { |
26 class BinaryValue; | 26 class BinaryValue; |
27 } | 27 } |
28 | 28 |
29 namespace device { | 29 namespace device { |
30 | 30 |
31 class BluetoothAdapter; | 31 class BluetoothAdapter; |
32 class BluetoothGattConnection; | 32 class BluetoothGattConnection; |
33 class BluetoothGattService; | 33 class BluetoothRemoteGattService; |
34 class BluetoothSocket; | 34 class BluetoothSocket; |
35 class BluetoothUUID; | 35 class BluetoothUUID; |
36 | 36 |
37 // BluetoothDevice represents a remote Bluetooth device, both its properties and | 37 // BluetoothDevice represents a remote Bluetooth device, both its properties and |
38 // capabilities as discovered by a local adapter and actions that may be | 38 // capabilities as discovered by a local adapter and actions that may be |
39 // performed on the remove device such as pairing, connection and disconnection. | 39 // performed on the remove device such as pairing, connection and disconnection. |
40 // | 40 // |
41 // The class is instantiated and managed by the BluetoothAdapter class | 41 // The class is instantiated and managed by the BluetoothAdapter class |
42 // and pointers should only be obtained from that class and not cached, | 42 // and pointers should only be obtained from that class and not cached, |
43 // instead use the GetAddress() method as a unique key for a device. | 43 // instead use the GetAddress() method as a unique key for a device. |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 virtual void CreateGattConnection(const GattConnectionCallback& callback, | 443 virtual void CreateGattConnection(const GattConnectionCallback& callback, |
444 const ConnectErrorCallback& error_callback); | 444 const ConnectErrorCallback& error_callback); |
445 | 445 |
446 // Set the gatt services discovery complete flag for this device. | 446 // Set the gatt services discovery complete flag for this device. |
447 virtual void SetGattServicesDiscoveryComplete(bool complete); | 447 virtual void SetGattServicesDiscoveryComplete(bool complete); |
448 | 448 |
449 // Indicates whether service discovery is complete for this device. | 449 // Indicates whether service discovery is complete for this device. |
450 virtual bool IsGattServicesDiscoveryComplete() const; | 450 virtual bool IsGattServicesDiscoveryComplete() const; |
451 | 451 |
452 // Returns the list of discovered GATT services. | 452 // Returns the list of discovered GATT services. |
453 virtual std::vector<BluetoothGattService*> GetGattServices() const; | 453 virtual std::vector<BluetoothRemoteGattService*> GetGattServices() const; |
454 | 454 |
455 // Returns the GATT service with device-specific identifier |identifier|. | 455 // Returns the GATT service with device-specific identifier |identifier|. |
456 // Returns NULL, if no such service exists. | 456 // Returns NULL, if no such service exists. |
457 virtual BluetoothGattService* GetGattService( | 457 virtual BluetoothRemoteGattService* GetGattService( |
458 const std::string& identifier) const; | 458 const std::string& identifier) const; |
459 | 459 |
460 // Returns service data of a service given its UUID. | 460 // Returns service data of a service given its UUID. |
461 virtual base::BinaryValue* GetServiceData(BluetoothUUID serviceUUID) const; | 461 virtual base::BinaryValue* GetServiceData(BluetoothUUID serviceUUID) const; |
462 | 462 |
463 // Returns the list UUIDs of services that have service data. | 463 // Returns the list UUIDs of services that have service data. |
464 virtual UUIDList GetServiceDataUUIDs() const; | 464 virtual UUIDList GetServiceDataUUIDs() const; |
465 | 465 |
466 // Returns the |address| in the canonical format: XX:XX:XX:XX:XX:XX, where | 466 // Returns the |address| in the canonical format: XX:XX:XX:XX:XX:XX, where |
467 // each 'X' is a hex digit. If the input |address| is invalid, returns an | 467 // each 'X' is a hex digit. If the input |address| is invalid, returns an |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 BluetoothAdapter* adapter_; | 531 BluetoothAdapter* adapter_; |
532 | 532 |
533 // Callbacks for pending success and error result of CreateGattConnection. | 533 // Callbacks for pending success and error result of CreateGattConnection. |
534 std::vector<GattConnectionCallback> create_gatt_connection_success_callbacks_; | 534 std::vector<GattConnectionCallback> create_gatt_connection_success_callbacks_; |
535 std::vector<ConnectErrorCallback> create_gatt_connection_error_callbacks_; | 535 std::vector<ConnectErrorCallback> create_gatt_connection_error_callbacks_; |
536 | 536 |
537 // BluetoothGattConnection objects keeping the GATT connection alive. | 537 // BluetoothGattConnection objects keeping the GATT connection alive. |
538 std::set<BluetoothGattConnection*> gatt_connections_; | 538 std::set<BluetoothGattConnection*> gatt_connections_; |
539 | 539 |
540 // Mapping from the platform-specific GATT service identifiers to | 540 // Mapping from the platform-specific GATT service identifiers to |
541 // BluetoothGattService objects. | 541 // BluetoothRemoteGattService objects. |
542 typedef base::ScopedPtrHashMap<std::string, | 542 typedef base::ScopedPtrHashMap<std::string, |
543 std::unique_ptr<BluetoothGattService>> | 543 std::unique_ptr<BluetoothRemoteGattService>> |
544 GattServiceMap; | 544 GattServiceMap; |
545 GattServiceMap gatt_services_; | 545 GattServiceMap gatt_services_; |
546 bool gatt_services_discovery_complete_; | 546 bool gatt_services_discovery_complete_; |
547 | 547 |
548 // Mapping from service UUID represented as a std::string of a bluetooth | 548 // Mapping from service UUID represented as a std::string of a bluetooth |
549 // service to | 549 // service to |
550 // the specific data. The data is stored as BinaryValue. | 550 // the specific data. The data is stored as BinaryValue. |
551 std::unique_ptr<base::DictionaryValue> services_data_; | 551 std::unique_ptr<base::DictionaryValue> services_data_; |
552 | 552 |
553 private: | 553 private: |
554 // Returns a localized string containing the device's bluetooth address and | 554 // Returns a localized string containing the device's bluetooth address and |
555 // a device type for display when |name_| is empty. | 555 // a device type for display when |name_| is empty. |
556 base::string16 GetAddressWithLocalizedDeviceTypeName() const; | 556 base::string16 GetAddressWithLocalizedDeviceTypeName() const; |
557 }; | 557 }; |
558 | 558 |
559 } // namespace device | 559 } // namespace device |
560 | 560 |
561 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 561 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
OLD | NEW |