OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_GATT_NOTIFY_SESSION_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_NOTIFY_SESSION_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_NOTIFY_SESSION_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_NOTIFY_SESSION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/weak_ptr.h" | |
12 #include "device/bluetooth/bluetooth_export.h" | 13 #include "device/bluetooth/bluetooth_export.h" |
13 | 14 |
14 namespace device { | 15 namespace device { |
15 | 16 |
17 class BluetoothRemoteGattCharacteristic; | |
18 | |
16 // A BluetoothGattNotifySession represents an active session for listening | 19 // A BluetoothGattNotifySession represents an active session for listening |
17 // to value updates from GATT characteristics that support notifications and/or | 20 // to value updates from GATT characteristics that support notifications and/or |
18 // indications. Instances are obtained by calling | 21 // indications. Instances are obtained by calling |
19 // BluetoothRemoteGattCharacteristic::StartNotifySession. | 22 // BluetoothRemoteGattCharacteristic::StartNotifySession. |
20 class DEVICE_BLUETOOTH_EXPORT BluetoothGattNotifySession { | 23 class DEVICE_BLUETOOTH_EXPORT BluetoothGattNotifySession { |
21 public: | 24 public: |
25 explicit BluetoothGattNotifySession( | |
26 base::WeakPtr<BluetoothRemoteGattCharacteristic> characteristic); | |
27 | |
22 // Destructor automatically stops this session. | 28 // Destructor automatically stops this session. |
23 virtual ~BluetoothGattNotifySession(); | 29 virtual ~BluetoothGattNotifySession(); |
24 | 30 |
25 // Returns the identifier of the associated characteristic. | 31 // Returns the identifier of the associated characteristic. |
26 virtual std::string GetCharacteristicIdentifier() const = 0; | 32 virtual std::string GetCharacteristicIdentifier() const; |
33 | |
34 // Returns the associated characteristic. | |
ortuno
2016/07/28 21:59:30
Explain when this returns nullptr.
tommyt
2016/08/01 11:39:21
Done.
| |
35 virtual BluetoothRemoteGattCharacteristic* GetCharacteristic() const; | |
27 | 36 |
28 // Returns true if this session is active. | 37 // Returns true if this session is active. |
29 virtual bool IsActive() = 0; | 38 virtual bool IsActive(); |
ortuno
2016/07/28 21:59:30
Please add a comment explaining what it means for
tommyt
2016/08/01 11:39:21
Done.
| |
30 | 39 |
31 // Stops this session and calls |callback| upon completion. This won't | 40 // Stops this session and calls |callback| upon completion. This won't |
32 // necessarily stop value updates from the characteristic -- since updates | 41 // necessarily stop value updates from the characteristic -- since updates |
33 // are shared among BluetoothGattNotifySession instances -- but it will | 42 // are shared among BluetoothGattNotifySession instances -- but it will |
34 // terminate this session. | 43 // terminate this session. |
35 virtual void Stop(const base::Closure& callback) = 0; | 44 virtual void Stop(const base::Closure& callback); |
36 | |
37 protected: | |
38 BluetoothGattNotifySession(); | |
39 | 45 |
40 private: | 46 private: |
47 // The associated characteristic. | |
48 base::WeakPtr<BluetoothRemoteGattCharacteristic> characteristic_; | |
49 std::string characteristic_id_; | |
50 | |
41 DISALLOW_COPY_AND_ASSIGN(BluetoothGattNotifySession); | 51 DISALLOW_COPY_AND_ASSIGN(BluetoothGattNotifySession); |
42 }; | 52 }; |
43 | 53 |
44 } // namespace device | 54 } // namespace device |
45 | 55 |
46 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_NOTIFY_SESSION_H_ | 56 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_NOTIFY_SESSION_H_ |
OLD | NEW |