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/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
16 #include "device/bluetooth/bluetooth_uuid.h" | 16 #include "device/bluetooth/bluetooth_uuid.h" |
17 #include "net/base/net_log.h" | 17 #include "net/base/net_log.h" |
18 | 18 |
19 namespace device { | 19 namespace device { |
20 | 20 |
| 21 class BluetoothGattConnection; |
21 class BluetoothGattService; | 22 class BluetoothGattService; |
22 class BluetoothSocket; | 23 class BluetoothSocket; |
23 class BluetoothUUID; | 24 class BluetoothUUID; |
24 | 25 |
25 // BluetoothDevice represents a remote Bluetooth device, both its properties and | 26 // BluetoothDevice represents a remote Bluetooth device, both its properties and |
26 // capabilities as discovered by a local adapter and actions that may be | 27 // capabilities as discovered by a local adapter and actions that may be |
27 // performed on the remove device such as pairing, connection and disconnection. | 28 // performed on the remove device such as pairing, connection and disconnection. |
28 // | 29 // |
29 // The class is instantiated and managed by the BluetoothAdapter class | 30 // The class is instantiated and managed by the BluetoothAdapter class |
30 // and pointers should only be obtained from that class and not cached, | 31 // and pointers should only be obtained from that class and not cached, |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 // cause. | 375 // cause. |
375 typedef base::Callback<void(scoped_refptr<BluetoothSocket>)> | 376 typedef base::Callback<void(scoped_refptr<BluetoothSocket>)> |
376 ConnectToServiceCallback; | 377 ConnectToServiceCallback; |
377 typedef base::Callback<void(const std::string& message)> | 378 typedef base::Callback<void(const std::string& message)> |
378 ConnectToServiceErrorCallback; | 379 ConnectToServiceErrorCallback; |
379 virtual void ConnectToService( | 380 virtual void ConnectToService( |
380 const BluetoothUUID& uuid, | 381 const BluetoothUUID& uuid, |
381 const ConnectToServiceCallback& callback, | 382 const ConnectToServiceCallback& callback, |
382 const ConnectToServiceErrorCallback& error_callback) = 0; | 383 const ConnectToServiceErrorCallback& error_callback) = 0; |
383 | 384 |
| 385 // Opens a new GATT connection to this device. On success, a new |
| 386 // BluetoothGattConnection will be handed to the caller via |callback|. On |
| 387 // error, |error_callback| will be called. The connection will be kept alive, |
| 388 // as long as there is at least one active GATT connection. In the case that |
| 389 // the underlying connection gets terminated, either due to a call to |
| 390 // BluetoothDevice::Disconnect or other unexpected circumstances, the |
| 391 // returned BluetoothGattConnection will be automatically marked as inactive. |
| 392 // To monitor the state of the connection, observe the |
| 393 // BluetoothAdapter::Observer::DeviceChanged method. |
| 394 typedef base::Callback<void(scoped_ptr<BluetoothGattConnection>)> |
| 395 GattConnectionCallback; |
| 396 virtual void CreateGattConnection( |
| 397 const GattConnectionCallback& callback, |
| 398 const ConnectErrorCallback& error_callback) = 0; |
| 399 |
384 // Starts monitoring the connection properties, RSSI and TX power. These | 400 // Starts monitoring the connection properties, RSSI and TX power. These |
385 // properties will be tracked, and updated when their values change. Exactly | 401 // properties will be tracked, and updated when their values change. Exactly |
386 // one of |callback| or |error_callback| will be run. | 402 // one of |callback| or |error_callback| will be run. |
387 virtual void StartConnectionMonitor(const base::Closure& callback, | 403 virtual void StartConnectionMonitor(const base::Closure& callback, |
388 const ErrorCallback& error_callback) = 0; | 404 const ErrorCallback& error_callback) = 0; |
389 | 405 |
390 // Returns the list of discovered GATT services. | 406 // Returns the list of discovered GATT services. |
391 virtual std::vector<BluetoothGattService*> GetGattServices() const; | 407 virtual std::vector<BluetoothGattService*> GetGattServices() const; |
392 | 408 |
393 // Returns the GATT service with device-specific identifier |identifier|. | 409 // Returns the GATT service with device-specific identifier |identifier|. |
(...skipping 19 matching lines...) Expand all Loading... |
413 | 429 |
414 private: | 430 private: |
415 // Returns a localized string containing the device's bluetooth address and | 431 // Returns a localized string containing the device's bluetooth address and |
416 // a device type for display when |name_| is empty. | 432 // a device type for display when |name_| is empty. |
417 base::string16 GetAddressWithLocalizedDeviceTypeName() const; | 433 base::string16 GetAddressWithLocalizedDeviceTypeName() const; |
418 }; | 434 }; |
419 | 435 |
420 } // namespace device | 436 } // namespace device |
421 | 437 |
422 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 438 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
OLD | NEW |