| 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 <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 const char kInvalidRfcommPort[] = "Invalid RFCCOMM port."; | 32 const char kInvalidRfcommPort[] = "Invalid RFCCOMM port."; |
| 33 const char kFailedToCreateSocket[] = "Failed to create socket."; | 33 const char kFailedToCreateSocket[] = "Failed to create socket."; |
| 34 const char kFailedToBindSocket[] = "Failed to bind socket."; | 34 const char kFailedToBindSocket[] = "Failed to bind socket."; |
| 35 const char kFailedToListenOnSocket[] = "Failed to listen on socket."; | 35 const char kFailedToListenOnSocket[] = "Failed to listen on socket."; |
| 36 const char kFailedToGetSockNameForSocket[] = "Failed to getsockname."; | 36 const char kFailedToGetSockNameForSocket[] = "Failed to getsockname."; |
| 37 const char kFailedToAccept[] = "Failed to accept."; | 37 const char kFailedToAccept[] = "Failed to accept."; |
| 38 const char kInvalidUUID[] = "Invalid UUID"; | 38 const char kInvalidUUID[] = "Invalid UUID"; |
| 39 const char kWsaSetServiceError[] = "WSASetService error."; | 39 const char kWsaSetServiceError[] = "WSASetService error."; |
| 40 | 40 |
| 41 std::string IPEndPointToBluetoothAddress(const net::IPEndPoint& end_point) { | 41 std::string IPEndPointToBluetoothAddress(const net::IPEndPoint& end_point) { |
| 42 if (end_point.address().size() != net::kBluetoothAddressSize) | 42 if (end_point.address_number().size() != net::kBluetoothAddressSize) |
| 43 return std::string(); | 43 return std::string(); |
| 44 // The address is copied from BTH_ADDR field of SOCKADDR_BTH, which is a | 44 // The address is copied from BTH_ADDR field of SOCKADDR_BTH, which is a |
| 45 // 64-bit ULONGLONG that stores Bluetooth address in little-endian. Print in | 45 // 64-bit ULONGLONG that stores Bluetooth address in little-endian. Print in |
| 46 // reverse order to preserve the correct ordering. | 46 // reverse order to preserve the correct ordering. |
| 47 return base::StringPrintf("%02X:%02X:%02X:%02X:%02X:%02X", | 47 return base::StringPrintf( |
| 48 end_point.address()[5], | 48 "%02X:%02X:%02X:%02X:%02X:%02X", end_point.address_number()[5], |
| 49 end_point.address()[4], | 49 end_point.address_number()[4], end_point.address_number()[3], |
| 50 end_point.address()[3], | 50 end_point.address_number()[2], end_point.address_number()[1], |
| 51 end_point.address()[2], | 51 end_point.address_number()[0]); |
| 52 end_point.address()[1], | |
| 53 end_point.address()[0]); | |
| 54 } | 52 } |
| 55 | 53 |
| 56 } // namespace | 54 } // namespace |
| 57 | 55 |
| 58 namespace device { | 56 namespace device { |
| 59 | 57 |
| 60 struct BluetoothSocketWin::ServiceRegData { | 58 struct BluetoothSocketWin::ServiceRegData { |
| 61 ServiceRegData() { | 59 ServiceRegData() { |
| 62 ZeroMemory(&address, sizeof(address)); | 60 ZeroMemory(&address, sizeof(address)); |
| 63 ZeroMemory(&address_info, sizeof(address_info)); | 61 ZeroMemory(&address_info, sizeof(address_info)); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 return; | 386 return; |
| 389 } | 387 } |
| 390 | 388 |
| 391 scoped_refptr<BluetoothSocketWin> peer_socket = | 389 scoped_refptr<BluetoothSocketWin> peer_socket = |
| 392 CreateBluetoothSocket(ui_task_runner(), socket_thread()); | 390 CreateBluetoothSocket(ui_task_runner(), socket_thread()); |
| 393 peer_socket->SetTCPSocket(accept_socket.Pass()); | 391 peer_socket->SetTCPSocket(accept_socket.Pass()); |
| 394 success_callback.Run(peer_device, peer_socket); | 392 success_callback.Run(peer_device, peer_socket); |
| 395 } | 393 } |
| 396 | 394 |
| 397 } // namespace device | 395 } // namespace device |
| OLD | NEW |