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

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

Issue 2319213005: 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
« no previous file with comments | « components/arc/bluetooth/arc_bluetooth_bridge.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 DCHECK(CalledOnValidThread());
948 gatt_connections_[addr->To<std::string>()] = std::move(connection);
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()) {
963 LOG(WARNING) << "OnGattDisconnected called, "
964 << "but no gatt connection was found";
965 } else {
966 gatt_connections_.erase(it);
967 }
968
958 OnGattConnectStateChanged(std::move(addr), false); 969 OnGattConnectStateChanged(std::move(addr), false);
959 } 970 }
960 971
961 void ArcBluetoothBridge::ConnectLEDevice( 972 void ArcBluetoothBridge::ConnectLEDevice(
962 mojom::BluetoothAddressPtr remote_addr) { 973 mojom::BluetoothAddressPtr remote_addr) {
963 if (!HasBluetoothInstance()) 974 if (!HasBluetoothInstance())
964 return; 975 return;
965 976
966 BluetoothDevice* device = 977 BluetoothDevice* device =
967 bluetooth_adapter_->GetDevice(remote_addr->To<std::string>()); 978 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 1843 LOG(WARNING) << "Bluetooth instance is too old (version " << version
1833 << ") need version " << version_need; 1844 << ") need version " << version_need;
1834 return false; 1845 return false;
1835 } 1846 }
1836 1847
1837 bool ArcBluetoothBridge::CalledOnValidThread() { 1848 bool ArcBluetoothBridge::CalledOnValidThread() {
1838 return thread_checker_.CalledOnValidThread(); 1849 return thread_checker_.CalledOnValidThread();
1839 } 1850 }
1840 1851
1841 } // namespace arc 1852 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/bluetooth/arc_bluetooth_bridge.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698