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

Side by Side Diff: net/socket/socket_posix.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/socket_posix.h ('k') | net/socket/socket_test_util.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/socket_posix.h" 5 #include "net/socket/socket_posix.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <netinet/in.h> 8 #include <netinet/in.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #include <utility> 10 #include <utility>
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 int rv = listen(socket_fd_, backlog); 136 int rv = listen(socket_fd_, backlog);
137 if (rv < 0) { 137 if (rv < 0) {
138 PLOG(ERROR) << "listen() returned an error, errno=" << errno; 138 PLOG(ERROR) << "listen() returned an error, errno=" << errno;
139 return MapSystemError(errno); 139 return MapSystemError(errno);
140 } 140 }
141 141
142 return OK; 142 return OK;
143 } 143 }
144 144
145 int SocketPosix::Accept(scoped_ptr<SocketPosix>* socket, 145 int SocketPosix::Accept(std::unique_ptr<SocketPosix>* socket,
146 const CompletionCallback& callback) { 146 const CompletionCallback& callback) {
147 DCHECK(thread_checker_.CalledOnValidThread()); 147 DCHECK(thread_checker_.CalledOnValidThread());
148 DCHECK_NE(kInvalidSocket, socket_fd_); 148 DCHECK_NE(kInvalidSocket, socket_fd_);
149 DCHECK(accept_callback_.is_null()); 149 DCHECK(accept_callback_.is_null());
150 DCHECK(socket); 150 DCHECK(socket);
151 DCHECK(!callback.is_null()); 151 DCHECK(!callback.is_null());
152 152
153 int rv = DoAccept(socket); 153 int rv = DoAccept(socket);
154 if (rv != ERR_IO_PENDING) 154 if (rv != ERR_IO_PENDING)
155 return rv; 155 return rv;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 360
361 void SocketPosix::OnFileCanWriteWithoutBlocking(int fd) { 361 void SocketPosix::OnFileCanWriteWithoutBlocking(int fd) {
362 DCHECK(!write_callback_.is_null()); 362 DCHECK(!write_callback_.is_null());
363 if (waiting_connect_) { 363 if (waiting_connect_) {
364 ConnectCompleted(); 364 ConnectCompleted();
365 } else { 365 } else {
366 WriteCompleted(); 366 WriteCompleted();
367 } 367 }
368 } 368 }
369 369
370 int SocketPosix::DoAccept(scoped_ptr<SocketPosix>* socket) { 370 int SocketPosix::DoAccept(std::unique_ptr<SocketPosix>* socket) {
371 SockaddrStorage new_peer_address; 371 SockaddrStorage new_peer_address;
372 int new_socket = HANDLE_EINTR(accept(socket_fd_, 372 int new_socket = HANDLE_EINTR(accept(socket_fd_,
373 new_peer_address.addr, 373 new_peer_address.addr,
374 &new_peer_address.addr_len)); 374 &new_peer_address.addr_len));
375 if (new_socket < 0) 375 if (new_socket < 0)
376 return MapAcceptError(errno); 376 return MapAcceptError(errno);
377 377
378 scoped_ptr<SocketPosix> accepted_socket(new SocketPosix); 378 std::unique_ptr<SocketPosix> accepted_socket(new SocketPosix);
379 int rv = accepted_socket->AdoptConnectedSocket(new_socket, new_peer_address); 379 int rv = accepted_socket->AdoptConnectedSocket(new_socket, new_peer_address);
380 if (rv != OK) 380 if (rv != OK)
381 return rv; 381 return rv;
382 382
383 *socket = std::move(accepted_socket); 383 *socket = std::move(accepted_socket);
384 return OK; 384 return OK;
385 } 385 }
386 386
387 void SocketPosix::AcceptCompleted() { 387 void SocketPosix::AcceptCompleted() {
388 DCHECK(accept_socket_); 388 DCHECK(accept_socket_);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 write_buf_ = NULL; 480 write_buf_ = NULL;
481 write_buf_len_ = 0; 481 write_buf_len_ = 0;
482 write_callback_.Reset(); 482 write_callback_.Reset();
483 } 483 }
484 484
485 waiting_connect_ = false; 485 waiting_connect_ = false;
486 peer_address_.reset(); 486 peer_address_.reset();
487 } 487 }
488 488
489 } // namespace net 489 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/socket_posix.h ('k') | net/socket/socket_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698