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

Side by Side Diff: components/arc/bluetooth/arc_bluetooth_bridge.cc

Issue 2321693002: arc/bluetooth: Save BluetoothGattConnection objects (Closed)
Patch Set: Created 4 years, 3 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 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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698