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 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 VLOG(1) << "Failed to register audio sink, adapter not present"; | 807 VLOG(1) << "Failed to register audio sink, adapter not present"; |
808 error_callback.Run(BluetoothAudioSink::ERROR_INVALID_ADAPTER); | 808 error_callback.Run(BluetoothAudioSink::ERROR_INVALID_ADAPTER); |
809 return; | 809 return; |
810 } | 810 } |
811 DCHECK(audio_sink.get()); | 811 DCHECK(audio_sink.get()); |
812 callback.Run(audio_sink); | 812 callback.Run(audio_sink); |
813 } | 813 } |
814 | 814 |
815 void BluetoothAdapterBlueZ::CreateServiceRecord( | 815 void BluetoothAdapterBlueZ::CreateServiceRecord( |
816 const BluetoothServiceRecordBlueZ& record, | 816 const BluetoothServiceRecordBlueZ& record, |
817 const base::Closure& callback, | 817 const ServiceRecordCallback& callback, |
818 const ServiceRecordErrorCallback& error_callback) { | 818 const ServiceRecordErrorCallback& error_callback) { |
819 // TODO(rkc): Implement this. | 819 bluez::BluezDBusManager::Get() |
820 callback.Run(); | 820 ->GetBluetoothAdapterClient() |
| 821 ->CreateServiceRecord( |
| 822 object_path_, record, callback, |
| 823 base::Bind(&BluetoothAdapterBlueZ::ServiceRecordErrorConnector, |
| 824 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
821 } | 825 } |
822 | 826 |
823 void BluetoothAdapterBlueZ::RemoveServiceRecord( | 827 void BluetoothAdapterBlueZ::RemoveServiceRecord( |
824 const device::BluetoothUUID& uuid, | 828 uint32_t handle, |
825 const base::Closure& callback, | 829 const base::Closure& callback, |
826 const ServiceRecordErrorCallback& error_callback) { | 830 const ServiceRecordErrorCallback& error_callback) { |
827 // TODO(rkc): Implement this. | 831 bluez::BluezDBusManager::Get() |
828 callback.Run(); | 832 ->GetBluetoothAdapterClient() |
| 833 ->RemoveServiceRecord( |
| 834 object_path_, handle, callback, |
| 835 base::Bind(&BluetoothAdapterBlueZ::ServiceRecordErrorConnector, |
| 836 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
829 } | 837 } |
830 | 838 |
831 BluetoothDeviceBlueZ* BluetoothAdapterBlueZ::GetDeviceWithPath( | 839 BluetoothDeviceBlueZ* BluetoothAdapterBlueZ::GetDeviceWithPath( |
832 const dbus::ObjectPath& object_path) { | 840 const dbus::ObjectPath& object_path) { |
833 if (!IsPresent()) | 841 if (!IsPresent()) |
834 return nullptr; | 842 return nullptr; |
835 | 843 |
836 for (DevicesMap::const_iterator iter = devices_.begin(); | 844 for (DevicesMap::const_iterator iter = devices_.begin(); |
837 iter != devices_.end(); ++iter) { | 845 iter != devices_.end(); ++iter) { |
838 BluetoothDeviceBlueZ* device_bluez = | 846 BluetoothDeviceBlueZ* device_bluez = |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1641 } | 1649 } |
1642 | 1650 |
1643 void BluetoothAdapterBlueZ::RegisterApplicationOnError( | 1651 void BluetoothAdapterBlueZ::RegisterApplicationOnError( |
1644 const base::Closure& callback, | 1652 const base::Closure& callback, |
1645 const device::BluetoothGattService::ErrorCallback& error_callback, | 1653 const device::BluetoothGattService::ErrorCallback& error_callback, |
1646 const std::string& /* error_name */, | 1654 const std::string& /* error_name */, |
1647 const std::string& /* error_message */) { | 1655 const std::string& /* error_message */) { |
1648 RegisterApplication(callback, error_callback); | 1656 RegisterApplication(callback, error_callback); |
1649 } | 1657 } |
1650 | 1658 |
| 1659 void BluetoothAdapterBlueZ::ServiceRecordErrorConnector( |
| 1660 const ServiceRecordErrorCallback& error_callback, |
| 1661 const std::string& error_name, |
| 1662 const std::string& error_message) { |
| 1663 VLOG(1) << "Creating service record failed: error: " << error_name << " - " |
| 1664 << error_message; |
| 1665 |
| 1666 BluetoothServiceRecordBlueZ::ErrorCode code = |
| 1667 BluetoothServiceRecordBlueZ::ErrorCode::UNKNOWN; |
| 1668 if (error_name == bluetooth_adapter::kErrorInvalidArguments) { |
| 1669 code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_INVALID_ARGUMENTS; |
| 1670 } else if (error_name == bluetooth_adapter::kErrorDoesNotExist) { |
| 1671 code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_RECORD_DOES_NOT_EXIST; |
| 1672 } else if (error_name == bluetooth_adapter::kErrorAlreadyExists) { |
| 1673 code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_RECORD_ALREADY_EXISTS; |
| 1674 } else if (error_name == bluetooth_adapter::kErrorNotReady) { |
| 1675 code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_ADAPTER_NOT_READY; |
| 1676 } |
| 1677 |
| 1678 error_callback.Run(code); |
| 1679 } |
| 1680 |
1651 } // namespace bluez | 1681 } // namespace bluez |
OLD | NEW |