Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: device/bluetooth/bluetooth_socket_win.cc

Issue 1752233002: Convert Pass()→std::move() on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_win_unittest.cc ('k') | device/hid/hid_connection_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <utility>
10 11
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/sequenced_task_runner.h" 14 #include "base/sequenced_task_runner.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
15 #include "base/strings/sys_string_conversions.h" 16 #include "base/strings/sys_string_conversions.h"
16 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
17 #include "base/threading/thread_restrictions.h" 18 #include "base/threading/thread_restrictions.h"
18 #include "device/bluetooth/bluetooth_device_win.h" 19 #include "device/bluetooth/bluetooth_device_win.h"
19 #include "device/bluetooth/bluetooth_init_win.h" 20 #include "device/bluetooth/bluetooth_init_win.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // TCPSocket implementation does not actually require one. 219 // TCPSocket implementation does not actually require one.
219 int net_result = 220 int net_result =
220 scoped_socket->AdoptConnectedSocket(socket_fd, net::IPEndPoint()); 221 scoped_socket->AdoptConnectedSocket(socket_fd, net::IPEndPoint());
221 if (net_result != net::OK) { 222 if (net_result != net::OK) {
222 error_callback.Run("Error connecting to socket: " + 223 error_callback.Run("Error connecting to socket: " +
223 net::ErrorToString(net_result)); 224 net::ErrorToString(net_result));
224 closesocket(socket_fd); 225 closesocket(socket_fd);
225 return; 226 return;
226 } 227 }
227 228
228 SetTCPSocket(scoped_socket.Pass()); 229 SetTCPSocket(std::move(scoped_socket));
229 success_callback.Run(); 230 success_callback.Run();
230 } 231 }
231 232
232 void BluetoothSocketWin::DoListen( 233 void BluetoothSocketWin::DoListen(
233 const BluetoothUUID& uuid, 234 const BluetoothUUID& uuid,
234 int rfcomm_channel, 235 int rfcomm_channel,
235 const base::Closure& success_callback, 236 const base::Closure& success_callback,
236 const ErrorCompletionCallback& error_callback) { 237 const ErrorCompletionCallback& error_callback) {
237 DCHECK(socket_thread()->task_runner()->RunsTasksOnCurrentThread()); 238 DCHECK(socket_thread()->task_runner()->RunsTasksOnCurrentThread());
238 DCHECK(!tcp_socket() && !service_reg_data_); 239 DCHECK(!tcp_socket() && !service_reg_data_);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 reg_data->service.lpcsaBuffer = &reg_data->address_info; 319 reg_data->service.lpcsaBuffer = &reg_data->address_info;
319 320
320 if (WSASetService(&reg_data->service, 321 if (WSASetService(&reg_data->service,
321 RNRSERVICE_REGISTER, 0) == SOCKET_ERROR) { 322 RNRSERVICE_REGISTER, 0) == SOCKET_ERROR) {
322 LOG(WARNING) << "Failed to register profile: WSASetService" 323 LOG(WARNING) << "Failed to register profile: WSASetService"
323 << "winsock err=" << WSAGetLastError(); 324 << "winsock err=" << WSAGetLastError();
324 PostErrorCompletion(error_callback, kWsaSetServiceError); 325 PostErrorCompletion(error_callback, kWsaSetServiceError);
325 return; 326 return;
326 } 327 }
327 328
328 SetTCPSocket(scoped_socket.Pass()); 329 SetTCPSocket(std::move(scoped_socket));
329 service_reg_data_ = reg_data.Pass(); 330 service_reg_data_ = std::move(reg_data);
330 331
331 PostSuccess(success_callback); 332 PostSuccess(success_callback);
332 } 333 }
333 334
334 void BluetoothSocketWin::DoAccept( 335 void BluetoothSocketWin::DoAccept(
335 const AcceptCompletionCallback& success_callback, 336 const AcceptCompletionCallback& success_callback,
336 const ErrorCompletionCallback& error_callback) { 337 const ErrorCompletionCallback& error_callback) {
337 DCHECK(socket_thread()->task_runner()->RunsTasksOnCurrentThread()); 338 DCHECK(socket_thread()->task_runner()->RunsTasksOnCurrentThread());
338 int result = tcp_socket()->Accept( 339 int result = tcp_socket()->Accept(
339 &accept_socket_, 340 &accept_socket_,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 const BluetoothDevice* peer_device = adapter_->GetDevice(peer_device_address); 382 const BluetoothDevice* peer_device = adapter_->GetDevice(peer_device_address);
382 if (!peer_device) { 383 if (!peer_device) {
383 LOG(WARNING) << "OnAccept failed with unknown device, addr=" 384 LOG(WARNING) << "OnAccept failed with unknown device, addr="
384 << peer_device_address; 385 << peer_device_address;
385 error_callback.Run(kFailedToAccept); 386 error_callback.Run(kFailedToAccept);
386 return; 387 return;
387 } 388 }
388 389
389 scoped_refptr<BluetoothSocketWin> peer_socket = 390 scoped_refptr<BluetoothSocketWin> peer_socket =
390 CreateBluetoothSocket(ui_task_runner(), socket_thread()); 391 CreateBluetoothSocket(ui_task_runner(), socket_thread());
391 peer_socket->SetTCPSocket(accept_socket.Pass()); 392 peer_socket->SetTCPSocket(std::move(accept_socket));
392 success_callback.Run(peer_device, peer_socket); 393 success_callback.Run(peer_device, peer_socket);
393 } 394 }
394 395
395 } // namespace device 396 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_win_unittest.cc ('k') | device/hid/hid_connection_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698