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 CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ |
6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 // Makes the group of characteristics belonging to a particular GATT based | 66 // Makes the group of characteristics belonging to a particular GATT based |
67 // profile available under the GATT service with object path |service_path|. | 67 // profile available under the GATT service with object path |service_path|. |
68 // Characteristic paths are hierarchical to service paths. | 68 // Characteristic paths are hierarchical to service paths. |
69 void ExposeHeartRateCharacteristics(const dbus::ObjectPath& service_path); | 69 void ExposeHeartRateCharacteristics(const dbus::ObjectPath& service_path); |
70 void HideHeartRateCharacteristics(); | 70 void HideHeartRateCharacteristics(); |
71 | 71 |
72 // Returns whether or not the heart rate characteristics are visible and | 72 // Returns whether or not the heart rate characteristics are visible and |
73 // performs the appropriate assertions. | 73 // performs the appropriate assertions. |
74 bool IsHeartRateVisible() const; | 74 bool IsHeartRateVisible() const; |
75 | 75 |
76 // Makes this characteristic client really slow. | |
77 // So slow, that it is guaranteed that |requests| requests will | |
78 // come in while the client is doing the previous request. | |
79 // Setting |requests| to zero will cause all delayed actions to | |
80 // complete immediately. | |
81 void SetExtraProcessing(size_t requests); | |
82 | |
83 size_t GetExtraProcessing() const; | |
84 | |
85 // Sets whether the client is authorized or not. | |
86 // Defaults to authorized. | |
87 void SetAuthorized(bool authorized) { authorized_ = authorized; } | |
88 | |
89 // Get the current Authorization state. | |
90 bool IsAuthorized() const { return authorized_; } | |
91 | |
76 // Returns the current object paths of exposed characteristics. If the | 92 // Returns the current object paths of exposed characteristics. If the |
77 // characteristic is not visible, returns an invalid empty path. | 93 // characteristic is not visible, returns an invalid empty path. |
78 dbus::ObjectPath GetHeartRateMeasurementPath() const; | 94 dbus::ObjectPath GetHeartRateMeasurementPath() const; |
79 dbus::ObjectPath GetBodySensorLocationPath() const; | 95 dbus::ObjectPath GetBodySensorLocationPath() const; |
80 dbus::ObjectPath GetHeartRateControlPointPath() const; | 96 dbus::ObjectPath GetHeartRateControlPointPath() const; |
81 | 97 |
82 // Object path components and UUIDs of GATT characteristics. | 98 // Object path components and UUIDs of GATT characteristics. |
83 // Heart Rate Service: | 99 // Heart Rate Service: |
84 static const char kHeartRateMeasurementPathComponent[]; | 100 static const char kHeartRateMeasurementPathComponent[]; |
85 static const char kHeartRateMeasurementUUID[]; | 101 static const char kHeartRateMeasurementUUID[]; |
(...skipping 17 matching lines...) Expand all Loading... | |
103 | 119 |
104 // Returns a random Heart Rate Measurement value. All the fields of the value | 120 // Returns a random Heart Rate Measurement value. All the fields of the value |
105 // are populated according to the the fake behavior. The measurement value | 121 // are populated according to the the fake behavior. The measurement value |
106 // is a random value within a reasonable range. | 122 // is a random value within a reasonable range. |
107 std::vector<uint8> GetHeartRateMeasurementValue(); | 123 std::vector<uint8> GetHeartRateMeasurementValue(); |
108 | 124 |
109 // If true, characteristics of the Heart Rate Service are visible. Use | 125 // If true, characteristics of the Heart Rate Service are visible. Use |
110 // IsHeartRateVisible() to check the value. | 126 // IsHeartRateVisible() to check the value. |
111 bool heart_rate_visible_; | 127 bool heart_rate_visible_; |
112 | 128 |
129 // If true, the client is authorized to read and write. | |
130 bool authorized_; | |
131 | |
113 // Total calories burned, used for the Heart Rate Measurement characteristic. | 132 // Total calories burned, used for the Heart Rate Measurement characteristic. |
114 uint16 calories_burned_; | 133 uint16 calories_burned_; |
115 | 134 |
116 // Static properties returned for simulated characteristics for the Heart | 135 // Static properties returned for simulated characteristics for the Heart |
117 // Rate Service. These pointers are not NULL only if the characteristics are | 136 // Rate Service. These pointers are not NULL only if the characteristics are |
118 // actually exposed. | 137 // actually exposed. |
119 scoped_ptr<Properties> heart_rate_measurement_properties_; | 138 scoped_ptr<Properties> heart_rate_measurement_properties_; |
120 scoped_ptr<Properties> body_sensor_location_properties_; | 139 scoped_ptr<Properties> body_sensor_location_properties_; |
121 scoped_ptr<Properties> heart_rate_control_point_properties_; | 140 scoped_ptr<Properties> heart_rate_control_point_properties_; |
122 | 141 |
123 // Object paths of the exposed characteristics. If a characteristic is not | 142 // Object paths of the exposed characteristics. If a characteristic is not |
124 // exposed, these will be empty. | 143 // exposed, these will be empty. |
125 std::string heart_rate_measurement_path_; | 144 std::string heart_rate_measurement_path_; |
126 std::string heart_rate_measurement_ccc_desc_path_; | 145 std::string heart_rate_measurement_ccc_desc_path_; |
127 std::string body_sensor_location_path_; | 146 std::string body_sensor_location_path_; |
128 std::string heart_rate_control_point_path_; | 147 std::string heart_rate_control_point_path_; |
129 | 148 |
149 // Number of extra requests that need to come in simulating slowness. | |
150 size_t extra_requests_; | |
151 | |
152 // Current countdowns for extra requests for various actions. | |
153 struct DelayedCallback { | |
154 public: | |
155 DelayedCallback(base::Closure callback, size_t delay); | |
156 ~DelayedCallback(); | |
157 | |
158 base::Closure callback_; | |
159 size_t delay_; | |
160 }; | |
161 | |
162 // Map of delayed callbacks. | |
163 std::map<std::string, struct DelayedCallback*> action_extra_requests_; | |
armansito
2014/10/01 20:08:22
struct keyword not necessary
| |
164 | |
130 // List of observers interested in event notifications from us. | 165 // List of observers interested in event notifications from us. |
131 ObserverList<Observer> observers_; | 166 ObserverList<Observer> observers_; |
132 | 167 |
133 // Weak pointer factory for generating 'this' pointers that might live longer | 168 // Weak pointer factory for generating 'this' pointers that might live longer |
134 // than we do. | 169 // than we do. |
135 // Note: This should remain the last member so it'll be destroyed and | 170 // Note: This should remain the last member so it'll be destroyed and |
136 // invalidate its weak pointers before any other members are destroyed. | 171 // invalidate its weak pointers before any other members are destroyed. |
137 base::WeakPtrFactory<FakeBluetoothGattCharacteristicClient> | 172 base::WeakPtrFactory<FakeBluetoothGattCharacteristicClient> |
138 weak_ptr_factory_; | 173 weak_ptr_factory_; |
139 | 174 |
140 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattCharacteristicClient); | 175 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattCharacteristicClient); |
141 }; | 176 }; |
142 | 177 |
143 } // namespace chromeos | 178 } // namespace chromeos |
144 | 179 |
145 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ | 180 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ |
OLD | NEW |