| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "device/bluetooth/bluez/bluetooth_adapter_bluez.h" | 5 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 base::ThreadTaskRunnerHandle::Get()->PostTask( | 201 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 202 FROM_HERE, base::Bind(&BluetoothAdapterBlueZ::Init, | 202 FROM_HERE, base::Bind(&BluetoothAdapterBlueZ::Init, |
| 203 weak_ptr_factory_.GetWeakPtr())); | 203 weak_ptr_factory_.GetWeakPtr())); |
| 204 return; | 204 return; |
| 205 } | 205 } |
| 206 bluez::BluezDBusManager::Get()->CallWhenObjectManagerSupportIsKnown( | 206 bluez::BluezDBusManager::Get()->CallWhenObjectManagerSupportIsKnown( |
| 207 base::Bind(&BluetoothAdapterBlueZ::Init, weak_ptr_factory_.GetWeakPtr())); | 207 base::Bind(&BluetoothAdapterBlueZ::Init, weak_ptr_factory_.GetWeakPtr())); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void BluetoothAdapterBlueZ::Init() { | 210 void BluetoothAdapterBlueZ::Init() { |
| 211 // If the platform doesn't support Object Manager then Bluez 5 is probably | 211 // We may have been shutdown already, in which case do nothing. If the |
| 212 // not present. In this case we just return without initializing anything. | 212 // platform doesn't support Object Manager then Bluez 5 is probably not |
| 213 if (!bluez::BluezDBusManager::Get()->IsObjectManagerSupported()) { | 213 // present. In this case we just return without initializing anything. |
| 214 if (dbus_is_shutdown_ || |
| 215 !bluez::BluezDBusManager::Get()->IsObjectManagerSupported()) { |
| 214 initialized_ = true; | 216 initialized_ = true; |
| 215 init_callback_.Run(); | 217 init_callback_.Run(); |
| 216 return; | 218 return; |
| 217 } | 219 } |
| 218 | 220 |
| 219 bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->AddObserver( | 221 bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->AddObserver( |
| 220 this); | 222 this); |
| 221 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->AddObserver(this); | 223 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->AddObserver(this); |
| 222 bluez::BluezDBusManager::Get()->GetBluetoothInputClient()->AddObserver(this); | 224 bluez::BluezDBusManager::Get()->GetBluetoothInputClient()->AddObserver(this); |
| 223 | 225 |
| (...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1685 } else if (error_name == bluetooth_adapter::kErrorAlreadyExists) { | 1687 } else if (error_name == bluetooth_adapter::kErrorAlreadyExists) { |
| 1686 code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_RECORD_ALREADY_EXISTS; | 1688 code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_RECORD_ALREADY_EXISTS; |
| 1687 } else if (error_name == bluetooth_adapter::kErrorNotReady) { | 1689 } else if (error_name == bluetooth_adapter::kErrorNotReady) { |
| 1688 code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_ADAPTER_NOT_READY; | 1690 code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_ADAPTER_NOT_READY; |
| 1689 } | 1691 } |
| 1690 | 1692 |
| 1691 error_callback.Run(code); | 1693 error_callback.Run(code); |
| 1692 } | 1694 } |
| 1693 | 1695 |
| 1694 } // namespace bluez | 1696 } // namespace bluez |
| OLD | NEW |