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 |