| 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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 // the underlying connection gets terminated, either due to a call to | 425 // the underlying connection gets terminated, either due to a call to |
| 426 // BluetoothDevice::Disconnect or other unexpected circumstances, the | 426 // BluetoothDevice::Disconnect or other unexpected circumstances, the |
| 427 // returned BluetoothGattConnection will be automatically marked as inactive. | 427 // returned BluetoothGattConnection will be automatically marked as inactive. |
| 428 // To monitor the state of the connection, observe the | 428 // To monitor the state of the connection, observe the |
| 429 // BluetoothAdapter::Observer::DeviceChanged method. | 429 // BluetoothAdapter::Observer::DeviceChanged method. |
| 430 typedef base::Callback<void(scoped_ptr<BluetoothGattConnection>)> | 430 typedef base::Callback<void(scoped_ptr<BluetoothGattConnection>)> |
| 431 GattConnectionCallback; | 431 GattConnectionCallback; |
| 432 virtual void CreateGattConnection(const GattConnectionCallback& callback, | 432 virtual void CreateGattConnection(const GattConnectionCallback& callback, |
| 433 const ConnectErrorCallback& error_callback); | 433 const ConnectErrorCallback& error_callback); |
| 434 | 434 |
| 435 // Set the gatt services discovery complete flag for this device. |
| 436 void SetGattServicesDiscoveryComplete(bool complete); |
| 437 |
| 438 // Indicates whether service discovery is complete for this device. |
| 439 bool IsGattServicesDiscoveryComplete() const; |
| 440 |
| 435 // Returns the list of discovered GATT services. | 441 // Returns the list of discovered GATT services. |
| 436 virtual std::vector<BluetoothGattService*> GetGattServices() const; | 442 virtual std::vector<BluetoothGattService*> GetGattServices() const; |
| 437 | 443 |
| 438 // Returns the GATT service with device-specific identifier |identifier|. | 444 // Returns the GATT service with device-specific identifier |identifier|. |
| 439 // Returns NULL, if no such service exists. | 445 // Returns NULL, if no such service exists. |
| 440 virtual BluetoothGattService* GetGattService( | 446 virtual BluetoothGattService* GetGattService( |
| 441 const std::string& identifier) const; | 447 const std::string& identifier) const; |
| 442 | 448 |
| 443 // Returns service data of a service given its UUID. | 449 // Returns service data of a service given its UUID. |
| 444 virtual base::BinaryValue* GetServiceData(BluetoothUUID serviceUUID) const; | 450 virtual base::BinaryValue* GetServiceData(BluetoothUUID serviceUUID) const; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 455 // BluetoothGattConnection is a friend to call Add/RemoveGattConnection. | 461 // BluetoothGattConnection is a friend to call Add/RemoveGattConnection. |
| 456 friend BluetoothGattConnection; | 462 friend BluetoothGattConnection; |
| 457 FRIEND_TEST_ALL_PREFIXES( | 463 FRIEND_TEST_ALL_PREFIXES( |
| 458 BluetoothTest, | 464 BluetoothTest, |
| 459 BluetoothGattConnection_DisconnectGatt_SimulateConnect); | 465 BluetoothGattConnection_DisconnectGatt_SimulateConnect); |
| 460 FRIEND_TEST_ALL_PREFIXES( | 466 FRIEND_TEST_ALL_PREFIXES( |
| 461 BluetoothTest, | 467 BluetoothTest, |
| 462 BluetoothGattConnection_DisconnectGatt_SimulateDisconnect); | 468 BluetoothGattConnection_DisconnectGatt_SimulateDisconnect); |
| 463 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, | 469 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, |
| 464 BluetoothGattConnection_ErrorAfterConnection); | 470 BluetoothGattConnection_ErrorAfterConnection); |
| 471 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, |
| 472 BluetoothGattConnection_DisconnectGatt_Cleanup); |
| 465 | 473 |
| 466 BluetoothDevice(BluetoothAdapter* adapter); | 474 BluetoothDevice(BluetoothAdapter* adapter); |
| 467 | 475 |
| 468 // Returns the internal name of the Bluetooth device, used by GetName(). | 476 // Returns the internal name of the Bluetooth device, used by GetName(). |
| 469 virtual std::string GetDeviceName() const = 0; | 477 virtual std::string GetDeviceName() const = 0; |
| 470 | 478 |
| 471 // Implements platform specific operations to initiate a GATT connection. | 479 // Implements platform specific operations to initiate a GATT connection. |
| 472 // Subclasses must also call DidConnectGatt, DidFailToConnectGatt, or | 480 // Subclasses must also call DidConnectGatt, DidFailToConnectGatt, or |
| 473 // DidDisconnectGatt immediately or asynchronously as the connection state | 481 // DidDisconnectGatt immediately or asynchronously as the connection state |
| 474 // changes. | 482 // changes. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 std::vector<ConnectErrorCallback> create_gatt_connection_error_callbacks_; | 520 std::vector<ConnectErrorCallback> create_gatt_connection_error_callbacks_; |
| 513 | 521 |
| 514 // BluetoothGattConnection objects keeping the GATT connection alive. | 522 // BluetoothGattConnection objects keeping the GATT connection alive. |
| 515 std::set<BluetoothGattConnection*> gatt_connections_; | 523 std::set<BluetoothGattConnection*> gatt_connections_; |
| 516 | 524 |
| 517 // Mapping from the platform-specific GATT service identifiers to | 525 // Mapping from the platform-specific GATT service identifiers to |
| 518 // BluetoothGattService objects. | 526 // BluetoothGattService objects. |
| 519 typedef base::ScopedPtrHashMap<std::string, scoped_ptr<BluetoothGattService>> | 527 typedef base::ScopedPtrHashMap<std::string, scoped_ptr<BluetoothGattService>> |
| 520 GattServiceMap; | 528 GattServiceMap; |
| 521 GattServiceMap gatt_services_; | 529 GattServiceMap gatt_services_; |
| 530 bool gatt_services_discovery_complete_; |
| 522 | 531 |
| 523 // Mapping from service UUID represented as a std::string of a bluetooth | 532 // Mapping from service UUID represented as a std::string of a bluetooth |
| 524 // service to | 533 // service to |
| 525 // the specific data. The data is stored as BinaryValue. | 534 // the specific data. The data is stored as BinaryValue. |
| 526 scoped_ptr<base::DictionaryValue> services_data_; | 535 scoped_ptr<base::DictionaryValue> services_data_; |
| 527 | 536 |
| 528 private: | 537 private: |
| 529 // Returns a localized string containing the device's bluetooth address and | 538 // Returns a localized string containing the device's bluetooth address and |
| 530 // a device type for display when |name_| is empty. | 539 // a device type for display when |name_| is empty. |
| 531 base::string16 GetAddressWithLocalizedDeviceTypeName() const; | 540 base::string16 GetAddressWithLocalizedDeviceTypeName() const; |
| 532 }; | 541 }; |
| 533 | 542 |
| 534 } // namespace device | 543 } // namespace device |
| 535 | 544 |
| 536 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 545 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| OLD | NEW |