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

Side by Side Diff: device/bluetooth/bluetooth_device_chromeos.cc

Issue 333983003: device/bluetooth: Implement BluetoothGattConnection on Chrome OS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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/bluetooth_device_chromeos.h" 5 #include "device/bluetooth/bluetooth_device_chromeos.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "chromeos/dbus/bluetooth_adapter_client.h" 14 #include "chromeos/dbus/bluetooth_adapter_client.h"
15 #include "chromeos/dbus/bluetooth_device_client.h" 15 #include "chromeos/dbus/bluetooth_device_client.h"
16 #include "chromeos/dbus/bluetooth_gatt_service_client.h" 16 #include "chromeos/dbus/bluetooth_gatt_service_client.h"
17 #include "chromeos/dbus/bluetooth_input_client.h" 17 #include "chromeos/dbus/bluetooth_input_client.h"
18 #include "chromeos/dbus/dbus_thread_manager.h" 18 #include "chromeos/dbus/dbus_thread_manager.h"
19 #include "dbus/bus.h" 19 #include "dbus/bus.h"
20 #include "device/bluetooth/bluetooth_adapter_chromeos.h" 20 #include "device/bluetooth/bluetooth_adapter_chromeos.h"
21 #include "device/bluetooth/bluetooth_gatt_connection_chromeos.h"
21 #include "device/bluetooth/bluetooth_pairing_chromeos.h" 22 #include "device/bluetooth/bluetooth_pairing_chromeos.h"
22 #include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h" 23 #include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h"
23 #include "device/bluetooth/bluetooth_socket.h" 24 #include "device/bluetooth/bluetooth_socket.h"
24 #include "device/bluetooth/bluetooth_socket_chromeos.h" 25 #include "device/bluetooth/bluetooth_socket_chromeos.h"
25 #include "device/bluetooth/bluetooth_socket_thread.h" 26 #include "device/bluetooth/bluetooth_socket_thread.h"
26 #include "device/bluetooth/bluetooth_uuid.h" 27 #include "device/bluetooth/bluetooth_uuid.h"
27 #include "third_party/cros_system_api/dbus/service_constants.h" 28 #include "third_party/cros_system_api/dbus/service_constants.h"
28 29
29 using device::BluetoothDevice; 30 using device::BluetoothDevice;
30 using device::BluetoothSocket; 31 using device::BluetoothSocket;
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 NULL, 447 NULL,
447 net::NetLog::Source()); 448 net::NetLog::Source());
448 socket->Connect(this, uuid, 449 socket->Connect(this, uuid,
449 base::Bind(callback, socket), 450 base::Bind(callback, socket),
450 error_callback); 451 error_callback);
451 } 452 }
452 453
453 void BluetoothDeviceChromeOS::CreateGattConnection( 454 void BluetoothDeviceChromeOS::CreateGattConnection(
454 const GattConnectionCallback& callback, 455 const GattConnectionCallback& callback,
455 const ConnectErrorCallback& error_callback) { 456 const ConnectErrorCallback& error_callback) {
456 // TODO(armansito): Implement. 457 // TODO(armansito): Until there is a way to create a reference counted GATT
457 error_callback.Run(ERROR_UNSUPPORTED_DEVICE); 458 // connection in bluetoothd, simply do a regular connect.
459 Connect(NULL,
460 base::Bind(&BluetoothDeviceChromeOS::OnCreateGattConnection,
461 weak_ptr_factory_.GetWeakPtr(),
462 callback),
463 error_callback);
458 } 464 }
459 465
460 void BluetoothDeviceChromeOS::StartConnectionMonitor( 466 void BluetoothDeviceChromeOS::StartConnectionMonitor(
461 const base::Closure& callback, 467 const base::Closure& callback,
462 const ErrorCallback& error_callback) { 468 const ErrorCallback& error_callback) {
463 DBusThreadManager::Get()->GetBluetoothDeviceClient()->StartConnectionMonitor( 469 DBusThreadManager::Get()->GetBluetoothDeviceClient()->StartConnectionMonitor(
464 object_path_, 470 object_path_,
465 base::Bind(&BluetoothDeviceChromeOS::OnStartConnectionMonitor, 471 base::Bind(&BluetoothDeviceChromeOS::OnStartConnectionMonitor,
466 weak_ptr_factory_.GetWeakPtr(), 472 weak_ptr_factory_.GetWeakPtr(),
467 callback), 473 callback),
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 SetTrusted(); 567 SetTrusted();
562 568
563 if (after_pairing) 569 if (after_pairing)
564 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingResult", 570 UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingResult",
565 UMA_PAIRING_RESULT_SUCCESS, 571 UMA_PAIRING_RESULT_SUCCESS,
566 UMA_PAIRING_RESULT_COUNT); 572 UMA_PAIRING_RESULT_COUNT);
567 573
568 callback.Run(); 574 callback.Run();
569 } 575 }
570 576
577 void BluetoothDeviceChromeOS::OnCreateGattConnection(
578 const GattConnectionCallback& callback) {
579 scoped_ptr<device::BluetoothGattConnection> conn(
580 new BluetoothGattConnectionChromeOS(
581 adapter_, GetAddress(), object_path_));
582 callback.Run(conn.Pass());
583 }
584
571 void BluetoothDeviceChromeOS::OnConnectError( 585 void BluetoothDeviceChromeOS::OnConnectError(
572 bool after_pairing, 586 bool after_pairing,
573 const ConnectErrorCallback& error_callback, 587 const ConnectErrorCallback& error_callback,
574 const std::string& error_name, 588 const std::string& error_name,
575 const std::string& error_message) { 589 const std::string& error_message) {
576 if (--num_connecting_calls_ == 0) 590 if (--num_connecting_calls_ == 0)
577 adapter_->NotifyDeviceChanged(this); 591 adapter_->NotifyDeviceChanged(this);
578 592
579 DCHECK(num_connecting_calls_ >= 0); 593 DCHECK(num_connecting_calls_ >= 0);
580 LOG(WARNING) << object_path_.value() << ": Failed to connect device: " 594 LOG(WARNING) << object_path_.value() << ": Failed to connect device: "
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 void BluetoothDeviceChromeOS::OnForgetError( 713 void BluetoothDeviceChromeOS::OnForgetError(
700 const ErrorCallback& error_callback, 714 const ErrorCallback& error_callback,
701 const std::string& error_name, 715 const std::string& error_name,
702 const std::string& error_message) { 716 const std::string& error_message) {
703 LOG(WARNING) << object_path_.value() << ": Failed to remove device: " 717 LOG(WARNING) << object_path_.value() << ": Failed to remove device: "
704 << error_name << ": " << error_message; 718 << error_name << ": " << error_message;
705 error_callback.Run(); 719 error_callback.Run();
706 } 720 }
707 721
708 } // namespace chromeos 722 } // namespace chromeos
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_chromeos.h ('k') | device/bluetooth/bluetooth_gatt_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698