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