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

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

Issue 1668233004: Refactor bluetooth_task_manager_win to prepare for new Bluetooth test fixture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 10 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
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 #include "device/bluetooth/bluetooth_low_energy_win.h" 5 #include "device/bluetooth/bluetooth_low_energy_win.h"
6 6
7 #include "base/files/file.h" 7 #include "base/files/file.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
11 #include "base/win/scoped_handle.h" 11 #include "base/win/scoped_handle.h"
12 #include "base/win/windows_version.h" 12 #include "base/win/windows_version.h"
13 13
14 namespace { 14 namespace {
15 15
16 static device::win::BluetoothLowEnergyWrapper* g_instance_ = nullptr;
17
16 using device::win::DeviceRegistryPropertyValue; 18 using device::win::DeviceRegistryPropertyValue;
17 using device::win::DevicePropertyValue; 19 using device::win::DevicePropertyValue;
18 using device::win::BluetoothLowEnergyDeviceInfo; 20 using device::win::BluetoothLowEnergyDeviceInfo;
19 using device::win::BluetoothLowEnergyServiceInfo; 21 using device::win::BluetoothLowEnergyServiceInfo;
20 22
21 const char kPlatformNotSupported[] = 23 const char kPlatformNotSupported[] =
22 "Bluetooth Low energy is only supported on Windows 8 and later."; 24 "Bluetooth Low energy is only supported on Windows 8 and later.";
23 const char kDeviceEnumError[] = "Error enumerating Bluetooth LE devices."; 25 const char kDeviceEnumError[] = "Error enumerating Bluetooth LE devices.";
24 const char kDeviceInfoError[] = 26 const char kDeviceInfoError[] =
25 "Error retrieving Bluetooth LE device information."; 27 "Error retrieving Bluetooth LE device information.";
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 return base::win::GetVersion() >= base::win::VERSION_WIN8; 654 return base::win::GetVersion() >= base::win::VERSION_WIN8;
653 } 655 }
654 656
655 bool ExtractBluetoothAddressFromDeviceInstanceIdForTesting( 657 bool ExtractBluetoothAddressFromDeviceInstanceIdForTesting(
656 const std::string& instance_id, 658 const std::string& instance_id,
657 BLUETOOTH_ADDRESS* btha, 659 BLUETOOTH_ADDRESS* btha,
658 std::string* error) { 660 std::string* error) {
659 return ExtractBluetoothAddressFromDeviceInstanceId(instance_id, btha, error); 661 return ExtractBluetoothAddressFromDeviceInstanceId(instance_id, btha, error);
660 } 662 }
661 663
662 static BluetoothLowEnergyWrapper* instance_ = nullptr;
663 BluetoothLowEnergyWrapper* BluetoothLowEnergyWrapper::GetInstance() { 664 BluetoothLowEnergyWrapper* BluetoothLowEnergyWrapper::GetInstance() {
664 if (instance_ == nullptr) { 665 if (g_instance_ == nullptr) {
665 instance_ = new BluetoothLowEnergyWrapper(); 666 g_instance_ = new BluetoothLowEnergyWrapper();
666 } 667 }
667 return instance_; 668 return g_instance_;
668 } 669 }
669 670
670 void BluetoothLowEnergyWrapper::DeleteInstance() { 671 void BluetoothLowEnergyWrapper::DeleteInstance() {
671 delete instance_; 672 delete g_instance_;
672 instance_ = nullptr; 673 g_instance_ = nullptr;
673 } 674 }
674 675
675 void BluetoothLowEnergyWrapper::SetInstanceForTest( 676 void BluetoothLowEnergyWrapper::SetInstanceForTest(
676 BluetoothLowEnergyWrapper* instance) { 677 BluetoothLowEnergyWrapper* instance) {
677 delete instance_; 678 delete g_instance_;
678 instance_ = instance; 679 g_instance_ = instance;
679 } 680 }
680 681
681 BluetoothLowEnergyWrapper::BluetoothLowEnergyWrapper() {} 682 BluetoothLowEnergyWrapper::BluetoothLowEnergyWrapper() {}
682 BluetoothLowEnergyWrapper::~BluetoothLowEnergyWrapper() {} 683 BluetoothLowEnergyWrapper::~BluetoothLowEnergyWrapper() {}
683 684
684 bool BluetoothLowEnergyWrapper::EnumerateKnownBluetoothLowEnergyDevices( 685 bool BluetoothLowEnergyWrapper::EnumerateKnownBluetoothLowEnergyDevices(
685 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices, 686 ScopedVector<BluetoothLowEnergyDeviceInfo>* devices,
686 std::string* error) { 687 std::string* error) {
687 if (!IsBluetoothLowEnergySupported()) { 688 if (!IsBluetoothLowEnergySupported()) {
688 *error = kPlatformNotSupported; 689 *error = kPlatformNotSupported;
(...skipping 24 matching lines...) Expand all
713 if (!IsBluetoothLowEnergySupported()) { 714 if (!IsBluetoothLowEnergySupported()) {
714 *error = kPlatformNotSupported; 715 *error = kPlatformNotSupported;
715 return false; 716 return false;
716 } 717 }
717 718
718 return CollectBluetoothLowEnergyDeviceServices(device_path, services, error); 719 return CollectBluetoothLowEnergyDeviceServices(device_path, services, error);
719 } 720 }
720 721
721 } // namespace win 722 } // namespace win
722 } // namespace device 723 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_classic_win_fake.cc ('k') | device/bluetooth/bluetooth_task_manager_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698