Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: device/bluetooth/bluetooth_task_manager_win.h

Issue 1690133002: Implement BluetoothRemoteGattServiceWin and related unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_TASK_MANAGER_WIN_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
17 #include "base/observer_list.h" 17 #include "base/observer_list.h"
18 #include "base/win/scoped_handle.h" 18 #include "base/win/scoped_handle.h"
19 #include "device/bluetooth/bluetooth_adapter.h" 19 #include "device/bluetooth/bluetooth_adapter.h"
20 #include "device/bluetooth/bluetooth_export.h" 20 #include "device/bluetooth/bluetooth_export.h"
21 #include "device/bluetooth/bluetooth_low_energy_win.h"
21 22
22 namespace base { 23 namespace base {
23 24
24 class SequencedTaskRunner; 25 class SequencedTaskRunner;
25 class SequencedWorkerPool; 26 class SequencedWorkerPool;
26 27
27 } // namespace base 28 } // namespace base
28 29
29 namespace device { 30 namespace device {
30 31
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner); 112 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner);
112 void Shutdown(); 113 void Shutdown();
113 114
114 void PostSetPoweredBluetoothTask( 115 void PostSetPoweredBluetoothTask(
115 bool powered, 116 bool powered,
116 const base::Closure& callback, 117 const base::Closure& callback,
117 const BluetoothAdapter::ErrorCallback& error_callback); 118 const BluetoothAdapter::ErrorCallback& error_callback);
118 void PostStartDiscoveryTask(); 119 void PostStartDiscoveryTask();
119 void PostStopDiscoveryTask(); 120 void PostStopDiscoveryTask();
120 121
122 // Callbacks of asynchronous operations of GATT service.
123 typedef base::Callback<
124 void(scoped_ptr<BTH_LE_GATT_SERVICE>, uint16_t, HRESULT)>
125 GetGattIncludedServicesCallback;
126 typedef base::Callback<
127 void(scoped_ptr<BTH_LE_GATT_CHARACTERISTIC>, uint16_t, HRESULT)>
128 GetGattIncludedCharacteristicsCallback;
129
130 // Get all included services of a given service. The service is uniquely
131 // identified by its |uuid| and |attribute_handle| with service device
132 // |service_path|. The result is returned asynchronously through |callback|.
133 void PostGetGattIncludedServices(
134 const base::FilePath& service_path,
135 const BluetoothUUID& uuid,
136 uint16_t attribute_handle,
137 const GetGattIncludedServicesCallback& callback);
138
139 // Get all included characteristics of a given service. The service is
140 // uniquely identified by its |uuid| and |attribute_handle| with service
141 // device |service_path|. The result is returned asynchronously through
142 // |callback|.
143 void PostGetGattIncludedCharacteristics(
144 const base::FilePath& service_path,
145 const BluetoothUUID& uuid,
146 uint16_t attribute_handle,
147 const GetGattIncludedCharacteristicsCallback& callback);
148
149 BluetoothUUID BluetoothLowEnergyUuidToBluetoothUuid(
150 const BTH_LE_UUID& bth_le_uuid);
151
121 private: 152 private:
122 friend class base::RefCountedThreadSafe<BluetoothTaskManagerWin>; 153 friend class base::RefCountedThreadSafe<BluetoothTaskManagerWin>;
123 friend class BluetoothTaskManagerWinTest; 154 friend class BluetoothTaskManagerWinTest;
124 155
125 static const int kPollIntervalMs; 156 static const int kPollIntervalMs;
126 157
127 virtual ~BluetoothTaskManagerWin(); 158 virtual ~BluetoothTaskManagerWin();
128 159
129 // Logs Win32 errors occurring during polling on the worker thread. The method 160 // Logs Win32 errors occurring during polling on the worker thread. The method
130 // may discard messages to avoid logging being too verbose. 161 // may discard messages to avoid logging being too verbose.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 bool DiscoverLowEnergyDeviceServices( 232 bool DiscoverLowEnergyDeviceServices(
202 const base::FilePath& device_path, 233 const base::FilePath& device_path,
203 ScopedVector<ServiceRecordState>* service_record_states); 234 ScopedVector<ServiceRecordState>* service_record_states);
204 235
205 // Search for device paths of the GATT services in |*service_record_states| 236 // Search for device paths of the GATT services in |*service_record_states|
206 // from |device_address|. 237 // from |device_address|.
207 bool SearchForGattServiceDevicePaths( 238 bool SearchForGattServiceDevicePaths(
208 const std::string device_address, 239 const std::string device_address,
209 ScopedVector<ServiceRecordState>* service_record_states); 240 ScopedVector<ServiceRecordState>* service_record_states);
210 241
242 // GATT service related functions.
243 void GetGattIncludedServices(base::FilePath service_path,
244 BluetoothUUID uuid,
245 uint16_t attribute_handle,
246 const GetGattIncludedServicesCallback& callback);
247 void GetGattIncludedCharacteristics(
248 base::FilePath device_path,
249 BluetoothUUID uuid,
250 uint16_t attribute_handle,
251 const GetGattIncludedCharacteristicsCallback& callback);
252
211 // UI task runner reference. 253 // UI task runner reference.
212 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; 254 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
213 255
214 scoped_refptr<base::SequencedWorkerPool> worker_pool_; 256 scoped_refptr<base::SequencedWorkerPool> worker_pool_;
215 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner_; 257 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner_;
216 258
217 // List of observers interested in event notifications. 259 // List of observers interested in event notifications.
218 base::ObserverList<Observer> observers_; 260 base::ObserverList<Observer> observers_;
219 261
220 // Weak reference of the adapter handle, let BluetoothClassicWrapper handle 262 // Weak reference of the adapter handle, let BluetoothClassicWrapper handle
221 // the close of |adapter_handle_|. 263 // the close of |adapter_handle_|.
222 HANDLE adapter_handle_; 264 HANDLE adapter_handle_;
223 265
224 // indicates whether the adapter is in discovery mode or not. 266 // indicates whether the adapter is in discovery mode or not.
225 bool discovering_; 267 bool discovering_;
226 268
227 // Use for discarding too many log messages. 269 // Use for discarding too many log messages.
228 base::TimeTicks current_logging_batch_ticks_; 270 base::TimeTicks current_logging_batch_ticks_;
229 int current_logging_batch_count_; 271 int current_logging_batch_count_;
230 272
231 DISALLOW_COPY_AND_ASSIGN(BluetoothTaskManagerWin); 273 DISALLOW_COPY_AND_ASSIGN(BluetoothTaskManagerWin);
232 }; 274 };
233 275
234 } // namespace device 276 } // namespace device
235 277
236 #endif // DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_ 278 #endif // DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698