#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 {
namespace device {
BluetoothDeviceWin::BluetoothDeviceWin(
- const BluetoothTaskManagerWin::DeviceState& state)
- : BluetoothDevice() {
+ const BluetoothTaskManagerWin::DeviceState& state,
+ scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
+ scoped_refptr<BluetoothSocketThread> 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;
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_;
}
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_;
}
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<BluetoothSocket> 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<BluetoothProfileWin*>(profile)->Connect(this))
- callback.Run();
- else
- error_callback.Run();
+ 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);
+}
+
+void BluetoothDeviceWin::ConnectToService(
+ const BluetoothUUID& uuid,
+ const ConnectToServiceCallback& callback,
+ const ConnectToServiceErrorCallback& error_callback) {
+ // TODO(keybuk): implement
+ NOTIMPLEMENTED();
}
void BluetoothDeviceWin::SetOutOfBandPairingData(
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;