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 <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 411 |
412 // Opens a new GATT connection to this device. On success, a new | 412 // Opens a new GATT connection to this device. On success, a new |
413 // BluetoothGattConnection will be handed to the caller via |callback|. On | 413 // BluetoothGattConnection will be handed to the caller via |callback|. On |
414 // error, |error_callback| will be called. The connection will be kept alive, | 414 // error, |error_callback| will be called. The connection will be kept alive, |
415 // as long as there is at least one active GATT connection. In the case that | 415 // as long as there is at least one active GATT connection. In the case that |
416 // the underlying connection gets terminated, either due to a call to | 416 // the underlying connection gets terminated, either due to a call to |
417 // BluetoothDevice::Disconnect or other unexpected circumstances, the | 417 // BluetoothDevice::Disconnect or other unexpected circumstances, the |
418 // returned BluetoothGattConnection will be automatically marked as inactive. | 418 // returned BluetoothGattConnection will be automatically marked as inactive. |
419 // To monitor the state of the connection, observe the | 419 // To monitor the state of the connection, observe the |
420 // BluetoothAdapter::Observer::DeviceChanged method. | 420 // BluetoothAdapter::Observer::DeviceChanged method. |
421 typedef base::Callback<void(scoped_ptr<BluetoothGattConnection>)> | 421 typedef base::Callback<void()> GattConnectionCallback; |
422 GattConnectionCallback; | 422 virtual scoped_ptr<device::BluetoothGattConnection> CreateGattConnection( |
423 virtual void CreateGattConnection(const GattConnectionCallback& callback, | 423 const GattConnectionCallback& callback, |
424 const ConnectErrorCallback& error_callback); | 424 const ConnectErrorCallback& error_callback); |
425 | 425 |
426 // Returns the list of discovered GATT services. | 426 // Returns the list of discovered GATT services. |
427 virtual std::vector<BluetoothGattService*> GetGattServices() const; | 427 virtual std::vector<BluetoothGattService*> GetGattServices() const; |
428 | 428 |
429 // Returns the GATT service with device-specific identifier |identifier|. | 429 // Returns the GATT service with device-specific identifier |identifier|. |
430 // Returns NULL, if no such service exists. | 430 // Returns NULL, if no such service exists. |
431 virtual BluetoothGattService* GetGattService( | 431 virtual BluetoothGattService* GetGattService( |
432 const std::string& identifier) const; | 432 const std::string& identifier) const; |
433 | 433 |
434 // Returns service data of a service given its UUID. | 434 // Returns service data of a service given its UUID. |
(...skipping 21 matching lines...) Expand all Loading... |
456 | 456 |
457 BluetoothDevice(BluetoothAdapter* adapter); | 457 BluetoothDevice(BluetoothAdapter* adapter); |
458 | 458 |
459 // Returns the internal name of the Bluetooth device, used by GetName(). | 459 // Returns the internal name of the Bluetooth device, used by GetName(). |
460 virtual std::string GetDeviceName() const = 0; | 460 virtual std::string GetDeviceName() const = 0; |
461 | 461 |
462 // Implements platform specific operations to initiate a GATT connection. | 462 // Implements platform specific operations to initiate a GATT connection. |
463 // Subclasses must also call DidConnectGatt, DidFailToConnectGatt, or | 463 // Subclasses must also call DidConnectGatt, DidFailToConnectGatt, or |
464 // DidDisconnectGatt immediately or asynchronously as the connection state | 464 // DidDisconnectGatt immediately or asynchronously as the connection state |
465 // changes. | 465 // changes. |
466 virtual void CreateGattConnectionImpl() = 0; | 466 virtual scoped_ptr<device::BluetoothGattConnection> |
| 467 CreateGattConnectionImpl() = 0; |
| 468 |
| 469 // Return new BluetoothGattConnection for already connected BluetoothDevice. |
| 470 virtual scoped_ptr<device::BluetoothGattConnection> |
| 471 ExistingGattConnection() = 0; |
467 | 472 |
468 // Disconnects GATT connection on platforms that maintain a specific GATT | 473 // Disconnects GATT connection on platforms that maintain a specific GATT |
469 // connection. | 474 // connection. |
470 virtual void DisconnectGatt() = 0; | 475 virtual void DisconnectGatt() = 0; |
471 | 476 |
472 // Calls any pending callbacks for CreateGattConnection based on result of | 477 // Calls any pending callbacks for CreateGattConnection based on result of |
473 // subclasses actions initiated in CreateGattConnectionImpl or related | 478 // subclasses actions initiated in CreateGattConnectionImpl or related |
474 // disconnection events. These may be called at any time, even multiple times, | 479 // disconnection events. These may be called at any time, even multiple times, |
475 // to ensure a change in platform state is correctly tracked. | 480 // to ensure a change in platform state is correctly tracked. |
476 // | 481 // |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 | 522 |
518 private: | 523 private: |
519 // Returns a localized string containing the device's bluetooth address and | 524 // Returns a localized string containing the device's bluetooth address and |
520 // a device type for display when |name_| is empty. | 525 // a device type for display when |name_| is empty. |
521 base::string16 GetAddressWithLocalizedDeviceTypeName() const; | 526 base::string16 GetAddressWithLocalizedDeviceTypeName() const; |
522 }; | 527 }; |
523 | 528 |
524 } // namespace device | 529 } // namespace device |
525 | 530 |
526 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 531 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
OLD | NEW |