OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/arc/bluetooth/arc_bluetooth_bridge.h" | 5 #include "components/arc/bluetooth/arc_bluetooth_bridge.h" |
6 | 6 |
7 #include <bluetooth/bluetooth.h> | 7 #include <bluetooth/bluetooth.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
936 return; | 936 return; |
937 | 937 |
938 DCHECK(addr); | 938 DCHECK(addr); |
939 | 939 |
940 arc_bridge_service()->bluetooth()->instance()->OnLEConnectionStateChange( | 940 arc_bridge_service()->bluetooth()->instance()->OnLEConnectionStateChange( |
941 std::move(addr), connected); | 941 std::move(addr), connected); |
942 } | 942 } |
943 | 943 |
944 void ArcBluetoothBridge::OnGattConnected( | 944 void ArcBluetoothBridge::OnGattConnected( |
945 mojom::BluetoothAddressPtr addr, | 945 mojom::BluetoothAddressPtr addr, |
946 std::unique_ptr<BluetoothGattConnection> connection) const { | 946 std::unique_ptr<BluetoothGattConnection> connection) { |
947 gatt_connections_.emplace(addr->To<std::string>(), std::move(connection)); | |
Luis Héctor Chávez
2016/09/07 19:54:14
nit: DCHECK(CalledOnValidThread());
| |
947 OnGattConnectStateChanged(std::move(addr), true); | 948 OnGattConnectStateChanged(std::move(addr), true); |
948 } | 949 } |
949 | 950 |
950 void ArcBluetoothBridge::OnGattConnectError( | 951 void ArcBluetoothBridge::OnGattConnectError( |
951 mojom::BluetoothAddressPtr addr, | 952 mojom::BluetoothAddressPtr addr, |
952 BluetoothDevice::ConnectErrorCode error_code) const { | 953 BluetoothDevice::ConnectErrorCode error_code) const { |
953 OnGattConnectStateChanged(std::move(addr), false); | 954 OnGattConnectStateChanged(std::move(addr), false); |
954 } | 955 } |
955 | 956 |
956 void ArcBluetoothBridge::OnGattDisconnected( | 957 void ArcBluetoothBridge::OnGattDisconnected( |
957 mojom::BluetoothAddressPtr addr) const { | 958 mojom::BluetoothAddressPtr addr) { |
959 auto it = gatt_connections_.find(addr->To<std::string>()); | |
Luis Héctor Chávez
2016/09/07 19:54:14
nit: DCHECK(CalledOnValidThread());
| |
960 if (it == gatt_connections_.end()) | |
961 LOG(WARNING) << "OnGattDisconnected called, " | |
962 << "but no gatt connection was found"; | |
963 else | |
964 gatt_connections_.erase(it); | |
965 | |
958 OnGattConnectStateChanged(std::move(addr), false); | 966 OnGattConnectStateChanged(std::move(addr), false); |
959 } | 967 } |
960 | 968 |
961 void ArcBluetoothBridge::ConnectLEDevice( | 969 void ArcBluetoothBridge::ConnectLEDevice( |
962 mojom::BluetoothAddressPtr remote_addr) { | 970 mojom::BluetoothAddressPtr remote_addr) { |
963 if (!HasBluetoothInstance()) | 971 if (!HasBluetoothInstance()) |
964 return; | 972 return; |
965 | 973 |
966 BluetoothDevice* device = | 974 BluetoothDevice* device = |
967 bluetooth_adapter_->GetDevice(remote_addr->To<std::string>()); | 975 bluetooth_adapter_->GetDevice(remote_addr->To<std::string>()); |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1832 LOG(WARNING) << "Bluetooth instance is too old (version " << version | 1840 LOG(WARNING) << "Bluetooth instance is too old (version " << version |
1833 << ") need version " << version_need; | 1841 << ") need version " << version_need; |
1834 return false; | 1842 return false; |
1835 } | 1843 } |
1836 | 1844 |
1837 bool ArcBluetoothBridge::CalledOnValidThread() { | 1845 bool ArcBluetoothBridge::CalledOnValidThread() { |
1838 return thread_checker_.CalledOnValidThread(); | 1846 return thread_checker_.CalledOnValidThread(); |
1839 } | 1847 } |
1840 | 1848 |
1841 } // namespace arc | 1849 } // namespace arc |
OLD | NEW |