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 946 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 this->weak_ptr_factory_.GetWeakPtr(), 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::RemoveProfile(const BluetoothUUID& uuid) { |
975 if (profiles_.find(uuid) != profiles_.end()) { | 975 if (profiles_.find(uuid) != profiles_.end()) { |
Ilya Sherman
2015/02/19 20:37:58
nit: I don't think you need the if stmt at all any
Marie Janssen
2015/02/20 22:53:46
Done.
| |
976 delete profiles_[uuid]; | |
977 profiles_.erase(uuid); | 976 profiles_.erase(uuid); |
Ilya Sherman
2015/02/19 20:37:58
What code is responsible for freeing the memory fo
Marie Janssen
2015/02/20 22:53:46
Profiles are now owned by BluetoothAdapterChromeOS
| |
978 } | 977 } |
979 } | 978 } |
980 | 979 |
981 void BluetoothAdapterChromeOS::OnRegisterProfile( | 980 void BluetoothAdapterChromeOS::OnRegisterProfile( |
982 const BluetoothUUID& uuid, | 981 const BluetoothUUID& uuid, |
983 const dbus::ObjectPath& device_path, | 982 const dbus::ObjectPath& device_path, |
984 BluetoothProfileServiceProvider::Delegate* delegate, | 983 BluetoothProfileServiceProvider::Delegate* delegate, |
985 const ProfileRegisteredCallback& success_callback, | 984 const ProfileRegisteredCallback& success_callback, |
986 const ErrorCompletionCallback& error_callback) { | 985 const ErrorCompletionCallback& error_callback) { |
987 SetProfileDelegate(uuid, device_path, delegate, success_callback, | 986 SetProfileDelegate(uuid, device_path, delegate, success_callback, |
(...skipping 16 matching lines...) Expand all Loading... | |
1004 } | 1003 } |
1005 | 1004 |
1006 void BluetoothAdapterChromeOS::OnRegisterProfileError( | 1005 void BluetoothAdapterChromeOS::OnRegisterProfileError( |
1007 const BluetoothUUID& uuid, | 1006 const BluetoothUUID& uuid, |
1008 const ErrorCompletionCallback& error_callback, | 1007 const ErrorCompletionCallback& error_callback, |
1009 const std::string& error_name, | 1008 const std::string& error_name, |
1010 const std::string& error_message) { | 1009 const std::string& error_message) { |
1011 LOG(WARNING) << object_path_.value() | 1010 LOG(WARNING) << object_path_.value() |
1012 << ": Failed to register profile: " << error_name << ": " | 1011 << ": Failed to register profile: " << error_name << ": " |
1013 << error_message; | 1012 << error_message; |
1013 delete profiles_[uuid]; | |
Ilya Sherman
2015/02/19 20:37:58
Are you sure it's appropriate to do this *before*
Marie Janssen
2015/02/20 22:53:46
Sockets don't get this pointer until the RegisterP
| |
1014 error_callback.Run(error_message); | 1014 error_callback.Run(error_message); |
1015 ReleaseProfile(uuid); | |
1016 } | 1015 } |
1017 | 1016 |
1018 void BluetoothAdapterChromeOS::OnSetDiscoverable( | 1017 void BluetoothAdapterChromeOS::OnSetDiscoverable( |
1019 const base::Closure& callback, | 1018 const base::Closure& callback, |
1020 const ErrorCallback& error_callback, | 1019 const ErrorCallback& error_callback, |
1021 bool success) { | 1020 bool success) { |
1022 DCHECK(IsPresent()); | 1021 DCHECK(IsPresent()); |
1023 // Set the discoverable_timeout property to zero so the adapter remains | 1022 // Set the discoverable_timeout property to zero so the adapter remains |
1024 // discoverable forever. | 1023 // discoverable forever. |
1025 DBusThreadManager::Get()->GetBluetoothAdapterClient()-> | 1024 DBusThreadManager::Get()->GetBluetoothAdapterClient()-> |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1217 | 1216 |
1218 // If the queued request resulted in a pending call, then let it | 1217 // If the queued request resulted in a pending call, then let it |
1219 // asynchonously process the remaining queued requests once the pending | 1218 // asynchonously process the remaining queued requests once the pending |
1220 // call returns. | 1219 // call returns. |
1221 if (discovery_request_pending_) | 1220 if (discovery_request_pending_) |
1222 return; | 1221 return; |
1223 } | 1222 } |
1224 } | 1223 } |
1225 | 1224 |
1226 } // namespace chromeos | 1225 } // namespace chromeos |
OLD | NEW |