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

Side by Side Diff: webrtc/base/asynctcpsocket.cc

Issue 2718663005: Replace NULL with nullptr or null in webrtc/base/. (Closed)
Patch Set: Fixing Windows and formatting issues. Created 3 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 | « webrtc/base/asynctcpsocket.h ('k') | webrtc/base/asyncudpsocket.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 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 29 matching lines...) Expand all
40 static const int kListenBacklog = 5; 40 static const int kListenBacklog = 5;
41 41
42 // Binds and connects |socket| 42 // Binds and connects |socket|
43 AsyncSocket* AsyncTCPSocketBase::ConnectSocket( 43 AsyncSocket* AsyncTCPSocketBase::ConnectSocket(
44 rtc::AsyncSocket* socket, 44 rtc::AsyncSocket* socket,
45 const rtc::SocketAddress& bind_address, 45 const rtc::SocketAddress& bind_address,
46 const rtc::SocketAddress& remote_address) { 46 const rtc::SocketAddress& remote_address) {
47 std::unique_ptr<rtc::AsyncSocket> owned_socket(socket); 47 std::unique_ptr<rtc::AsyncSocket> owned_socket(socket);
48 if (socket->Bind(bind_address) < 0) { 48 if (socket->Bind(bind_address) < 0) {
49 LOG(LS_ERROR) << "Bind() failed with error " << socket->GetError(); 49 LOG(LS_ERROR) << "Bind() failed with error " << socket->GetError();
50 return NULL; 50 return nullptr;
51 } 51 }
52 if (socket->Connect(remote_address) < 0) { 52 if (socket->Connect(remote_address) < 0) {
53 LOG(LS_ERROR) << "Connect() failed with error " << socket->GetError(); 53 LOG(LS_ERROR) << "Connect() failed with error " << socket->GetError();
54 return NULL; 54 return nullptr;
55 } 55 }
56 return owned_socket.release(); 56 return owned_socket.release();
57 } 57 }
58 58
59 AsyncTCPSocketBase::AsyncTCPSocketBase(AsyncSocket* socket, bool listen, 59 AsyncTCPSocketBase::AsyncTCPSocketBase(AsyncSocket* socket, bool listen,
60 size_t max_packet_size) 60 size_t max_packet_size)
61 : socket_(socket), 61 : socket_(socket),
62 listen_(listen), 62 listen_(listen),
63 max_insize_(max_packet_size), 63 max_insize_(max_packet_size),
64 max_outsize_(max_packet_size) { 64 max_outsize_(max_packet_size) {
65 if (!listen_) { 65 if (!listen_) {
66 // Listening sockets don't send/receive data, so they don't need buffers. 66 // Listening sockets don't send/receive data, so they don't need buffers.
67 inbuf_.EnsureCapacity(kMinimumRecvSize); 67 inbuf_.EnsureCapacity(kMinimumRecvSize);
68 } 68 }
69 69
70 RTC_DCHECK(socket_.get() != NULL); 70 RTC_DCHECK(socket_.get() != nullptr);
71 socket_->SignalConnectEvent.connect( 71 socket_->SignalConnectEvent.connect(
72 this, &AsyncTCPSocketBase::OnConnectEvent); 72 this, &AsyncTCPSocketBase::OnConnectEvent);
73 socket_->SignalReadEvent.connect(this, &AsyncTCPSocketBase::OnReadEvent); 73 socket_->SignalReadEvent.connect(this, &AsyncTCPSocketBase::OnReadEvent);
74 socket_->SignalWriteEvent.connect(this, &AsyncTCPSocketBase::OnWriteEvent); 74 socket_->SignalWriteEvent.connect(this, &AsyncTCPSocketBase::OnWriteEvent);
75 socket_->SignalCloseEvent.connect(this, &AsyncTCPSocketBase::OnCloseEvent); 75 socket_->SignalCloseEvent.connect(this, &AsyncTCPSocketBase::OnCloseEvent);
76 76
77 if (listen_) { 77 if (listen_) {
78 if (socket_->Listen(kListenBacklog) < 0) { 78 if (socket_->Listen(kListenBacklog) < 0) {
79 LOG(LS_ERROR) << "Listen() failed with error " << socket_->GetError(); 79 LOG(LS_ERROR) << "Listen() failed with error " << socket_->GetError();
80 } 80 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 SignalReadyToSend(this); 253 SignalReadyToSend(this);
254 } 254 }
255 } 255 }
256 256
257 void AsyncTCPSocketBase::OnCloseEvent(AsyncSocket* socket, int error) { 257 void AsyncTCPSocketBase::OnCloseEvent(AsyncSocket* socket, int error) {
258 SignalClose(this, error); 258 SignalClose(this, error);
259 } 259 }
260 260
261 // AsyncTCPSocket 261 // AsyncTCPSocket
262 // Binds and connects |socket| and creates AsyncTCPSocket for 262 // Binds and connects |socket| and creates AsyncTCPSocket for
263 // it. Takes ownership of |socket|. Returns NULL if bind() or 263 // it. Takes ownership of |socket|. Returns null if bind() or
264 // connect() fail (|socket| is destroyed in that case). 264 // connect() fail (|socket| is destroyed in that case).
265 AsyncTCPSocket* AsyncTCPSocket::Create( 265 AsyncTCPSocket* AsyncTCPSocket::Create(
266 AsyncSocket* socket, 266 AsyncSocket* socket,
267 const SocketAddress& bind_address, 267 const SocketAddress& bind_address,
268 const SocketAddress& remote_address) { 268 const SocketAddress& remote_address) {
269 return new AsyncTCPSocket(AsyncTCPSocketBase::ConnectSocket( 269 return new AsyncTCPSocket(AsyncTCPSocketBase::ConnectSocket(
270 socket, bind_address, remote_address), false); 270 socket, bind_address, remote_address), false);
271 } 271 }
272 272
273 AsyncTCPSocket::AsyncTCPSocket(AsyncSocket* socket, bool listen) 273 AsyncTCPSocket::AsyncTCPSocket(AsyncSocket* socket, bool listen)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 memmove(data, data + kPacketLenSize + pkt_len, *len); 322 memmove(data, data + kPacketLenSize + pkt_len, *len);
323 } 323 }
324 } 324 }
325 } 325 }
326 326
327 void AsyncTCPSocket::HandleIncomingConnection(AsyncSocket* socket) { 327 void AsyncTCPSocket::HandleIncomingConnection(AsyncSocket* socket) {
328 SignalNewConnection(this, new AsyncTCPSocket(socket, false)); 328 SignalNewConnection(this, new AsyncTCPSocket(socket, false));
329 } 329 }
330 330
331 } // namespace rtc 331 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/asynctcpsocket.h ('k') | webrtc/base/asyncudpsocket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698