OLD | NEW |
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/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "base/win/scoped_handle.h" | 10 #include "base/win/scoped_handle.h" |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 for (DWORD i = 0;; ++i) { | 642 for (DWORD i = 0;; ++i) { |
643 scoped_ptr<BluetoothLowEnergyDeviceInfo> device_info; | 643 scoped_ptr<BluetoothLowEnergyDeviceInfo> device_info; |
644 DeviceInfoResult result = EnumerateSingleBluetoothLowEnergyDevice( | 644 DeviceInfoResult result = EnumerateSingleBluetoothLowEnergyDevice( |
645 info_set_handle, i, &device_info, error); | 645 info_set_handle, i, &device_info, error); |
646 switch (result) { | 646 switch (result) { |
647 case kNoMoreDevices: | 647 case kNoMoreDevices: |
648 return true; | 648 return true; |
649 case kError: | 649 case kError: |
650 return false; | 650 return false; |
651 case kOk: | 651 case kOk: |
652 devices->push_back(device_info.release()); | 652 devices->push_back(device_info.Pass()); |
653 } | 653 } |
654 } | 654 } |
655 } | 655 } |
656 | 656 |
657 bool EnumerateKnownBluetoothLowEnergyServices( | 657 bool EnumerateKnownBluetoothLowEnergyServices( |
658 const base::FilePath& device_path, | 658 const base::FilePath& device_path, |
659 ScopedVector<BluetoothLowEnergyServiceInfo>* services, | 659 ScopedVector<BluetoothLowEnergyServiceInfo>* services, |
660 std::string* error) { | 660 std::string* error) { |
661 if (!IsBluetoothLowEnergySupported()) { | 661 if (!IsBluetoothLowEnergySupported()) { |
662 *error = kPlatformNotSupported; | 662 *error = kPlatformNotSupported; |
663 return false; | 663 return false; |
664 } | 664 } |
665 | 665 |
666 return CollectBluetoothLowEnergyDeviceServices(device_path, services, error); | 666 return CollectBluetoothLowEnergyDeviceServices(device_path, services, error); |
667 } | 667 } |
668 | 668 |
669 bool ExtractBluetoothAddressFromDeviceInstanceIdForTesting( | 669 bool ExtractBluetoothAddressFromDeviceInstanceIdForTesting( |
670 const std::string& instance_id, | 670 const std::string& instance_id, |
671 BLUETOOTH_ADDRESS* btha, | 671 BLUETOOTH_ADDRESS* btha, |
672 std::string* error) { | 672 std::string* error) { |
673 return ExtractBluetoothAddressFromDeviceInstanceId(instance_id, btha, error); | 673 return ExtractBluetoothAddressFromDeviceInstanceId(instance_id, btha, error); |
674 } | 674 } |
675 | 675 |
676 } // namespace win | 676 } // namespace win |
677 } // namespace device | 677 } // namespace device |
OLD | NEW |