Chromium Code Reviews| 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 DCHECK(CalledOnValidThread()); | |
| 948 gatt_connections_.emplace(addr->To<std::string>(), std::move(connection)); | |
|
Rahul Chaturvedi
2016/09/07 21:31:38
Also, don't expect to "not" have the address in th
Rahul Chaturvedi
2016/09/07 21:31:39
can't use map::emplace
Eric Caruso
2016/09/07 21:33:31
I switched this out for operator[] which will caus
| |
| 947 OnGattConnectStateChanged(std::move(addr), true); | 949 OnGattConnectStateChanged(std::move(addr), true); |
| 948 } | 950 } |
| 949 | 951 |
| 950 void ArcBluetoothBridge::OnGattConnectError( | 952 void ArcBluetoothBridge::OnGattConnectError( |
| 951 mojom::BluetoothAddressPtr addr, | 953 mojom::BluetoothAddressPtr addr, |
| 952 BluetoothDevice::ConnectErrorCode error_code) const { | 954 BluetoothDevice::ConnectErrorCode error_code) const { |
| 953 OnGattConnectStateChanged(std::move(addr), false); | 955 OnGattConnectStateChanged(std::move(addr), false); |
| 954 } | 956 } |
| 955 | 957 |
| 956 void ArcBluetoothBridge::OnGattDisconnected( | 958 void ArcBluetoothBridge::OnGattDisconnected( |
| 957 mojom::BluetoothAddressPtr addr) const { | 959 mojom::BluetoothAddressPtr addr) { |
| 960 DCHECK(CalledOnValidThread()); | |
| 961 auto it = gatt_connections_.find(addr->To<std::string>()); | |
| 962 if (it == gatt_connections_.end()) | |
|
Rahul Chaturvedi
2016/09/07 21:31:38
nit: {} around multiline
| |
| 963 LOG(WARNING) << "OnGattDisconnected called, " | |
| 964 << "but no gatt connection was found"; | |
| 965 else | |
| 966 gatt_connections_.erase(it); | |
| 967 | |
| 958 OnGattConnectStateChanged(std::move(addr), false); | 968 OnGattConnectStateChanged(std::move(addr), false); |
| 959 } | 969 } |
| 960 | 970 |
| 961 void ArcBluetoothBridge::ConnectLEDevice( | 971 void ArcBluetoothBridge::ConnectLEDevice( |
| 962 mojom::BluetoothAddressPtr remote_addr) { | 972 mojom::BluetoothAddressPtr remote_addr) { |
| 963 if (!HasBluetoothInstance()) | 973 if (!HasBluetoothInstance()) |
| 964 return; | 974 return; |
| 965 | 975 |
| 966 BluetoothDevice* device = | 976 BluetoothDevice* device = |
| 967 bluetooth_adapter_->GetDevice(remote_addr->To<std::string>()); | 977 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 | 1842 LOG(WARNING) << "Bluetooth instance is too old (version " << version |
| 1833 << ") need version " << version_need; | 1843 << ") need version " << version_need; |
| 1834 return false; | 1844 return false; |
| 1835 } | 1845 } |
| 1836 | 1846 |
| 1837 bool ArcBluetoothBridge::CalledOnValidThread() { | 1847 bool ArcBluetoothBridge::CalledOnValidThread() { |
| 1838 return thread_checker_.CalledOnValidThread(); | 1848 return thread_checker_.CalledOnValidThread(); |
| 1839 } | 1849 } |
| 1840 | 1850 |
| 1841 } // namespace arc | 1851 } // namespace arc |
| OLD | NEW |