| Index: trunk/src/device/bluetooth/bluetooth_device_win.cc
|
| ===================================================================
|
| --- trunk/src/device/bluetooth/bluetooth_device_win.cc (revision 262179)
|
| +++ trunk/src/device/bluetooth/bluetooth_device_win.cc (working copy)
|
| @@ -9,12 +9,10 @@
|
| #include "base/basictypes.h"
|
| #include "base/logging.h"
|
| #include "base/memory/scoped_vector.h"
|
| -#include "base/sequenced_task_runner.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h"
|
| #include "device/bluetooth/bluetooth_profile_win.h"
|
| #include "device/bluetooth/bluetooth_service_record_win.h"
|
| -#include "device/bluetooth/bluetooth_socket_thread_win.h"
|
| #include "device/bluetooth/bluetooth_socket_win.h"
|
| #include "device/bluetooth/bluetooth_task_manager_win.h"
|
|
|
| @@ -27,16 +25,8 @@
|
| namespace device {
|
|
|
| BluetoothDeviceWin::BluetoothDeviceWin(
|
| - const BluetoothTaskManagerWin::DeviceState& state,
|
| - scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
|
| - scoped_refptr<BluetoothSocketThreadWin> socket_thread,
|
| - net::NetLog* net_log,
|
| - const net::NetLog::Source& net_log_source)
|
| - : BluetoothDevice(),
|
| - ui_task_runner_(ui_task_runner),
|
| - socket_thread_(socket_thread),
|
| - net_log_(net_log),
|
| - net_log_source_(net_log_source) {
|
| + const BluetoothTaskManagerWin::DeviceState& state)
|
| + : BluetoothDevice() {
|
| name_ = state.name;
|
| address_ = state.address;
|
| bluetooth_class_ = state.bluetooth_class;
|
| @@ -173,21 +163,29 @@
|
| void BluetoothDeviceWin::ConnectToService(
|
| const device::BluetoothUUID& service_uuid,
|
| const SocketCallback& callback) {
|
| - NOTIMPLEMENTED();
|
| + for (ServiceRecordList::const_iterator iter = service_record_list_.begin();
|
| + iter != service_record_list_.end();
|
| + ++iter) {
|
| + if ((*iter)->uuid() == service_uuid) {
|
| + // If multiple service records are found, use the first one that works.
|
| + scoped_refptr<BluetoothSocket> socket(
|
| + BluetoothSocketWin::CreateBluetoothSocket(**iter));
|
| + if (socket.get() != NULL) {
|
| + callback.Run(socket);
|
| + return;
|
| + }
|
| + }
|
| + }
|
| }
|
|
|
| void BluetoothDeviceWin::ConnectToProfile(
|
| device::BluetoothProfile* profile,
|
| const base::Closure& callback,
|
| - const ConnectToProfileErrorCallback& error_callback) {
|
| - DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
|
| - static_cast<BluetoothProfileWin*>(profile)->Connect(this,
|
| - ui_task_runner_,
|
| - socket_thread_,
|
| - net_log_,
|
| - net_log_source_,
|
| - callback,
|
| - error_callback);
|
| + const ErrorCallback& error_callback) {
|
| + if (static_cast<BluetoothProfileWin*>(profile)->Connect(this))
|
| + callback.Run();
|
| + else
|
| + error_callback.Run();
|
| }
|
|
|
| void BluetoothDeviceWin::SetOutOfBandPairingData(
|
|
|