OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_task_manager_win.h" | 5 #include "device/bluetooth/bluetooth_task_manager_win.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <winsock2.h> | 8 #include <winsock2.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 // List all known GATT service devices on the machine. | 781 // List all known GATT service devices on the machine. |
782 ScopedVector<win::BluetoothLowEnergyDeviceInfo> gatt_service_devices; | 782 ScopedVector<win::BluetoothLowEnergyDeviceInfo> gatt_service_devices; |
783 bool success = win::BluetoothLowEnergyWrapper::GetInstance() | 783 bool success = win::BluetoothLowEnergyWrapper::GetInstance() |
784 ->EnumerateKnownBluetoothLowEnergyGattServiceDevices( | 784 ->EnumerateKnownBluetoothLowEnergyGattServiceDevices( |
785 &gatt_service_devices, &error); | 785 &gatt_service_devices, &error); |
786 if (!success) { | 786 if (!success) { |
787 LogPollingError(error.c_str(), 0); | 787 LogPollingError(error.c_str(), 0); |
788 return false; | 788 return false; |
789 } | 789 } |
790 | 790 |
791 for (auto gatt_service_device : gatt_service_devices) { | 791 for (auto* gatt_service_device : gatt_service_devices) { |
792 // Only care about the service devices with |device_address|. | 792 // Only care about the service devices with |device_address|. |
793 if (BluetoothAddressToCanonicalString(gatt_service_device->address) != | 793 if (BluetoothAddressToCanonicalString(gatt_service_device->address) != |
794 device_address) { | 794 device_address) { |
795 continue; | 795 continue; |
796 } | 796 } |
797 | 797 |
798 // Discover this service device's contained services. | 798 // Discover this service device's contained services. |
799 ScopedVector<win::BluetoothLowEnergyServiceInfo> gatt_services; | 799 ScopedVector<win::BluetoothLowEnergyServiceInfo> gatt_services; |
800 if (!win::BluetoothLowEnergyWrapper::GetInstance() | 800 if (!win::BluetoothLowEnergyWrapper::GetInstance() |
801 ->EnumerateKnownBluetoothLowEnergyServices( | 801 ->EnumerateKnownBluetoothLowEnergyServices( |
802 gatt_service_device->path, &gatt_services, &error)) { | 802 gatt_service_device->path, &gatt_services, &error)) { |
803 LogPollingError(error.c_str(), 0); | 803 LogPollingError(error.c_str(), 0); |
804 continue; | 804 continue; |
805 } | 805 } |
806 | 806 |
807 // Usually each service device correspond to one Gatt service. | 807 // Usually each service device correspond to one Gatt service. |
808 if (gatt_services.size() > 1) { | 808 if (gatt_services.size() > 1) { |
809 LOG(WARNING) << "This GATT service device contains more than one (" | 809 LOG(WARNING) << "This GATT service device contains more than one (" |
810 << gatt_services.size() << ") services"; | 810 << gatt_services.size() << ") services"; |
811 } | 811 } |
812 | 812 |
813 // Associate service device to corresponding service record. Attribute | 813 // Associate service device to corresponding service record. Attribute |
814 // handle is unique on one device. | 814 // handle is unique on one device. |
815 for (auto gatt_service : gatt_services) { | 815 for (auto* gatt_service : gatt_services) { |
816 for (auto service_record_state : *service_record_states) { | 816 for (auto* service_record_state : *service_record_states) { |
817 if (service_record_state->attribute_handle == | 817 if (service_record_state->attribute_handle == |
818 gatt_service->attribute_handle) { | 818 gatt_service->attribute_handle) { |
819 service_record_state->path = gatt_service_device->path; | 819 service_record_state->path = gatt_service_device->path; |
820 break; | 820 break; |
821 } | 821 } |
822 } | 822 } |
823 } | 823 } |
824 } | 824 } |
825 | 825 |
826 return true; | 826 return true; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 void BluetoothTaskManagerWin::PostUnregisterGattCharacteristicValueChangedEvent( | 1034 void BluetoothTaskManagerWin::PostUnregisterGattCharacteristicValueChangedEvent( |
1035 PVOID event_handle) { | 1035 PVOID event_handle) { |
1036 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 1036 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
1037 bluetooth_task_runner_->PostTask( | 1037 bluetooth_task_runner_->PostTask( |
1038 FROM_HERE, base::Bind(&BluetoothTaskManagerWin:: | 1038 FROM_HERE, base::Bind(&BluetoothTaskManagerWin:: |
1039 UnregisterGattCharacteristicValueChangedEvent, | 1039 UnregisterGattCharacteristicValueChangedEvent, |
1040 this, event_handle)); | 1040 this, event_handle)); |
1041 } | 1041 } |
1042 | 1042 |
1043 } // namespace device | 1043 } // namespace device |
OLD | NEW |