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

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

Issue 2320293002: 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 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 return; 912 return;
913 913
914 DCHECK(addr); 914 DCHECK(addr);
915 915
916 arc_bridge_service()->bluetooth()->instance()->OnLEConnectionStateChange( 916 arc_bridge_service()->bluetooth()->instance()->OnLEConnectionStateChange(
917 std::move(addr), connected); 917 std::move(addr), connected);
918 } 918 }
919 919
920 void ArcBluetoothBridge::OnGattConnected( 920 void ArcBluetoothBridge::OnGattConnected(
921 mojom::BluetoothAddressPtr addr, 921 mojom::BluetoothAddressPtr addr,
922 std::unique_ptr<BluetoothGattConnection> connection) const { 922 std::unique_ptr<BluetoothGattConnection> connection) {
923 DCHECK(CalledOnValidThread());
924 gatt_connections_[addr->To<std::string>()] = std::move(connection);
923 OnGattConnectStateChanged(std::move(addr), true); 925 OnGattConnectStateChanged(std::move(addr), true);
924 } 926 }
925 927
926 void ArcBluetoothBridge::OnGattConnectError( 928 void ArcBluetoothBridge::OnGattConnectError(
927 mojom::BluetoothAddressPtr addr, 929 mojom::BluetoothAddressPtr addr,
928 BluetoothDevice::ConnectErrorCode error_code) const { 930 BluetoothDevice::ConnectErrorCode error_code) const {
929 OnGattConnectStateChanged(std::move(addr), false); 931 OnGattConnectStateChanged(std::move(addr), false);
930 } 932 }
931 933
932 void ArcBluetoothBridge::OnGattDisconnected( 934 void ArcBluetoothBridge::OnGattDisconnected(
933 mojom::BluetoothAddressPtr addr) const { 935 mojom::BluetoothAddressPtr addr) {
936 DCHECK(CalledOnValidThread());
937 auto it = gatt_connections_.find(addr->To<std::string>());
938 if (it == gatt_connections_.end()) {
939 LOG(WARNING) << "OnGattDisconnected called, "
940 << "but no gatt connection was found";
941 } else {
942 gatt_connections_.erase(it);
943 }
944
934 OnGattConnectStateChanged(std::move(addr), false); 945 OnGattConnectStateChanged(std::move(addr), false);
935 } 946 }
936 947
937 void ArcBluetoothBridge::ConnectLEDevice( 948 void ArcBluetoothBridge::ConnectLEDevice(
938 mojom::BluetoothAddressPtr remote_addr) { 949 mojom::BluetoothAddressPtr remote_addr) {
939 if (!HasBluetoothInstance()) 950 if (!HasBluetoothInstance())
940 return; 951 return;
941 952
942 BluetoothDevice* device = 953 BluetoothDevice* device =
943 bluetooth_adapter_->GetDevice(remote_addr->To<std::string>()); 954 bluetooth_adapter_->GetDevice(remote_addr->To<std::string>());
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 LOG(WARNING) << "Bluetooth instance is too old (version " << version 1797 LOG(WARNING) << "Bluetooth instance is too old (version " << version
1787 << ") need version " << version_need; 1798 << ") need version " << version_need;
1788 return false; 1799 return false;
1789 } 1800 }
1790 1801
1791 bool ArcBluetoothBridge::CalledOnValidThread() { 1802 bool ArcBluetoothBridge::CalledOnValidThread() {
1792 return thread_checker_.CalledOnValidThread(); 1803 return thread_checker_.CalledOnValidThread();
1793 } 1804 }
1794 1805
1795 } // namespace arc 1806 } // 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