Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: device/bluetooth/bluez/bluetooth_device_bluez.cc

Issue 2102093003: Implement BluetoothDeviceBlueZ::GetServiceRecords. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_device_bluez.h" 5 #include "device/bluetooth/bluez/bluetooth_device_bluez.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 return; 547 return;
548 } 548 }
549 549
550 // TODO(armansito): Until there is a way to create a reference counted GATT 550 // TODO(armansito): Until there is a way to create a reference counted GATT
551 // connection in bluetoothd, simply do a regular connect. 551 // connection in bluetoothd, simply do a regular connect.
552 Connect(NULL, base::Bind(&BluetoothDeviceBlueZ::OnCreateGattConnection, 552 Connect(NULL, base::Bind(&BluetoothDeviceBlueZ::OnCreateGattConnection,
553 weak_ptr_factory_.GetWeakPtr(), callback), 553 weak_ptr_factory_.GetWeakPtr(), callback),
554 error_callback); 554 error_callback);
555 } 555 }
556 556
557 std::vector<BluetoothServiceRecordBlueZ*> 557 void BluetoothDeviceBlueZ::GetServiceRecords(
558 BluetoothDeviceBlueZ::GetServiceRecords() { 558 const GetServiceRecordsCallback& callback,
559 // TODO(rkc): Implement this. 559 const GetServiceRecordsErrorCallback& error_callback) {
560 return std::vector<BluetoothServiceRecordBlueZ*>(); 560 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetServiceRecords(
561 object_path_, callback,
562 base::Bind(&BluetoothDeviceBlueZ::OnGetServiceRecordsError,
563 weak_ptr_factory_.GetWeakPtr(), error_callback));
561 } 564 }
562 565
563 BluetoothPairingBlueZ* BluetoothDeviceBlueZ::BeginPairing( 566 BluetoothPairingBlueZ* BluetoothDeviceBlueZ::BeginPairing(
564 BluetoothDevice::PairingDelegate* pairing_delegate) { 567 BluetoothDevice::PairingDelegate* pairing_delegate) {
565 pairing_.reset(new BluetoothPairingBlueZ(this, pairing_delegate)); 568 pairing_.reset(new BluetoothPairingBlueZ(this, pairing_delegate));
566 return pairing_.get(); 569 return pairing_.get();
567 } 570 }
568 571
569 void BluetoothDeviceBlueZ::EndPairing() { 572 void BluetoothDeviceBlueZ::EndPairing() {
570 pairing_.reset(); 573 pairing_.reset();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 void BluetoothDeviceBlueZ::OnGetConnInfoError( 700 void BluetoothDeviceBlueZ::OnGetConnInfoError(
698 const ConnectionInfoCallback& callback, 701 const ConnectionInfoCallback& callback,
699 const std::string& error_name, 702 const std::string& error_name,
700 const std::string& error_message) { 703 const std::string& error_message) {
701 LOG(WARNING) << object_path_.value() 704 LOG(WARNING) << object_path_.value()
702 << ": Failed to get connection info: " << error_name << ": " 705 << ": Failed to get connection info: " << error_name << ": "
703 << error_message; 706 << error_message;
704 callback.Run(ConnectionInfo()); 707 callback.Run(ConnectionInfo());
705 } 708 }
706 709
710 void BluetoothDeviceBlueZ::OnGetServiceRecordsError(
711 const GetServiceRecordsErrorCallback& error_callback,
712 const std::string& error_name,
713 const std::string& error_message) {
714 VLOG(1) << object_path_.value()
715 << ": Failed to get service records: " << error_name << ": "
716 << error_message;
717 BluetoothServiceRecordBlueZ::ErrorCode code =
718 BluetoothServiceRecordBlueZ::ErrorCode::UNKNOWN;
719 if (error_name == bluetooth_device::kErrorNotConnected) {
720 code = BluetoothServiceRecordBlueZ::ErrorCode::ERROR_DEVICE_DISCONNECTED;
721 }
722 error_callback.Run(code);
723 }
724
707 void BluetoothDeviceBlueZ::ConnectInternal( 725 void BluetoothDeviceBlueZ::ConnectInternal(
708 bool after_pairing, 726 bool after_pairing,
709 const base::Closure& callback, 727 const base::Closure& callback,
710 const ConnectErrorCallback& error_callback) { 728 const ConnectErrorCallback& error_callback) {
711 VLOG(1) << object_path_.value() << ": Connecting"; 729 VLOG(1) << object_path_.value() << ": Connecting";
712 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Connect( 730 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Connect(
713 object_path_, 731 object_path_,
714 base::Bind(&BluetoothDeviceBlueZ::OnConnect, 732 base::Bind(&BluetoothDeviceBlueZ::OnConnect,
715 weak_ptr_factory_.GetWeakPtr(), after_pairing, callback), 733 weak_ptr_factory_.GetWeakPtr(), after_pairing, callback),
716 base::Bind(&BluetoothDeviceBlueZ::OnConnectError, 734 base::Bind(&BluetoothDeviceBlueZ::OnConnectError,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 void BluetoothDeviceBlueZ::OnForgetError(const ErrorCallback& error_callback, 887 void BluetoothDeviceBlueZ::OnForgetError(const ErrorCallback& error_callback,
870 const std::string& error_name, 888 const std::string& error_name,
871 const std::string& error_message) { 889 const std::string& error_message) {
872 LOG(WARNING) << object_path_.value() 890 LOG(WARNING) << object_path_.value()
873 << ": Failed to remove device: " << error_name << ": " 891 << ": Failed to remove device: " << error_name << ": "
874 << error_message; 892 << error_message;
875 error_callback.Run(); 893 error_callback.Run();
876 } 894 }
877 895
878 } // namespace bluez 896 } // namespace bluez
OLDNEW
« no previous file with comments | « device/bluetooth/bluez/bluetooth_device_bluez.h ('k') | device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698