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

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

Issue 1892323002: Change scoped_ptr to std::unique_ptr in //net/socket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « net/socket/tcp_socket_win.h ('k') | net/socket/transport_client_socket_pool.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/tcp_socket.h" 5 #include "net/socket/tcp_socket.h"
6 #include "net/socket/tcp_socket_win.h" 6 #include "net/socket/tcp_socket_win.h"
7 7
8 #include <errno.h> 8 #include <errno.h>
9 #include <mstcpip.h> 9 #include <mstcpip.h>
10 10
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 DCHECK_EQ(object, core_->write_overlapped_.hEvent); 236 DCHECK_EQ(object, core_->write_overlapped_.hEvent);
237 if (core_->socket_) 237 if (core_->socket_)
238 core_->socket_->DidCompleteWrite(); 238 core_->socket_->DidCompleteWrite();
239 239
240 core_->Release(); 240 core_->Release();
241 } 241 }
242 242
243 //----------------------------------------------------------------------------- 243 //-----------------------------------------------------------------------------
244 244
245 TCPSocketWin::TCPSocketWin( 245 TCPSocketWin::TCPSocketWin(
246 scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher, 246 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
247 net::NetLog* net_log, 247 net::NetLog* net_log,
248 const net::NetLog::Source& source) 248 const net::NetLog::Source& source)
249 : socket_(INVALID_SOCKET), 249 : socket_(INVALID_SOCKET),
250 socket_performance_watcher_(std::move(socket_performance_watcher)), 250 socket_performance_watcher_(std::move(socket_performance_watcher)),
251 accept_event_(WSA_INVALID_EVENT), 251 accept_event_(WSA_INVALID_EVENT),
252 accept_socket_(NULL), 252 accept_socket_(NULL),
253 accept_address_(NULL), 253 accept_address_(NULL),
254 waiting_connect_(false), 254 waiting_connect_(false),
255 waiting_read_(false), 255 waiting_read_(false),
256 waiting_write_(false), 256 waiting_write_(false),
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 356
357 int result = listen(socket_, backlog); 357 int result = listen(socket_, backlog);
358 if (result < 0) { 358 if (result < 0) {
359 PLOG(ERROR) << "listen() returned an error"; 359 PLOG(ERROR) << "listen() returned an error";
360 return MapSystemError(WSAGetLastError()); 360 return MapSystemError(WSAGetLastError());
361 } 361 }
362 362
363 return OK; 363 return OK;
364 } 364 }
365 365
366 int TCPSocketWin::Accept(scoped_ptr<TCPSocketWin>* socket, 366 int TCPSocketWin::Accept(std::unique_ptr<TCPSocketWin>* socket,
367 IPEndPoint* address, 367 IPEndPoint* address,
368 const CompletionCallback& callback) { 368 const CompletionCallback& callback) {
369 DCHECK(CalledOnValidThread()); 369 DCHECK(CalledOnValidThread());
370 DCHECK(socket); 370 DCHECK(socket);
371 DCHECK(address); 371 DCHECK(address);
372 DCHECK(!callback.is_null()); 372 DCHECK(!callback.is_null());
373 DCHECK(accept_callback_.is_null()); 373 DCHECK(accept_callback_.is_null());
374 374
375 net_log_.BeginEvent(NetLog::TYPE_TCP_ACCEPT); 375 net_log_.BeginEvent(NetLog::TYPE_TCP_ACCEPT);
376 376
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 675
676 void TCPSocketWin::EndLoggingMultipleConnectAttempts(int net_error) { 676 void TCPSocketWin::EndLoggingMultipleConnectAttempts(int net_error) {
677 if (logging_multiple_connect_attempts_) { 677 if (logging_multiple_connect_attempts_) {
678 LogConnectEnd(net_error); 678 LogConnectEnd(net_error);
679 logging_multiple_connect_attempts_ = false; 679 logging_multiple_connect_attempts_ = false;
680 } else { 680 } else {
681 NOTREACHED(); 681 NOTREACHED();
682 } 682 }
683 } 683 }
684 684
685 int TCPSocketWin::AcceptInternal(scoped_ptr<TCPSocketWin>* socket, 685 int TCPSocketWin::AcceptInternal(std::unique_ptr<TCPSocketWin>* socket,
686 IPEndPoint* address) { 686 IPEndPoint* address) {
687 SockaddrStorage storage; 687 SockaddrStorage storage;
688 int new_socket = accept(socket_, storage.addr, &storage.addr_len); 688 int new_socket = accept(socket_, storage.addr, &storage.addr_len);
689 if (new_socket < 0) { 689 if (new_socket < 0) {
690 int net_error = MapSystemError(WSAGetLastError()); 690 int net_error = MapSystemError(WSAGetLastError());
691 if (net_error != ERR_IO_PENDING) 691 if (net_error != ERR_IO_PENDING)
692 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_TCP_ACCEPT, net_error); 692 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_TCP_ACCEPT, net_error);
693 return net_error; 693 return net_error;
694 } 694 }
695 695
696 IPEndPoint ip_end_point; 696 IPEndPoint ip_end_point;
697 if (!ip_end_point.FromSockAddr(storage.addr, storage.addr_len)) { 697 if (!ip_end_point.FromSockAddr(storage.addr, storage.addr_len)) {
698 NOTREACHED(); 698 NOTREACHED();
699 if (closesocket(new_socket) < 0) 699 if (closesocket(new_socket) < 0)
700 PLOG(ERROR) << "closesocket"; 700 PLOG(ERROR) << "closesocket";
701 int net_error = ERR_ADDRESS_INVALID; 701 int net_error = ERR_ADDRESS_INVALID;
702 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_TCP_ACCEPT, net_error); 702 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_TCP_ACCEPT, net_error);
703 return net_error; 703 return net_error;
704 } 704 }
705 scoped_ptr<TCPSocketWin> tcp_socket( 705 std::unique_ptr<TCPSocketWin> tcp_socket(
706 new TCPSocketWin(NULL, net_log_.net_log(), net_log_.source())); 706 new TCPSocketWin(NULL, net_log_.net_log(), net_log_.source()));
707 int adopt_result = tcp_socket->AdoptConnectedSocket(new_socket, ip_end_point); 707 int adopt_result = tcp_socket->AdoptConnectedSocket(new_socket, ip_end_point);
708 if (adopt_result != OK) { 708 if (adopt_result != OK) {
709 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_TCP_ACCEPT, adopt_result); 709 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_TCP_ACCEPT, adopt_result);
710 return adopt_result; 710 return adopt_result;
711 } 711 }
712 *socket = std::move(tcp_socket); 712 *socket = std::move(tcp_socket);
713 *address = ip_end_point; 713 *address = ip_end_point;
714 net_log_.EndEvent(NetLog::TYPE_TCP_ACCEPT, 714 net_log_.EndEvent(NetLog::TYPE_TCP_ACCEPT,
715 CreateNetLogIPEndPointCallback(&ip_end_point)); 715 CreateNetLogIPEndPointCallback(&ip_end_point));
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 } 1009 }
1010 1010
1011 bool TCPSocketWin::GetEstimatedRoundTripTime(base::TimeDelta* out_rtt) const { 1011 bool TCPSocketWin::GetEstimatedRoundTripTime(base::TimeDelta* out_rtt) const {
1012 DCHECK(out_rtt); 1012 DCHECK(out_rtt);
1013 // TODO(bmcquade): Consider implementing using 1013 // TODO(bmcquade): Consider implementing using
1014 // GetPerTcpConnectionEStats/GetPerTcp6ConnectionEStats. 1014 // GetPerTcpConnectionEStats/GetPerTcp6ConnectionEStats.
1015 return false; 1015 return false;
1016 } 1016 }
1017 1017
1018 } // namespace net 1018 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/tcp_socket_win.h ('k') | net/socket/transport_client_socket_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698