scoped_refptr<BluetoothSocketWin>
BluetoothSocketWin::CreateBluetoothSocket(
scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
- scoped_refptr<device::BluetoothSocketThread> socket_thread,
- net::NetLog* net_log,
- const net::NetLog::Source& source) {
+ scoped_refptr<device::BluetoothSocketThread> socket_thread) {
DCHECK(ui_task_runner->RunsTasksOnCurrentThread());
return make_scoped_refptr(
- new BluetoothSocketWin(ui_task_runner, socket_thread, net_log, source));
+ new BluetoothSocketWin(ui_task_runner, socket_thread));
}
BluetoothSocketWin::BluetoothSocketWin(
scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
- scoped_refptr<BluetoothSocketThread> socket_thread,
- net::NetLog* net_log,
- const net::NetLog::Source& source)
- : BluetoothSocketNet(ui_task_runner, socket_thread, net_log, source),
+ scoped_refptr<BluetoothSocketThread> socket_thread)
+ : BluetoothSocketNet(ui_task_runner, socket_thread),
supports_rfcomm_(false),
- rfcomm_channel_(-1),
+ rfcomm_channel_(0xFF),
bth_addr_(BTH_ADDR_NULL) {
}
return;
}
- device_address_ = service_record_win->address();
+ device_address_ = service_record_win->device_address();
if (service_record_win->SupportsRfcomm()) {
supports_rfcomm_ = true;
rfcomm_channel_ = service_record_win->rfcomm_channel();
- bth_addr_ = service_record_win->bth_addr();
+ bth_addr_ = service_record_win->device_bth_addr();
}
socket_thread()->task_runner()->PostTask(
void BluetoothSocketWin::Listen(scoped_refptr<BluetoothAdapter> adapter,
const BluetoothUUID& uuid,
- int rfcomm_channel,
+ const BluetoothAdapter::ServiceOptions& options,
const base::Closure& success_callback,
const ErrorCompletionCallback& error_callback) {
DCHECK(ui_task_runner()->RunsTasksOnCurrentThread());
adapter_ = adapter;
+ int rfcomm_channel = options.channel ? *options.channel : 0;
+ // TODO(xiyuan): Use |options.name|.
socket_thread()->task_runner()->PostTask(
FROM_HERE,
base::Bind(&BluetoothSocketWin::DoListen,
return;
}
- ResetTCPSocket();
+ scoped_ptr<net::TCPSocket> scoped_socket(
+ new net::TCPSocket(NULL, net::NetLog::Source()));
net::EnsureWinsockInit();
SOCKET socket_fd = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);
SOCKADDR_BTH sa;
// Note: We don't have a meaningful |IPEndPoint|, but that is ok since the
// TCPSocket implementation does not actually require one.
int net_result =
- tcp_socket()->AdoptConnectedSocket(socket_fd, net::IPEndPoint());
+ scoped_socket->AdoptConnectedSocket(socket_fd, net::IPEndPoint());
if (net_result != net::OK) {
error_callback.Run("Error connecting to socket: " +
- std::string(net::ErrorToString(net_result)));
+ net::ErrorToString(net_result));
closesocket(socket_fd);
return;
}
+ SetTCPSocket(scoped_socket.Pass());
success_callback.Run();
}
return;
}
- scoped_refptr<BluetoothSocketWin> peer_socket = CreateBluetoothSocket(
- ui_task_runner(),
- socket_thread(),
- net_log(),
- source());
+ scoped_refptr<BluetoothSocketWin> peer_socket =
+ CreateBluetoothSocket(ui_task_runner(), socket_thread());
peer_socket->SetTCPSocket(accept_socket.Pass());
success_callback.Run(peer_device, peer_socket);
}