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

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

Issue 603783002: Replaced DCHECK with CHECK to detect invalid socket usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | net/socket/tcp_socket_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 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_libevent.h" 5 #include "net/socket/socket_libevent.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 10
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 return true; 224 return true;
225 } 225 }
226 226
227 int SocketLibevent::Read(IOBuffer* buf, 227 int SocketLibevent::Read(IOBuffer* buf,
228 int buf_len, 228 int buf_len,
229 const CompletionCallback& callback) { 229 const CompletionCallback& callback) {
230 DCHECK(thread_checker_.CalledOnValidThread()); 230 DCHECK(thread_checker_.CalledOnValidThread());
231 DCHECK_NE(kInvalidSocket, socket_fd_); 231 DCHECK_NE(kInvalidSocket, socket_fd_);
232 DCHECK(!waiting_connect_); 232 DCHECK(!waiting_connect_);
233 DCHECK(read_callback_.is_null()); 233 CHECK(read_callback_.is_null());
234 // Synchronous operation not supported 234 // Synchronous operation not supported
235 DCHECK(!callback.is_null()); 235 DCHECK(!callback.is_null());
236 DCHECK_LT(0, buf_len); 236 DCHECK_LT(0, buf_len);
237 237
238 int rv = DoRead(buf, buf_len); 238 int rv = DoRead(buf, buf_len);
239 if (rv != ERR_IO_PENDING) 239 if (rv != ERR_IO_PENDING)
240 return rv; 240 return rv;
241 241
242 if (!base::MessageLoopForIO::current()->WatchFileDescriptor( 242 if (!base::MessageLoopForIO::current()->WatchFileDescriptor(
243 socket_fd_, true, base::MessageLoopForIO::WATCH_READ, 243 socket_fd_, true, base::MessageLoopForIO::WATCH_READ,
244 &read_socket_watcher_, this)) { 244 &read_socket_watcher_, this)) {
245 PLOG(ERROR) << "WatchFileDescriptor failed on read, errno " << errno; 245 PLOG(ERROR) << "WatchFileDescriptor failed on read, errno " << errno;
246 return MapSystemError(errno); 246 return MapSystemError(errno);
247 } 247 }
248 248
249 read_buf_ = buf; 249 read_buf_ = buf;
250 read_buf_len_ = buf_len; 250 read_buf_len_ = buf_len;
251 read_callback_ = callback; 251 read_callback_ = callback;
252 return ERR_IO_PENDING; 252 return ERR_IO_PENDING;
253 } 253 }
254 254
255 int SocketLibevent::Write(IOBuffer* buf, 255 int SocketLibevent::Write(IOBuffer* buf,
256 int buf_len, 256 int buf_len,
257 const CompletionCallback& callback) { 257 const CompletionCallback& callback) {
258 DCHECK(thread_checker_.CalledOnValidThread()); 258 DCHECK(thread_checker_.CalledOnValidThread());
259 DCHECK_NE(kInvalidSocket, socket_fd_); 259 DCHECK_NE(kInvalidSocket, socket_fd_);
260 DCHECK(!waiting_connect_); 260 DCHECK(!waiting_connect_);
261 DCHECK(write_callback_.is_null()); 261 CHECK(write_callback_.is_null());
262 // Synchronous operation not supported 262 // Synchronous operation not supported
263 DCHECK(!callback.is_null()); 263 DCHECK(!callback.is_null());
264 DCHECK_LT(0, buf_len); 264 DCHECK_LT(0, buf_len);
265 265
266 int rv = DoWrite(buf, buf_len); 266 int rv = DoWrite(buf, buf_len);
267 if (rv == ERR_IO_PENDING) 267 if (rv == ERR_IO_PENDING)
268 rv = WaitForWrite(buf, buf_len, callback); 268 rv = WaitForWrite(buf, buf_len, callback);
269 return rv; 269 return rv;
270 } 270 }
271 271
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 write_buf_ = NULL; 473 write_buf_ = NULL;
474 write_buf_len_ = 0; 474 write_buf_len_ = 0;
475 write_callback_.Reset(); 475 write_callback_.Reset();
476 } 476 }
477 477
478 waiting_connect_ = false; 478 waiting_connect_ = false;
479 peer_address_.reset(); 479 peer_address_.reset();
480 } 480 }
481 481
482 } // namespace net 482 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/socket/tcp_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698