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

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

Issue 267633003: Reimplement BluetoothSocketChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
11 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
13 #include "chromeos/dbus/bluetooth_adapter_client.h" 14 #include "chromeos/dbus/bluetooth_adapter_client.h"
14 #include "chromeos/dbus/bluetooth_device_client.h" 15 #include "chromeos/dbus/bluetooth_device_client.h"
15 #include "chromeos/dbus/bluetooth_gatt_service_client.h" 16 #include "chromeos/dbus/bluetooth_gatt_service_client.h"
16 #include "chromeos/dbus/bluetooth_input_client.h" 17 #include "chromeos/dbus/bluetooth_input_client.h"
17 #include "chromeos/dbus/dbus_thread_manager.h" 18 #include "chromeos/dbus/dbus_thread_manager.h"
18 #include "dbus/bus.h" 19 #include "dbus/bus.h"
19 #include "device/bluetooth/bluetooth_adapter_chromeos.h" 20 #include "device/bluetooth/bluetooth_adapter_chromeos.h"
20 #include "device/bluetooth/bluetooth_pairing_chromeos.h" 21 #include "device/bluetooth/bluetooth_pairing_chromeos.h"
21 #include "device/bluetooth/bluetooth_profile_chromeos.h" 22 #include "device/bluetooth/bluetooth_profile_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"
25 #include "device/bluetooth/bluetooth_socket_thread.h"
24 #include "third_party/cros_system_api/dbus/service_constants.h" 26 #include "third_party/cros_system_api/dbus/service_constants.h"
25 27
26 using device::BluetoothDevice; 28 using device::BluetoothDevice;
29 using device::BluetoothSocket;
27 30
28 namespace { 31 namespace {
29 32
30 // Histogram enumerations for pairing results. 33 // Histogram enumerations for pairing results.
31 enum UMAPairingResult { 34 enum UMAPairingResult {
32 UMA_PAIRING_RESULT_SUCCESS, 35 UMA_PAIRING_RESULT_SUCCESS,
33 UMA_PAIRING_RESULT_INPROGRESS, 36 UMA_PAIRING_RESULT_INPROGRESS,
34 UMA_PAIRING_RESULT_FAILED, 37 UMA_PAIRING_RESULT_FAILED,
35 UMA_PAIRING_RESULT_AUTH_FAILED, 38 UMA_PAIRING_RESULT_AUTH_FAILED,
36 UMA_PAIRING_RESULT_AUTH_CANCELED, 39 UMA_PAIRING_RESULT_AUTH_CANCELED,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 pairing_result, 112 pairing_result,
110 UMA_PAIRING_RESULT_COUNT); 113 UMA_PAIRING_RESULT_COUNT);
111 } 114 }
112 115
113 } // namespace 116 } // namespace
114 117
115 namespace chromeos { 118 namespace chromeos {
116 119
117 BluetoothDeviceChromeOS::BluetoothDeviceChromeOS( 120 BluetoothDeviceChromeOS::BluetoothDeviceChromeOS(
118 BluetoothAdapterChromeOS* adapter, 121 BluetoothAdapterChromeOS* adapter,
119 const dbus::ObjectPath& object_path) 122 const dbus::ObjectPath& object_path,
123 scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
124 scoped_refptr<device::BluetoothSocketThread> socket_thread)
120 : adapter_(adapter), 125 : adapter_(adapter),
121 object_path_(object_path), 126 object_path_(object_path),
122 num_connecting_calls_(0), 127 num_connecting_calls_(0),
128 ui_task_runner_(ui_task_runner),
129 socket_thread_(socket_thread),
123 weak_ptr_factory_(this) { 130 weak_ptr_factory_(this) {
124 DBusThreadManager::Get()->GetBluetoothGattServiceClient()->AddObserver(this); 131 DBusThreadManager::Get()->GetBluetoothGattServiceClient()->AddObserver(this);
125 132
126 // Add all known GATT services. 133 // Add all known GATT services.
127 const std::vector<dbus::ObjectPath> gatt_services = 134 const std::vector<dbus::ObjectPath> gatt_services =
128 DBusThreadManager::Get()->GetBluetoothGattServiceClient()->GetServices(); 135 DBusThreadManager::Get()->GetBluetoothGattServiceClient()->GetServices();
129 for (std::vector<dbus::ObjectPath>::const_iterator it = gatt_services.begin(); 136 for (std::vector<dbus::ObjectPath>::const_iterator it = gatt_services.begin();
130 it != gatt_services.end(); ++it) { 137 it != gatt_services.end(); ++it) {
131 GattServiceAdded(*it); 138 GattServiceAdded(*it);
132 } 139 }
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 const std::string& error_message) { 669 const std::string& error_message) {
663 BluetoothProfileChromeOS* profile_chromeos = 670 BluetoothProfileChromeOS* profile_chromeos =
664 static_cast<BluetoothProfileChromeOS*>(profile); 671 static_cast<BluetoothProfileChromeOS*>(profile);
665 VLOG(1) << object_path_.value() << ": Profile connection failed: " 672 VLOG(1) << object_path_.value() << ": Profile connection failed: "
666 << profile_chromeos->uuid().canonical_value() << ": " 673 << profile_chromeos->uuid().canonical_value() << ": "
667 << error_name << ": " << error_message; 674 << error_name << ": " << error_message;
668 error_callback.Run(error_message); 675 error_callback.Run(error_message);
669 } 676 }
670 677
671 } // namespace chromeos 678 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698