| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "device/bluetooth/bluetooth_socket_win.h" | 5 #include "device/bluetooth/bluetooth_socket_win.h" |
| 6 | 6 |
| 7 #include <objbase.h> | 7 #include <objbase.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 << "winsock err=" << WSAGetLastError(); | 256 << "winsock err=" << WSAGetLastError(); |
| 257 PostErrorCompletion(error_callback, kFailedToCreateSocket); | 257 PostErrorCompletion(error_callback, kFailedToCreateSocket); |
| 258 return; | 258 return; |
| 259 } | 259 } |
| 260 | 260 |
| 261 // Note that |socket_fd| belongs to a non-TCP address family (i.e. AF_BTH), | 261 // Note that |socket_fd| belongs to a non-TCP address family (i.e. AF_BTH), |
| 262 // TCPSocket methods that involve address could not be called. So bind() | 262 // TCPSocket methods that involve address could not be called. So bind() |
| 263 // is called on |socket_fd| directly. | 263 // is called on |socket_fd| directly. |
| 264 std::unique_ptr<net::TCPSocket> scoped_socket( | 264 std::unique_ptr<net::TCPSocket> scoped_socket( |
| 265 new net::TCPSocket(NULL, NULL, net::NetLogSource())); | 265 new net::TCPSocket(NULL, NULL, net::NetLogSource())); |
| 266 scoped_socket->AdoptListenSocket(socket_fd); | 266 scoped_socket->AdoptUnconnectedSocket(socket_fd); |
| 267 | 267 |
| 268 SOCKADDR_BTH sa; | 268 SOCKADDR_BTH sa; |
| 269 struct sockaddr* sock_addr = reinterpret_cast<struct sockaddr*>(&sa); | 269 struct sockaddr* sock_addr = reinterpret_cast<struct sockaddr*>(&sa); |
| 270 int sock_addr_len = sizeof(sa); | 270 int sock_addr_len = sizeof(sa); |
| 271 ZeroMemory(&sa, sock_addr_len); | 271 ZeroMemory(&sa, sock_addr_len); |
| 272 sa.addressFamily = AF_BTH; | 272 sa.addressFamily = AF_BTH; |
| 273 sa.port = rfcomm_channel ? rfcomm_channel : BT_PORT_ANY; | 273 sa.port = rfcomm_channel ? rfcomm_channel : BT_PORT_ANY; |
| 274 if (bind(socket_fd, sock_addr, sock_addr_len) < 0) { | 274 if (bind(socket_fd, sock_addr, sock_addr_len) < 0) { |
| 275 LOG(WARNING) << "Failed to start service: create socket, " | 275 LOG(WARNING) << "Failed to start service: create socket, " |
| 276 << "winsock err=" << WSAGetLastError(); | 276 << "winsock err=" << WSAGetLastError(); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 return; | 389 return; |
| 390 } | 390 } |
| 391 | 391 |
| 392 scoped_refptr<BluetoothSocketWin> peer_socket = | 392 scoped_refptr<BluetoothSocketWin> peer_socket = |
| 393 CreateBluetoothSocket(ui_task_runner(), socket_thread()); | 393 CreateBluetoothSocket(ui_task_runner(), socket_thread()); |
| 394 peer_socket->SetTCPSocket(std::move(accept_socket)); | 394 peer_socket->SetTCPSocket(std::move(accept_socket)); |
| 395 success_callback.Run(peer_device, peer_socket); | 395 success_callback.Run(peer_device, peer_socket); |
| 396 } | 396 } |
| 397 | 397 |
| 398 } // namespace device | 398 } // namespace device |
| OLD | NEW |