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

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

Issue 2317773002: Fix bluetooth callback function declaration (Closed)
Patch Set: Add comment to explain and justify cast Created 4 years, 3 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
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_low_energy_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_LOW_ENERGY_WIN_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
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/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
16 #include "base/optional.h" 16 #include "base/optional.h"
17 #include "device/bluetooth/bluetooth_export.h" 17 #include "device/bluetooth/bluetooth_export.h"
18 #include "device/bluetooth/bluetooth_low_energy_defs_win.h" 18 #include "device/bluetooth/bluetooth_low_energy_defs_win.h"
19 19
20 namespace device { 20 namespace device {
21 namespace win { 21 namespace win {
22 22
23 //
24 // Callback function signature for Bluetooth GATT events. This fixes a bug in
25 // the prototype in the Windows 10.0.10586 SDK which is missing the CALLBACK
26 // modifier. This typedef should be used throughout Chromium except when casting
scheib 2016/09/12 19:28:16 Would be nice to include the 'why' you mention in
27 // to the 'official' definition when calling Microsoft functions. This allows
28 // Chromium to build with 10.0.10586 or later SDKs (with the fix) while doing
29 // the correct thing.
30 //
31 typedef VOID(CALLBACK* PFNBLUETOOTH_GATT_EVENT_CALLBACK_CORRECTED)(
32 _In_ BTH_LE_GATT_EVENT_TYPE EventType,
33 _In_ PVOID EventOutParameter,
34 _In_opt_ PVOID Context);
35
23 // Represents a device registry property value 36 // Represents a device registry property value
24 class DEVICE_BLUETOOTH_EXPORT DeviceRegistryPropertyValue { 37 class DEVICE_BLUETOOTH_EXPORT DeviceRegistryPropertyValue {
25 public: 38 public:
26 // Creates a property value instance, where |property_type| is one of REG_xxx 39 // Creates a property value instance, where |property_type| is one of REG_xxx
27 // registry value type (e.g. REG_SZ, REG_DWORD), |value| is a byte array 40 // registry value type (e.g. REG_SZ, REG_DWORD), |value| is a byte array
28 // containing the property value and |value_size| is the number of bytes in 41 // containing the property value and |value_size| is the number of bytes in
29 // |value|. Note the returned instance takes ownership of the bytes in 42 // |value|. Note the returned instance takes ownership of the bytes in
30 // |value|. 43 // |value|.
31 static std::unique_ptr<DeviceRegistryPropertyValue> Create( 44 static std::unique_ptr<DeviceRegistryPropertyValue> Create(
32 DWORD property_type, 45 DWORD property_type,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 virtual HRESULT WriteCharacteristicValue( 187 virtual HRESULT WriteCharacteristicValue(
175 base::FilePath& service_path, 188 base::FilePath& service_path,
176 const PBTH_LE_GATT_CHARACTERISTIC characteristic, 189 const PBTH_LE_GATT_CHARACTERISTIC characteristic,
177 PBTH_LE_GATT_CHARACTERISTIC_VALUE new_value); 190 PBTH_LE_GATT_CHARACTERISTIC_VALUE new_value);
178 191
179 // Register GATT events of |event_type| in the service with service device 192 // Register GATT events of |event_type| in the service with service device
180 // path |service_path|. |event_parameter| is the event's parameter. |callback| 193 // path |service_path|. |event_parameter| is the event's parameter. |callback|
181 // is the function to be invoked if the event happened. |context| is the input 194 // is the function to be invoked if the event happened. |context| is the input
182 // parameter to be given back through |callback|. |*out_handle| stores the 195 // parameter to be given back through |callback|. |*out_handle| stores the
183 // unique handle in OS for this registration. 196 // unique handle in OS for this registration.
184 virtual HRESULT RegisterGattEvents(base::FilePath& service_path, 197 virtual HRESULT RegisterGattEvents(
185 BTH_LE_GATT_EVENT_TYPE event_type, 198 base::FilePath& service_path,
186 PVOID event_parameter, 199 BTH_LE_GATT_EVENT_TYPE event_type,
187 PFNBLUETOOTH_GATT_EVENT_CALLBACK callback, 200 PVOID event_parameter,
188 PVOID context, 201 PFNBLUETOOTH_GATT_EVENT_CALLBACK_CORRECTED callback,
189 BLUETOOTH_GATT_EVENT_HANDLE* out_handle); 202 PVOID context,
203 BLUETOOTH_GATT_EVENT_HANDLE* out_handle);
190 virtual HRESULT UnregisterGattEvent(BLUETOOTH_GATT_EVENT_HANDLE event_handle); 204 virtual HRESULT UnregisterGattEvent(BLUETOOTH_GATT_EVENT_HANDLE event_handle);
191 205
192 // Writes |descriptor| value in service with service device path 206 // Writes |descriptor| value in service with service device path
193 // |service_path| to |*new_value|. 207 // |service_path| to |*new_value|.
194 virtual HRESULT WriteDescriptorValue(base::FilePath& service_path, 208 virtual HRESULT WriteDescriptorValue(base::FilePath& service_path,
195 const PBTH_LE_GATT_DESCRIPTOR descriptor, 209 const PBTH_LE_GATT_DESCRIPTOR descriptor,
196 PBTH_LE_GATT_DESCRIPTOR_VALUE new_value); 210 PBTH_LE_GATT_DESCRIPTOR_VALUE new_value);
197 211
198 protected: 212 protected:
199 BluetoothLowEnergyWrapper(); 213 BluetoothLowEnergyWrapper();
200 virtual ~BluetoothLowEnergyWrapper(); 214 virtual ~BluetoothLowEnergyWrapper();
201 }; 215 };
202 216
203 } // namespace win 217 } // namespace win
204 } // namespace device 218 } // namespace device
205 219
206 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_ 220 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_WIN_H_
OLDNEW
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_low_energy_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698