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

Unified Diff: device/bluetooth/bluetooth_profile_chromeos.cc

Issue 267633003: Reimplement BluetoothSocketChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments #1 Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_profile_chromeos.cc
diff --git a/device/bluetooth/bluetooth_profile_chromeos.cc b/device/bluetooth/bluetooth_profile_chromeos.cc
index 2b6e91f9b40b9f33459c5143c7cdacc0db2a378e..5543bdc329997a8e7c98a08faebb3ab07f7182dd 100644
--- a/device/bluetooth/bluetooth_profile_chromeos.cc
+++ b/device/bluetooth/bluetooth_profile_chromeos.cc
@@ -30,6 +30,7 @@
#include "device/bluetooth/bluetooth_profile.h"
#include "device/bluetooth/bluetooth_socket.h"
#include "device/bluetooth/bluetooth_socket_chromeos.h"
+#include "device/bluetooth/bluetooth_socket_thread.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
using device::BluetoothAdapter;
@@ -54,8 +55,12 @@ scoped_ptr<dbus::FileDescriptor> CheckValidity(
namespace chromeos {
-BluetoothProfileChromeOS::BluetoothProfileChromeOS()
- : weak_ptr_factory_(this) {
+BluetoothProfileChromeOS::BluetoothProfileChromeOS(
+ scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
+ scoped_refptr<device::BluetoothSocketThread> socket_thread)
+ : ui_task_runner_(ui_task_runner),
+ socket_thread_(socket_thread),
+ weak_ptr_factory_(this) {
}
BluetoothProfileChromeOS::~BluetoothProfileChromeOS() {
@@ -281,16 +286,44 @@ void BluetoothProfileChromeOS::OnCheckValidity(
return;
}
- callback.Run(SUCCESS);
+ scoped_refptr<BluetoothSocketChromeOS> socket =
+ BluetoothSocketChromeOS::CreateBluetoothSocket(
+ ui_task_runner_,
+ socket_thread_,
+ NULL,
+ net::NetLog::Source());
+ socket->Connect(fd.Pass(),
+ base::Bind(&BluetoothProfileChromeOS::OnConnect,
+ weak_ptr_factory_.GetWeakPtr(),
+ device_path,
+ socket,
+ callback),
+ base::Bind(&BluetoothProfileChromeOS::OnConnectError,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback));
+}
+
+void BluetoothProfileChromeOS::OnConnect(
+ const dbus::ObjectPath& device_path,
+ scoped_refptr<BluetoothSocketChromeOS> socket,
+ const ConfirmationCallback& callback) {
+ VLOG(1) << object_path_.value() << ": Profile connection complete";
rpaquay 2014/05/01 15:23:58 |callback| is not used here, shouldn't there be a
keybuk 2014/05/01 18:07:16 Done.
BluetoothDeviceChromeOS* device =
static_cast<BluetoothAdapterChromeOS*>(adapter_.get())->
GetDeviceWithPath(device_path);
DCHECK(device);
- scoped_refptr<BluetoothSocket> socket((
- BluetoothSocketChromeOS::Create(fd.get())));
connection_callback_.Run(device, socket);
}
+void BluetoothProfileChromeOS::OnConnectError(
+ const ConfirmationCallback& callback,
+ const std::string& error_message) {
+ VLOG(1) << object_path_.value() << ": Profile connection failed: "
+ << error_message;
+
+ callback.Run(REJECTED);
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698