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