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

Unified Diff: device/bluetooth/bluetooth_low_energy_win.cc

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/bluetooth/bluetooth_low_energy_win.h ('k') | device/bluetooth/bluetooth_low_energy_win_fake.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_low_energy_win.cc
diff --git a/device/bluetooth/bluetooth_low_energy_win.cc b/device/bluetooth/bluetooth_low_energy_win.cc
index 54af750526b42fa7387bb8fa271bd5aac77aab05..e0a843248f0aa4b1f2e23cf05ba367057232996b 100644
--- a/device/bluetooth/bluetooth_low_energy_win.cc
+++ b/device/bluetooth/bluetooth_low_energy_win.cc
@@ -652,7 +652,36 @@ bool IsBluetoothLowEnergySupported() {
return base::win::GetVersion() >= base::win::VERSION_WIN8;
}
-bool EnumerateKnownBluetoothLowEnergyDevices(
+bool ExtractBluetoothAddressFromDeviceInstanceIdForTesting(
+ const std::string& instance_id,
+ BLUETOOTH_ADDRESS* btha,
+ std::string* error) {
+ return ExtractBluetoothAddressFromDeviceInstanceId(instance_id, btha, error);
+}
+
+static BluetoothLowEnergyWrapper* instance_ = nullptr;
+BluetoothLowEnergyWrapper* BluetoothLowEnergyWrapper::GetInstance() {
+ if (instance_ == nullptr) {
+ instance_ = new BluetoothLowEnergyWrapper();
+ }
+ return instance_;
+}
+
+void BluetoothLowEnergyWrapper::DeleteInstance() {
+ delete instance_;
+ instance_ = nullptr;
+}
+
+void BluetoothLowEnergyWrapper::SetInstanceForTest(
+ BluetoothLowEnergyWrapper* instance) {
+ delete instance_;
+ instance_ = instance;
+}
+
+BluetoothLowEnergyWrapper::BluetoothLowEnergyWrapper() {}
+BluetoothLowEnergyWrapper::~BluetoothLowEnergyWrapper() {}
+
+bool BluetoothLowEnergyWrapper::EnumerateKnownBluetoothLowEnergyDevices(
ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
std::string* error) {
if (!IsBluetoothLowEnergySupported()) {
@@ -664,9 +693,10 @@ bool EnumerateKnownBluetoothLowEnergyDevices(
GUID_BLUETOOTHLE_DEVICE_INTERFACE, devices, error);
}
-bool EnumerateKnownBluetoothLowEnergyGattServiceDevices(
- ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
- std::string* error) {
+bool BluetoothLowEnergyWrapper::
+ EnumerateKnownBluetoothLowEnergyGattServiceDevices(
+ ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
+ std::string* error) {
if (!IsBluetoothLowEnergySupported()) {
*error = kPlatformNotSupported;
return false;
@@ -676,7 +706,7 @@ bool EnumerateKnownBluetoothLowEnergyGattServiceDevices(
GUID_BLUETOOTH_GATT_SERVICE_DEVICE_INTERFACE, devices, error);
}
-bool EnumerateKnownBluetoothLowEnergyServices(
+bool BluetoothLowEnergyWrapper::EnumerateKnownBluetoothLowEnergyServices(
const base::FilePath& device_path,
ScopedVector<BluetoothLowEnergyServiceInfo>* services,
std::string* error) {
@@ -688,12 +718,5 @@ bool EnumerateKnownBluetoothLowEnergyServices(
return CollectBluetoothLowEnergyDeviceServices(device_path, services, error);
}
-bool ExtractBluetoothAddressFromDeviceInstanceIdForTesting(
- const std::string& instance_id,
- BLUETOOTH_ADDRESS* btha,
- std::string* error) {
- return ExtractBluetoothAddressFromDeviceInstanceId(instance_id, btha, error);
-}
-
} // namespace win
} // namespace device
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_win.h ('k') | device/bluetooth/bluetooth_low_energy_win_fake.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698