| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 283 |
| 284 // We can downcast here because we are always running on Chrome OS, and | 284 // We can downcast here because we are always running on Chrome OS, and |
| 285 // so our adapter uses BlueZ. | 285 // so our adapter uses BlueZ. |
| 286 bluetooth_adapter_ = | 286 bluetooth_adapter_ = |
| 287 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter.get()); | 287 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter.get()); |
| 288 | 288 |
| 289 // The ARC instance was ready before the Bluetooth adapter, hence we didn't | 289 // The ARC instance was ready before the Bluetooth adapter, hence we didn't |
| 290 // register ourselves as an observer with it then. Since our adapter is | 290 // register ourselves as an observer with it then. Since our adapter is |
| 291 // ready, we should register it now. | 291 // ready, we should register it now. |
| 292 if (!bluetooth_adapter_->HasObserver(this) && | 292 if (!bluetooth_adapter_->HasObserver(this) && |
| 293 arc_bridge_service()->bluetooth()->instance()) { | 293 arc_bridge_service()->bluetooth()->HasInstance()) { |
| 294 bluetooth_adapter_->AddObserver(this); | 294 bluetooth_adapter_->AddObserver(this); |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 | 297 |
| 298 void ArcBluetoothBridge::OnInstanceReady() { | 298 void ArcBluetoothBridge::OnInstanceReady() { |
| 299 mojom::BluetoothInstance* bluetooth_instance = | 299 mojom::BluetoothInstance* bluetooth_instance = |
| 300 arc_bridge_service()->bluetooth()->instance(); | 300 arc_bridge_service()->bluetooth()->GetInstanceForMethod("Init"); |
| 301 if (!bluetooth_instance) { | 301 CHECK(bluetooth_instance); |
| 302 LOG(ERROR) << "OnBluetoothInstanceReady called, " | |
| 303 << "but no bluetooth instance found"; | |
| 304 return; | |
| 305 } | |
| 306 | 302 |
| 307 bluetooth_instance->Init(binding_.CreateInterfacePtrAndBind()); | 303 bluetooth_instance->Init(binding_.CreateInterfacePtrAndBind()); |
| 308 | 304 |
| 309 // The Bluetooth adapter was ready before the ARC instance, hence we didn't | 305 // The Bluetooth adapter was ready before the ARC instance, hence we didn't |
| 310 // register ourselves as an observer with it then. Since our instance is | 306 // register ourselves as an observer with it then. Since our instance is |
| 311 // ready, we should register it now. | 307 // ready, we should register it now. |
| 312 if (bluetooth_adapter_ && !bluetooth_adapter_->HasObserver(this)) | 308 if (bluetooth_adapter_ && !bluetooth_adapter_->HasObserver(this)) |
| 313 bluetooth_adapter_->AddObserver(this); | 309 bluetooth_adapter_->AddObserver(this); |
| 314 } | 310 } |
| 315 | 311 |
| (...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2026 sdp_bluetooth_instance->OnGetSdpRecords( | 2022 sdp_bluetooth_instance->OnGetSdpRecords( |
| 2027 status, std::move(remote_addr), target_uuid, | 2023 status, std::move(remote_addr), target_uuid, |
| 2028 mojo::Array<mojom::BluetoothSdpRecordPtr>::New(0)); | 2024 mojo::Array<mojom::BluetoothSdpRecordPtr>::New(0)); |
| 2029 } | 2025 } |
| 2030 | 2026 |
| 2031 bool ArcBluetoothBridge::CalledOnValidThread() { | 2027 bool ArcBluetoothBridge::CalledOnValidThread() { |
| 2032 return thread_checker_.CalledOnValidThread(); | 2028 return thread_checker_.CalledOnValidThread(); |
| 2033 } | 2029 } |
| 2034 | 2030 |
| 2035 } // namespace arc | 2031 } // namespace arc |
| OLD | NEW |