X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fdevice%2Fbluetooth%2Fbluetooth_device_win.cc;h=59e11c4c318db42a0f08ae8d79d5841c7aeb87fc;hb=004985e17e624662a4c85c76a7654039dc83f028;hp=da016f7007d146c9b5b04c554d84a33306bd173d;hpb=2f108dbacb161091e42a3479f4e171339b7e7623;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/device/bluetooth/bluetooth_device_win.cc b/src/device/bluetooth/bluetooth_device_win.cc index da016f7..59e11c4 100644 --- a/src/device/bluetooth/bluetooth_device_win.cc +++ b/src/device/bluetooth/bluetooth_device_win.cc @@ -9,12 +9,15 @@ #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.h" #include "device/bluetooth/bluetooth_socket_win.h" #include "device/bluetooth/bluetooth_task_manager_win.h" +#include "device/bluetooth/bluetooth_uuid.h" namespace { @@ -25,8 +28,16 @@ const int kSdpBytesBufferSize = 1024; namespace device { BluetoothDeviceWin::BluetoothDeviceWin( - const BluetoothTaskManagerWin::DeviceState& state) - : BluetoothDevice() { + const BluetoothTaskManagerWin::DeviceState& state, + scoped_refptr ui_task_runner, + scoped_refptr 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) { name_ = state.name; address_ = state.address; bluetooth_class_ = state.bluetooth_class; @@ -59,6 +70,19 @@ void BluetoothDeviceWin::SetVisible(bool visible) { visible_ = visible; } +void BluetoothDeviceWin::AddObserver( + device::BluetoothDevice::Observer* observer) { + DCHECK(observer); + observers_.AddObserver(observer); +} + +void BluetoothDeviceWin::RemoveObserver( + device::BluetoothDevice::Observer* observer) { + DCHECK(observer); + observers_.RemoveObserver(observer); +} + + uint32 BluetoothDeviceWin::GetBluetoothClass() const { return bluetooth_class_; } @@ -88,6 +112,21 @@ uint16 BluetoothDeviceWin::GetDeviceID() const { return 0; } +int BluetoothDeviceWin::GetRSSI() const { + NOTIMPLEMENTED(); + return kUnknownPower; +} + +int BluetoothDeviceWin::GetCurrentHostTransmitPower() const { + NOTIMPLEMENTED(); + return kUnknownPower; +} + +int BluetoothDeviceWin::GetMaximumHostTransmitPower() const { + NOTIMPLEMENTED(); + return kUnknownPower; +} + bool BluetoothDeviceWin::IsPaired() const { return paired_; } @@ -160,32 +199,26 @@ void BluetoothDeviceWin::Forget(const ErrorCallback& error_callback) { NOTIMPLEMENTED(); } -void BluetoothDeviceWin::ConnectToService( - const std::string& service_uuid, - const SocketCallback& callback) { - 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 socket( - BluetoothSocketWin::CreateBluetoothSocket(**iter)); - if (socket.get() != NULL) { - callback.Run(socket); - return; - } - } - } -} - void BluetoothDeviceWin::ConnectToProfile( device::BluetoothProfile* profile, const base::Closure& callback, - const ErrorCallback& error_callback) { - if (static_cast(profile)->Connect(this)) - callback.Run(); - else - error_callback.Run(); + const ConnectToProfileErrorCallback& error_callback) { + DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); + static_cast(profile)->Connect(this, + ui_task_runner_, + socket_thread_, + net_log_, + net_log_source_, + callback, + error_callback); +} + +void BluetoothDeviceWin::ConnectToService( + const BluetoothUUID& uuid, + const ConnectToServiceCallback& callback, + const ConnectToServiceErrorCallback& error_callback) { + // TODO(keybuk): implement + NOTIMPLEMENTED(); } void BluetoothDeviceWin::SetOutOfBandPairingData( @@ -201,12 +234,18 @@ void BluetoothDeviceWin::ClearOutOfBandPairingData( NOTIMPLEMENTED(); } +void BluetoothDeviceWin::StartConnectionMonitor( + const base::Closure& callback, + const ErrorCallback& error_callback) { + NOTIMPLEMENTED(); +} + const BluetoothServiceRecord* BluetoothDeviceWin::GetServiceRecord( - const std::string& uuid) const { + const device::BluetoothUUID& uuid) const { for (ServiceRecordList::const_iterator iter = service_record_list_.begin(); iter != service_record_list_.end(); ++iter) { - if ((*iter)->uuid().compare(uuid) == 0) + if ((*iter)->uuid() == uuid) return *iter; } return NULL;