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

Unified Diff: device/bluetooth/bluetooth_low_energy_win.h

Issue 1646023002: Refactor bluetooth_low_energy_win to prepare for new Bluetooth test fixture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: export class BluetoothLowEnergyWrapper for test Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/BUILD.gn ('k') | device/bluetooth/bluetooth_low_energy_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_low_energy_win.h
diff --git a/device/bluetooth/bluetooth_low_energy_win.h b/device/bluetooth/bluetooth_low_energy_win.h
index 52347cece15299a289ca9b141cd3a2339c09c181..9abdf34fef63c9d44e544f7e262f197d4ba359d9 100644
--- a/device/bluetooth/bluetooth_low_energy_win.h
+++ b/device/bluetooth/bluetooth_low_energy_win.h
@@ -12,7 +12,6 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
-#include "base/win/scoped_handle.h"
#include "device/bluetooth/bluetooth_export.h"
#include "device/bluetooth/bluetooth_low_energy_defs_win.h"
@@ -100,42 +99,56 @@ struct BluetoothLowEnergyDeviceInfo {
bool connected;
};
-// Enumerates the list of known (i.e. already paired) Bluetooth LE devices on
-// this machine. In case of error, returns false and sets |error| with an error
-// message describing the problem.
-// Note: This function returns an error if Bluetooth Low Energy is not supported
-// on this Windows platform.
-bool EnumerateKnownBluetoothLowEnergyDevices(
- ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
- std::string* error);
-
-// Enumerates the list of known Bluetooth LE GATT service devices on this
-// machine (a Bluetooth LE device usually has more than one GATT
-// services that each of them has a device interface on the machine). In case
-// of error, returns false and sets |error| with an error message describing the
-// problem.
-// Note: This function returns an error if Bluetooth Low Energy is not supported
-// on this Windows platform.
-bool EnumerateKnownBluetoothLowEnergyGattServiceDevices(
- ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
- std::string* error);
-
-// Enumerates the list of known (i.e. cached) GATT services for a given
-// Bluetooth LE device |device_path| into |services|. In case of error, returns
-// false and sets |error| with an error message describing the problem. Note:
-// This function returns an error if Bluetooth Low Energy is not supported on
-// this Windows platform.
-bool EnumerateKnownBluetoothLowEnergyServices(
- const base::FilePath& device_path,
- ScopedVector<BluetoothLowEnergyServiceInfo>* services,
- std::string* error);
-
bool DEVICE_BLUETOOTH_EXPORT
ExtractBluetoothAddressFromDeviceInstanceIdForTesting(
const std::string& instance_id,
BLUETOOTH_ADDRESS* btha,
std::string* error);
+// Wraps Windows APIs used to access Bluetooth Low Energy devices, providing an
+// interface that can be replaced with fakes in tests.
+class DEVICE_BLUETOOTH_EXPORT BluetoothLowEnergyWrapper {
+ public:
+ static BluetoothLowEnergyWrapper* GetInstance();
+ static void DeleteInstance();
+ static void SetInstanceForTest(BluetoothLowEnergyWrapper* instance);
+
+ // Enumerates the list of known (i.e. already paired) Bluetooth LE devices on
+ // this machine. In case of error, returns false and sets |error| with an
+ // error message describing the problem.
+ // Note: This function returns an error if Bluetooth Low Energy is not
+ // supported on this Windows platform.
+ virtual bool EnumerateKnownBluetoothLowEnergyDevices(
+ ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
+ std::string* error);
+
+ // Enumerates the list of known Bluetooth LE GATT service devices on this
+ // machine (a Bluetooth LE device usually has more than one GATT
+ // services that each of them has a device interface on the machine). In case
+ // of error, returns false and sets |error| with an error message describing
+ // the problem.
+ // Note: This function returns an error if Bluetooth Low Energy is not
+ // supported on this Windows platform.
+ virtual bool EnumerateKnownBluetoothLowEnergyGattServiceDevices(
+ ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
+ std::string* error);
+
+ // Enumerates the list of known (i.e. cached) GATT services for a given
+ // Bluetooth LE device |device_path| into |services|. In case of error,
+ // returns false and sets |error| with an error message describing the
+ // problem.
+ // Note: This function returns an error if Bluetooth Low Energy is not
+ // supported on this Windows platform.
+ virtual bool EnumerateKnownBluetoothLowEnergyServices(
+ const base::FilePath& device_path,
+ ScopedVector<BluetoothLowEnergyServiceInfo>* services,
+ std::string* error);
+
+ protected:
+ BluetoothLowEnergyWrapper();
+ virtual ~BluetoothLowEnergyWrapper();
+};
+
} // namespace win
} // namespace device
« no previous file with comments | « device/BUILD.gn ('k') | device/bluetooth/bluetooth_low_energy_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698