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

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

Issue 227473008: make SetReceiveBufferSize and SetSendBufferSize return net error codes (instead of bools) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linux typo Created 6 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 | Annotate | Revision Log
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 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <netdb.h> 9 #include <netdb.h>
10 #include <netinet/in.h> 10 #include <netinet/in.h>
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 // 494 //
495 // SO_REUSEPORT is provided in MacOS X and iOS. 495 // SO_REUSEPORT is provided in MacOS X and iOS.
496 int boolean_value = allow ? 1 : 0; 496 int boolean_value = allow ? 1 : 0;
497 int rv = setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, &boolean_value, 497 int rv = setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, &boolean_value,
498 sizeof(boolean_value)); 498 sizeof(boolean_value));
499 if (rv < 0) 499 if (rv < 0)
500 return MapSystemError(errno); 500 return MapSystemError(errno);
501 return OK; 501 return OK;
502 } 502 }
503 503
504 bool TCPSocketLibevent::SetReceiveBufferSize(int32 size) { 504 int TCPSocketLibevent::SetReceiveBufferSize(int32 size) {
505 DCHECK(CalledOnValidThread()); 505 DCHECK(CalledOnValidThread());
506 int rv = setsockopt(socket_, SOL_SOCKET, SO_RCVBUF, 506 int rv = setsockopt(socket_, SOL_SOCKET, SO_RCVBUF,
507 reinterpret_cast<const char*>(&size), 507 reinterpret_cast<const char*>(&size), sizeof(size));
508 sizeof(size)); 508 return (rv == 0) ? OK : MapSystemErrorWithDefault(
509 DCHECK(!rv) << "Could not set socket receive buffer size: " << errno; 509 errno, ERR_SOCKET_SET_RECEIVE_BUFFER_SIZE_ERROR);
510 return rv == 0;
511 } 510 }
512 511
513 bool TCPSocketLibevent::SetSendBufferSize(int32 size) { 512 int TCPSocketLibevent::SetSendBufferSize(int32 size) {
514 DCHECK(CalledOnValidThread()); 513 DCHECK(CalledOnValidThread());
515 int rv = setsockopt(socket_, SOL_SOCKET, SO_SNDBUF, 514 int rv = setsockopt(socket_, SOL_SOCKET, SO_SNDBUF,
516 reinterpret_cast<const char*>(&size), 515 reinterpret_cast<const char*>(&size), sizeof(size));
517 sizeof(size)); 516 return (rv == 0) ? OK : MapSystemErrorWithDefault(
518 DCHECK(!rv) << "Could not set socket send buffer size: " << errno; 517 errno, ERR_SOCKET_SET_SEND_BUFFER_SIZE_ERROR);
519 return rv == 0;
520 } 518 }
521 519
522 bool TCPSocketLibevent::SetKeepAlive(bool enable, int delay) { 520 bool TCPSocketLibevent::SetKeepAlive(bool enable, int delay) {
523 DCHECK(CalledOnValidThread()); 521 DCHECK(CalledOnValidThread());
524 return SetTCPKeepAlive(socket_, enable, delay); 522 return SetTCPKeepAlive(socket_, enable, delay);
525 } 523 }
526 524
527 bool TCPSocketLibevent::SetNoDelay(bool no_delay) { 525 bool TCPSocketLibevent::SetNoDelay(bool no_delay) {
528 DCHECK(CalledOnValidThread()); 526 DCHECK(CalledOnValidThread());
529 return SetTCPNoDelay(socket_, no_delay); 527 return SetTCPNoDelay(socket_, no_delay);
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 } 895 }
898 } else { 896 } else {
899 fast_open_status_ = (fast_open_status_ == FAST_OPEN_FAST_CONNECT_RETURN ? 897 fast_open_status_ = (fast_open_status_ == FAST_OPEN_FAST_CONNECT_RETURN ?
900 FAST_OPEN_SYN_DATA_FAILED : 898 FAST_OPEN_SYN_DATA_FAILED :
901 FAST_OPEN_NO_SYN_DATA_FAILED); 899 FAST_OPEN_NO_SYN_DATA_FAILED);
902 } 900 }
903 } 901 }
904 } 902 }
905 903
906 } // namespace net 904 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698