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

Side by Side Diff: net/socket/udp_socket_win.cc

Issue 2503993002: Change unique_ptr::reset() for std::move (Closed)
Patch Set: Change unique_ptr::reset() for std::move Created 4 years 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 | « net/socket/udp_socket_posix.cc ('k') | net/spdy/spdy_network_transaction_unittest.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 "net/socket/udp_socket_win.h" 5 #include "net/socket/udp_socket_win.h"
6 6
7 #include <mstcpip.h> 7 #include <mstcpip.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 return ERR_SOCKET_NOT_CONNECTED; 329 return ERR_SOCKET_NOT_CONNECTED;
330 330
331 // TODO(szym): Simplify. http://crbug.com/126152 331 // TODO(szym): Simplify. http://crbug.com/126152
332 if (!remote_address_.get()) { 332 if (!remote_address_.get()) {
333 SockaddrStorage storage; 333 SockaddrStorage storage;
334 if (getpeername(socket_, storage.addr, &storage.addr_len)) 334 if (getpeername(socket_, storage.addr, &storage.addr_len))
335 return MapSystemError(WSAGetLastError()); 335 return MapSystemError(WSAGetLastError());
336 std::unique_ptr<IPEndPoint> remote_address(new IPEndPoint()); 336 std::unique_ptr<IPEndPoint> remote_address(new IPEndPoint());
337 if (!remote_address->FromSockAddr(storage.addr, storage.addr_len)) 337 if (!remote_address->FromSockAddr(storage.addr, storage.addr_len))
338 return ERR_ADDRESS_INVALID; 338 return ERR_ADDRESS_INVALID;
339 remote_address_.reset(remote_address.release()); 339 remote_address_ = std::move(remote_address);
340 } 340 }
341 341
342 *address = *remote_address_; 342 *address = *remote_address_;
343 return OK; 343 return OK;
344 } 344 }
345 345
346 int UDPSocketWin::GetLocalAddress(IPEndPoint* address) const { 346 int UDPSocketWin::GetLocalAddress(IPEndPoint* address) const {
347 DCHECK(CalledOnValidThread()); 347 DCHECK(CalledOnValidThread());
348 DCHECK(address); 348 DCHECK(address);
349 if (!is_connected()) 349 if (!is_connected())
350 return ERR_SOCKET_NOT_CONNECTED; 350 return ERR_SOCKET_NOT_CONNECTED;
351 351
352 // TODO(szym): Simplify. http://crbug.com/126152 352 // TODO(szym): Simplify. http://crbug.com/126152
353 if (!local_address_.get()) { 353 if (!local_address_.get()) {
354 SockaddrStorage storage; 354 SockaddrStorage storage;
355 if (getsockname(socket_, storage.addr, &storage.addr_len)) 355 if (getsockname(socket_, storage.addr, &storage.addr_len))
356 return MapSystemError(WSAGetLastError()); 356 return MapSystemError(WSAGetLastError());
357 std::unique_ptr<IPEndPoint> local_address(new IPEndPoint()); 357 std::unique_ptr<IPEndPoint> local_address(new IPEndPoint());
358 if (!local_address->FromSockAddr(storage.addr, storage.addr_len)) 358 if (!local_address->FromSockAddr(storage.addr, storage.addr_len))
359 return ERR_ADDRESS_INVALID; 359 return ERR_ADDRESS_INVALID;
360 local_address_.reset(local_address.release()); 360 local_address_ = std::move(local_address);
361 net_log_.AddEvent(NetLogEventType::UDP_LOCAL_ADDRESS, 361 net_log_.AddEvent(NetLogEventType::UDP_LOCAL_ADDRESS,
362 CreateNetLogUDPConnectCallback( 362 CreateNetLogUDPConnectCallback(
363 local_address_.get(), 363 local_address_.get(),
364 NetworkChangeNotifier::kInvalidNetworkHandle)); 364 NetworkChangeNotifier::kInvalidNetworkHandle));
365 } 365 }
366 366
367 *address = *local_address_; 367 *address = *local_address_;
368 return OK; 368 return OK;
369 } 369 }
370 370
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 void UDPSocketWin::DetachFromThread() { 1192 void UDPSocketWin::DetachFromThread() {
1193 base::NonThreadSafe::DetachFromThread(); 1193 base::NonThreadSafe::DetachFromThread();
1194 } 1194 }
1195 1195
1196 void UDPSocketWin::UseNonBlockingIO() { 1196 void UDPSocketWin::UseNonBlockingIO() {
1197 DCHECK(!core_); 1197 DCHECK(!core_);
1198 use_non_blocking_io_ = true; 1198 use_non_blocking_io_ = true;
1199 } 1199 }
1200 1200
1201 } // namespace net 1201 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/udp_socket_posix.cc ('k') | net/spdy/spdy_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698