Chromium Code Reviews| Index: device/bluetooth/bluetooth_adapter_chromeos.cc |
| diff --git a/device/bluetooth/bluetooth_adapter_chromeos.cc b/device/bluetooth/bluetooth_adapter_chromeos.cc |
| index e69c479a77fe63c0a96faa5085b1efd95935c11e..bbe8cf8e30255f40ad8da154c31d6a8f4725b97c 100644 |
| --- a/device/bluetooth/bluetooth_adapter_chromeos.cc |
| +++ b/device/bluetooth/bluetooth_adapter_chromeos.cc |
| @@ -72,8 +72,29 @@ base::WeakPtr<BluetoothAdapter> BluetoothAdapterChromeOS::CreateAdapter() { |
| return adapter->weak_ptr_factory_.GetWeakPtr(); |
| } |
| +void BluetoothAdapterChromeOS::Shutdown() { |
| + if (is_shutdown_) |
| + return; |
| + is_shutdown_ = true; |
|
armansito
2015/01/14 20:49:04
Here I would explicitly set present as false or at
scheib
2015/01/14 23:07:27
Done: reworked to call RemoveAdapter().
|
| + DCHECK(DBusThreadManager::IsInitialized()) |
| + << "Call BluetoothAdapterFactory::Shutdown() before " |
| + "DBusThreadManager::Shutdown()."; |
| + DBusThreadManager::Get()->GetBluetoothAdapterClient()->RemoveObserver(this); |
| + DBusThreadManager::Get()->GetBluetoothDeviceClient()->RemoveObserver(this); |
| + DBusThreadManager::Get()->GetBluetoothInputClient()->RemoveObserver(this); |
| + |
| + VLOG(1) << "Unregistering pairing agent"; |
| + DBusThreadManager::Get()->GetBluetoothAgentManagerClient()->UnregisterAgent( |
| + dbus::ObjectPath(kAgentPath), base::Bind(&base::DoNothing), |
| + base::Bind(&OnUnregisterAgentError)); |
| + |
| + agent_.reset(); |
| + STLDeleteValues(&devices_); |
| +} |
| + |
| BluetoothAdapterChromeOS::BluetoothAdapterChromeOS() |
| - : num_discovery_sessions_(0), |
| + : is_shutdown_(false), |
| + num_discovery_sessions_(0), |
| discovery_request_pending_(false), |
| weak_ptr_factory_(this) { |
| ui_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| @@ -99,16 +120,7 @@ BluetoothAdapterChromeOS::BluetoothAdapterChromeOS() |
| } |
| BluetoothAdapterChromeOS::~BluetoothAdapterChromeOS() { |
| - DBusThreadManager::Get()->GetBluetoothAdapterClient()->RemoveObserver(this); |
| - DBusThreadManager::Get()->GetBluetoothDeviceClient()->RemoveObserver(this); |
| - DBusThreadManager::Get()->GetBluetoothInputClient()->RemoveObserver(this); |
| - |
| - VLOG(1) << "Unregistering pairing agent"; |
| - DBusThreadManager::Get()->GetBluetoothAgentManagerClient()-> |
| - UnregisterAgent( |
| - dbus::ObjectPath(kAgentPath), |
| - base::Bind(&base::DoNothing), |
| - base::Bind(&OnUnregisterAgentError)); |
| + Shutdown(); |
| } |
| void BluetoothAdapterChromeOS::DeleteOnCorrectThread() const { |
| @@ -175,7 +187,7 @@ bool BluetoothAdapterChromeOS::IsInitialized() const { |
| } |
| bool BluetoothAdapterChromeOS::IsPresent() const { |
| - return !object_path_.value().empty(); |
| + return !is_shutdown_ && !object_path_.value().empty(); |
| } |
| bool BluetoothAdapterChromeOS::IsPowered() const { |