Chromium Code Reviews| 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/bluetooth_adapter_chromeos.h" | 5 #include "device/bluetooth/bluetooth_adapter_chromeos.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 DBusThreadManager::Get()->GetBluetoothAdapterClient()->GetAdapters(); | 121 DBusThreadManager::Get()->GetBluetoothAdapterClient()->GetAdapters(); |
| 122 | 122 |
| 123 if (!object_paths.empty()) { | 123 if (!object_paths.empty()) { |
| 124 VLOG(1) << object_paths.size() << " Bluetooth adapter(s) available."; | 124 VLOG(1) << object_paths.size() << " Bluetooth adapter(s) available."; |
| 125 SetAdapter(object_paths[0]); | 125 SetAdapter(object_paths[0]); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 BluetoothAdapterChromeOS::~BluetoothAdapterChromeOS() { | 129 BluetoothAdapterChromeOS::~BluetoothAdapterChromeOS() { |
| 130 Shutdown(); | 130 Shutdown(); |
| 131 } | 131 } |
|
Ilya Sherman
2015/02/21 01:22:10
Should any remaining profiles be deleted as part o
Marie Janssen
2015/02/23 17:49:09
All profiles will get unregistered (and subsequent
Ilya Sherman
2015/02/24 05:26:06
I'm not following how PresentChanged(false) result
Marie Janssen
2015/02/24 18:49:21
Sorry this was unclear wording. Shutdown() eventu
| |
| 132 | 132 |
| 133 void BluetoothAdapterChromeOS::DeleteOnCorrectThread() const { | 133 void BluetoothAdapterChromeOS::DeleteOnCorrectThread() const { |
| 134 if (ui_task_runner_->RunsTasksOnCurrentThread() || | 134 if (ui_task_runner_->RunsTasksOnCurrentThread() || |
| 135 !ui_task_runner_->DeleteSoon(FROM_HERE, this)) | 135 !ui_task_runner_->DeleteSoon(FROM_HERE, this)) |
| 136 delete this; | 136 delete this; |
| 137 } | 137 } |
| 138 | 138 |
| 139 void BluetoothAdapterChromeOS::AddObserver( | 139 void BluetoothAdapterChromeOS::AddObserver( |
| 140 BluetoothAdapter::Observer* observer) { | 140 BluetoothAdapter::Observer* observer) { |
| 141 DCHECK(observer); | 141 DCHECK(observer); |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 957 | 957 |
| 958 if (profiles_.find(uuid) != profiles_.end()) { | 958 if (profiles_.find(uuid) != profiles_.end()) { |
| 959 // TODO(jamuraa) check that the options are the same and error when they are | 959 // TODO(jamuraa) check that the options are the same and error when they are |
| 960 // not. | 960 // not. |
| 961 SetProfileDelegate(uuid, device_path, delegate, success_callback, | 961 SetProfileDelegate(uuid, device_path, delegate, success_callback, |
| 962 error_callback); | 962 error_callback); |
| 963 return; | 963 return; |
| 964 } | 964 } |
| 965 | 965 |
| 966 profiles_[uuid] = BluetoothAdapterProfileChromeOS::Register( | 966 profiles_[uuid] = BluetoothAdapterProfileChromeOS::Register( |
| 967 this, uuid, options, | 967 uuid, options, |
| 968 base::Bind(&BluetoothAdapterChromeOS::OnRegisterProfile, this, uuid, | 968 base::Bind(&BluetoothAdapterChromeOS::OnRegisterProfile, this, uuid, |
| 969 device_path, delegate, success_callback, error_callback), | 969 device_path, delegate, success_callback, error_callback), |
| 970 base::Bind(&BluetoothAdapterChromeOS::OnRegisterProfileError, this, uuid, | 970 base::Bind(&BluetoothAdapterChromeOS::OnRegisterProfileError, this, uuid, |
| 971 error_callback)); | 971 error_callback)); |
| 972 } | 972 } |
| 973 | 973 |
| 974 void BluetoothAdapterChromeOS::ReleaseProfile(const BluetoothUUID& uuid) { | 974 void BluetoothAdapterChromeOS::ReleaseProfile( |
| 975 const dbus::ObjectPath& device_path, | |
| 976 BluetoothAdapterProfileChromeOS* profile) { | |
| 977 profile->RemoveDelegate( | |
| 978 device_path, base::Bind(&BluetoothAdapterChromeOS::RemoveProfile, | |
| 979 weak_ptr_factory_.GetWeakPtr(), profile->uuid())); | |
|
Ilya Sherman
2015/02/21 01:22:10
nit: Is this what git cl format produces? The for
Marie Janssen
2015/02/23 17:49:09
This is in fact what cl format produced. It looks
| |
| 980 } | |
| 981 | |
| 982 void BluetoothAdapterChromeOS::RemoveProfile(const BluetoothUUID& uuid) { | |
| 975 if (profiles_.find(uuid) != profiles_.end()) { | 983 if (profiles_.find(uuid) != profiles_.end()) { |
| 976 delete profiles_[uuid]; | 984 delete profiles_[uuid]; |
| 977 profiles_.erase(uuid); | 985 profiles_.erase(uuid); |
| 978 } | 986 } |
| 979 } | 987 } |
| 980 | 988 |
| 981 void BluetoothAdapterChromeOS::OnRegisterProfile( | 989 void BluetoothAdapterChromeOS::OnRegisterProfile( |
| 982 const BluetoothUUID& uuid, | 990 const BluetoothUUID& uuid, |
| 983 const dbus::ObjectPath& device_path, | 991 const dbus::ObjectPath& device_path, |
| 984 BluetoothProfileServiceProvider::Delegate* delegate, | 992 BluetoothProfileServiceProvider::Delegate* delegate, |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1004 } | 1012 } |
| 1005 | 1013 |
| 1006 void BluetoothAdapterChromeOS::OnRegisterProfileError( | 1014 void BluetoothAdapterChromeOS::OnRegisterProfileError( |
| 1007 const BluetoothUUID& uuid, | 1015 const BluetoothUUID& uuid, |
| 1008 const ErrorCompletionCallback& error_callback, | 1016 const ErrorCompletionCallback& error_callback, |
| 1009 const std::string& error_name, | 1017 const std::string& error_name, |
| 1010 const std::string& error_message) { | 1018 const std::string& error_message) { |
| 1011 LOG(WARNING) << object_path_.value() | 1019 LOG(WARNING) << object_path_.value() |
| 1012 << ": Failed to register profile: " << error_name << ": " | 1020 << ": Failed to register profile: " << error_name << ": " |
| 1013 << error_message; | 1021 << error_message; |
| 1022 delete profiles_[uuid]; | |
| 1014 error_callback.Run(error_message); | 1023 error_callback.Run(error_message); |
| 1015 ReleaseProfile(uuid); | |
| 1016 } | 1024 } |
| 1017 | 1025 |
| 1018 void BluetoothAdapterChromeOS::OnSetDiscoverable( | 1026 void BluetoothAdapterChromeOS::OnSetDiscoverable( |
| 1019 const base::Closure& callback, | 1027 const base::Closure& callback, |
| 1020 const ErrorCallback& error_callback, | 1028 const ErrorCallback& error_callback, |
| 1021 bool success) { | 1029 bool success) { |
| 1022 DCHECK(IsPresent()); | 1030 DCHECK(IsPresent()); |
| 1023 // Set the discoverable_timeout property to zero so the adapter remains | 1031 // Set the discoverable_timeout property to zero so the adapter remains |
| 1024 // discoverable forever. | 1032 // discoverable forever. |
| 1025 DBusThreadManager::Get()->GetBluetoothAdapterClient()-> | 1033 DBusThreadManager::Get()->GetBluetoothAdapterClient()-> |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1217 | 1225 |
| 1218 // If the queued request resulted in a pending call, then let it | 1226 // If the queued request resulted in a pending call, then let it |
| 1219 // asynchonously process the remaining queued requests once the pending | 1227 // asynchonously process the remaining queued requests once the pending |
| 1220 // call returns. | 1228 // call returns. |
| 1221 if (discovery_request_pending_) | 1229 if (discovery_request_pending_) |
| 1222 return; | 1230 return; |
| 1223 } | 1231 } |
| 1224 } | 1232 } |
| 1225 | 1233 |
| 1226 } // namespace chromeos | 1234 } // namespace chromeos |
| OLD | NEW |