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

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: address comments and split out of included GATT services 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // to an active discovery session. Note that for a given device (address), 97 // to an active discovery session. Note that for a given device (address),
97 // the associated state can change over time. For example, during a 98 // the associated state can change over time. For example, during a
98 // discovery session, the "friendly" name may initially be "unknown" before 99 // discovery session, the "friendly" name may initially be "unknown" before
99 // the actual name is retrieved in subsequent poll events. 100 // the actual name is retrieved in subsequent poll events.
100 virtual void DevicesPolled(const ScopedVector<DeviceState>& devices) {} 101 virtual void DevicesPolled(const ScopedVector<DeviceState>& devices) {}
101 }; 102 };
102 103
103 explicit BluetoothTaskManagerWin( 104 explicit BluetoothTaskManagerWin(
104 scoped_refptr<base::SequencedTaskRunner> ui_task_runner); 105 scoped_refptr<base::SequencedTaskRunner> ui_task_runner);
105 106
107 static BluetoothUUID BluetoothLowEnergyUuidToBluetoothUuid(
108 const BTH_LE_UUID& bth_le_uuid);
109
106 void AddObserver(Observer* observer); 110 void AddObserver(Observer* observer);
107 void RemoveObserver(Observer* observer); 111 void RemoveObserver(Observer* observer);
108 112
109 void Initialize(); 113 void Initialize();
110 void InitializeWithBluetoothTaskRunner( 114 void InitializeWithBluetoothTaskRunner(
111 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner); 115 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner);
112 void Shutdown(); 116 void Shutdown();
113 117
114 void PostSetPoweredBluetoothTask( 118 void PostSetPoweredBluetoothTask(
115 bool powered, 119 bool powered,
116 const base::Closure& callback, 120 const base::Closure& callback,
117 const BluetoothAdapter::ErrorCallback& error_callback); 121 const BluetoothAdapter::ErrorCallback& error_callback);
118 void PostStartDiscoveryTask(); 122 void PostStartDiscoveryTask();
119 void PostStopDiscoveryTask(); 123 void PostStopDiscoveryTask();
120 124
125 // Callbacks of asynchronous operations of GATT service.
126 typedef base::Callback<
127 void(scoped_ptr<BTH_LE_GATT_CHARACTERISTIC>, uint16_t, HRESULT)>
128 GetGattIncludedCharacteristicsCallback;
129
130 // Get all included characteristics of a given service. The service is
131 // uniquely identified by its |uuid| and |attribute_handle| with service
132 // device |service_path|. The result is returned asynchronously through
133 // |callback|.
134 void PostGetGattIncludedCharacteristics(
135 const base::FilePath& service_path,
136 const BluetoothUUID& uuid,
137 uint16_t attribute_handle,
138 const GetGattIncludedCharacteristicsCallback& callback);
139
121 private: 140 private:
122 friend class base::RefCountedThreadSafe<BluetoothTaskManagerWin>; 141 friend class base::RefCountedThreadSafe<BluetoothTaskManagerWin>;
123 friend class BluetoothTaskManagerWinTest; 142 friend class BluetoothTaskManagerWinTest;
124 143
125 static const int kPollIntervalMs; 144 static const int kPollIntervalMs;
126 145
127 virtual ~BluetoothTaskManagerWin(); 146 virtual ~BluetoothTaskManagerWin();
128 147
129 // Logs Win32 errors occurring during polling on the worker thread. The method 148 // Logs Win32 errors occurring during polling on the worker thread. The method
130 // may discard messages to avoid logging being too verbose. 149 // may discard messages to avoid logging being too verbose.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 bool DiscoverLowEnergyDeviceServices( 220 bool DiscoverLowEnergyDeviceServices(
202 const base::FilePath& device_path, 221 const base::FilePath& device_path,
203 ScopedVector<ServiceRecordState>* service_record_states); 222 ScopedVector<ServiceRecordState>* service_record_states);
204 223
205 // Search for device paths of the GATT services in |*service_record_states| 224 // Search for device paths of the GATT services in |*service_record_states|
206 // from |device_address|. 225 // from |device_address|.
207 bool SearchForGattServiceDevicePaths( 226 bool SearchForGattServiceDevicePaths(
208 const std::string device_address, 227 const std::string device_address,
209 ScopedVector<ServiceRecordState>* service_record_states); 228 ScopedVector<ServiceRecordState>* service_record_states);
210 229
230 // GATT service related functions.
231 void GetGattIncludedCharacteristics(
232 base::FilePath device_path,
233 BluetoothUUID uuid,
234 uint16_t attribute_handle,
235 const GetGattIncludedCharacteristicsCallback& callback);
236
211 // UI task runner reference. 237 // UI task runner reference.
212 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; 238 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
213 239
214 scoped_refptr<base::SequencedWorkerPool> worker_pool_; 240 scoped_refptr<base::SequencedWorkerPool> worker_pool_;
215 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner_; 241 scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner_;
216 242
217 // List of observers interested in event notifications. 243 // List of observers interested in event notifications.
218 base::ObserverList<Observer> observers_; 244 base::ObserverList<Observer> observers_;
219 245
220 // Weak reference of the adapter handle, let BluetoothClassicWrapper handle 246 // Weak reference of the adapter handle, let BluetoothClassicWrapper handle
221 // the close of |adapter_handle_|. 247 // the close of |adapter_handle_|.
222 HANDLE adapter_handle_; 248 HANDLE adapter_handle_;
223 249
224 // indicates whether the adapter is in discovery mode or not. 250 // indicates whether the adapter is in discovery mode or not.
225 bool discovering_; 251 bool discovering_;
226 252
227 // Use for discarding too many log messages. 253 // Use for discarding too many log messages.
228 base::TimeTicks current_logging_batch_ticks_; 254 base::TimeTicks current_logging_batch_ticks_;
229 int current_logging_batch_count_; 255 int current_logging_batch_count_;
230 256
231 DISALLOW_COPY_AND_ASSIGN(BluetoothTaskManagerWin); 257 DISALLOW_COPY_AND_ASSIGN(BluetoothTaskManagerWin);
232 }; 258 };
233 259
234 } // namespace device 260 } // namespace device
235 261
236 #endif // DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_ 262 #endif // DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698