| OLD | NEW | 
|---|
| 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  Loading... | 
| 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 : MapSystemError(errno); | 
| 509   DCHECK(!rv) << "Could not set socket receive buffer size: " << errno; |  | 
| 510   return rv == 0; |  | 
| 511 } | 509 } | 
| 512 | 510 | 
| 513 bool TCPSocketLibevent::SetSendBufferSize(int32 size) { | 511 int TCPSocketLibevent::SetSendBufferSize(int32 size) { | 
| 514   DCHECK(CalledOnValidThread()); | 512   DCHECK(CalledOnValidThread()); | 
| 515   int rv = setsockopt(socket_, SOL_SOCKET, SO_SNDBUF, | 513   int rv = setsockopt(socket_, SOL_SOCKET, SO_SNDBUF, | 
| 516       reinterpret_cast<const char*>(&size), | 514                       reinterpret_cast<const char*>(&size), sizeof(size)); | 
| 517       sizeof(size)); | 515   return (rv == 0) ? OK : MapSystemError(errno); | 
| 518   DCHECK(!rv) << "Could not set socket send buffer size: " << errno; |  | 
| 519   return rv == 0; |  | 
| 520 } | 516 } | 
| 521 | 517 | 
| 522 bool TCPSocketLibevent::SetKeepAlive(bool enable, int delay) { | 518 bool TCPSocketLibevent::SetKeepAlive(bool enable, int delay) { | 
| 523   DCHECK(CalledOnValidThread()); | 519   DCHECK(CalledOnValidThread()); | 
| 524   return SetTCPKeepAlive(socket_, enable, delay); | 520   return SetTCPKeepAlive(socket_, enable, delay); | 
| 525 } | 521 } | 
| 526 | 522 | 
| 527 bool TCPSocketLibevent::SetNoDelay(bool no_delay) { | 523 bool TCPSocketLibevent::SetNoDelay(bool no_delay) { | 
| 528   DCHECK(CalledOnValidThread()); | 524   DCHECK(CalledOnValidThread()); | 
| 529   return SetTCPNoDelay(socket_, no_delay); | 525   return SetTCPNoDelay(socket_, no_delay); | 
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 897       } | 893       } | 
| 898     } else { | 894     } else { | 
| 899       fast_open_status_ = (fast_open_status_ == FAST_OPEN_FAST_CONNECT_RETURN ? | 895       fast_open_status_ = (fast_open_status_ == FAST_OPEN_FAST_CONNECT_RETURN ? | 
| 900                            FAST_OPEN_SYN_DATA_FAILED : | 896                            FAST_OPEN_SYN_DATA_FAILED : | 
| 901                            FAST_OPEN_NO_SYN_DATA_FAILED); | 897                            FAST_OPEN_NO_SYN_DATA_FAILED); | 
| 902     } | 898     } | 
| 903   } | 899   } | 
| 904 } | 900 } | 
| 905 | 901 | 
| 906 }  // namespace net | 902 }  // namespace net | 
| OLD | NEW | 
|---|