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

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: 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
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 6e1cb81e46172e484bb187a1ee5198bdebcac3ee..dea12d0f970faba3f13bcede9769c364dd0d0d66 100644
--- a/device/bluetooth/bluetooth_low_energy_win.cc
+++ b/device/bluetooth/bluetooth_low_energy_win.cc
@@ -611,7 +611,32 @@ 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 BluetoothLowEnergyHub* instance_ = nullptr;
scheib 2016/01/29 04:35:50 I think you'll want a base/lazy_instance.h as you
gogerald1 2016/02/02 22:00:20 Done.
+BluetoothLowEnergyHub* BluetoothLowEnergyHub::GetInstance() {
+ if (instance_ == nullptr) {
+ instance_ = new BluetoothLowEnergyHub();
+ }
+ return instance_;
+}
+
+void BluetoothLowEnergyHub::SetInstanceForTest(
+ BluetoothLowEnergyHub* instance) {
+ if (instance_ != nullptr)
+ delete instance_;
scheib 2016/01/29 04:35:50 The if isn't needed. just delete, it works on null
gogerald1 2016/02/02 22:00:20 Done.
+ instance_ = instance;
+}
+
+BluetoothLowEnergyHub::BluetoothLowEnergyHub() {}
+BluetoothLowEnergyHub::~BluetoothLowEnergyHub() {}
+
+bool BluetoothLowEnergyHub::EnumerateKnownBluetoothLowEnergyDevices(
ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
std::string* error) {
if (!IsBluetoothLowEnergySupported()) {
@@ -641,7 +666,7 @@ bool EnumerateKnownBluetoothLowEnergyDevices(
}
}
-bool EnumerateKnownBluetoothLowEnergyServices(
+bool BluetoothLowEnergyHub::EnumerateKnownBluetoothLowEnergyServices(
const base::FilePath& device_path,
ScopedVector<BluetoothLowEnergyServiceInfo>* services,
std::string* error) {
@@ -653,12 +678,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

Powered by Google App Engine
This is Rietveld 408576698