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

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

Issue 217573002: make SetReceiveBufferSize and SetSendBufferSize return net error codes (instead of bools) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix one more bool-->int return (in a local function) and put back tiny bug fix 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
« no previous file with comments | « net/socket/tcp_socket_win.h ('k') | net/socket/transport_client_socket_pool_unittest.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 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_win.h" 5 #include "net/socket/tcp_socket_win.h"
6 6
7 #include <mstcpip.h> 7 #include <mstcpip.h>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 10 matching lines...) Expand all
21 #include "net/base/winsock_util.h" 21 #include "net/base/winsock_util.h"
22 #include "net/socket/socket_descriptor.h" 22 #include "net/socket/socket_descriptor.h"
23 #include "net/socket/socket_net_log_params.h" 23 #include "net/socket/socket_net_log_params.h"
24 24
25 namespace net { 25 namespace net {
26 26
27 namespace { 27 namespace {
28 28
29 const int kTCPKeepAliveSeconds = 45; 29 const int kTCPKeepAliveSeconds = 45;
30 30
31 bool SetSocketReceiveBufferSize(SOCKET socket, int32 size) { 31 int SetSocketReceiveBufferSize(SOCKET socket, int32 size) {
32 int rv = setsockopt(socket, SOL_SOCKET, SO_RCVBUF, 32 int rv = setsockopt(socket, SOL_SOCKET, SO_RCVBUF,
33 reinterpret_cast<const char*>(&size), sizeof(size)); 33 reinterpret_cast<const char*>(&size), sizeof(size));
34 DCHECK(!rv) << "Could not set socket receive buffer size: " << GetLastError(); 34 DCHECK(!rv) << "Could not set socket receive buffer size: " << GetLastError();
35 return rv == 0; 35 return rv;
36 } 36 }
37 37
38 bool SetSocketSendBufferSize(SOCKET socket, int32 size) { 38 int SetSocketSendBufferSize(SOCKET socket, int32 size) {
39 int rv = setsockopt(socket, SOL_SOCKET, SO_SNDBUF, 39 int rv = setsockopt(socket, SOL_SOCKET, SO_SNDBUF,
40 reinterpret_cast<const char*>(&size), sizeof(size)); 40 reinterpret_cast<const char*>(&size), sizeof(size));
41 DCHECK(!rv) << "Could not set socket send buffer size: " << GetLastError(); 41 DCHECK(!rv) << "Could not set socket send buffer size: " << GetLastError();
42 return rv == 0; 42 return rv;
wtc 2014/04/02 00:52:29 IMPORTANT: these two functions should return like
jar (doing other things) 2014/04/02 01:18:32 Done. Also made corresponding changes in the Linu
43 } 43 }
44 44
45 // Disable Nagle. 45 // Disable Nagle.
46 // The Nagle implementation on windows is governed by RFC 896. The idea 46 // The Nagle implementation on windows is governed by RFC 896. The idea
47 // behind Nagle is to reduce small packets on the network. When Nagle is 47 // behind Nagle is to reduce small packets on the network. When Nagle is
48 // enabled, if a partial packet has been sent, the TCP stack will disallow 48 // enabled, if a partial packet has been sent, the TCP stack will disallow
49 // further *partial* packets until an ACK has been received from the other 49 // further *partial* packets until an ACK has been received from the other
50 // side. Good applications should always strive to send as much data as 50 // side. Good applications should always strive to send as much data as
51 // possible and avoid partial-packet sends. However, in most real world 51 // possible and avoid partial-packet sends. However, in most real world
52 // applications, there are edge cases where this does not happen, and two 52 // applications, there are edge cases where this does not happen, and two
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 592
593 BOOL true_value = 1; 593 BOOL true_value = 1;
594 int rv = setsockopt(socket_, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, 594 int rv = setsockopt(socket_, SOL_SOCKET, SO_EXCLUSIVEADDRUSE,
595 reinterpret_cast<const char*>(&true_value), 595 reinterpret_cast<const char*>(&true_value),
596 sizeof(true_value)); 596 sizeof(true_value));
597 if (rv < 0) 597 if (rv < 0)
598 return MapSystemError(errno); 598 return MapSystemError(errno);
599 return OK; 599 return OK;
600 } 600 }
601 601
602 bool TCPSocketWin::SetReceiveBufferSize(int32 size) { 602 int TCPSocketWin::SetReceiveBufferSize(int32 size) {
603 DCHECK(CalledOnValidThread()); 603 DCHECK(CalledOnValidThread());
604 return SetSocketReceiveBufferSize(socket_, size); 604 return SetSocketReceiveBufferSize(socket_, size);
605 } 605 }
606 606
607 bool TCPSocketWin::SetSendBufferSize(int32 size) { 607 int TCPSocketWin::SetSendBufferSize(int32 size) {
608 DCHECK(CalledOnValidThread()); 608 DCHECK(CalledOnValidThread());
609 return SetSocketSendBufferSize(socket_, size); 609 return SetSocketSendBufferSize(socket_, size);
610 } 610 }
611 611
612 bool TCPSocketWin::SetKeepAlive(bool enable, int delay) { 612 bool TCPSocketWin::SetKeepAlive(bool enable, int delay) {
613 return SetTCPKeepAlive(socket_, enable, delay); 613 return SetTCPKeepAlive(socket_, enable, delay);
614 } 614 }
615 615
616 bool TCPSocketWin::SetNoDelay(bool no_delay) { 616 bool TCPSocketWin::SetNoDelay(bool no_delay) {
617 return DisableNagle(socket_, no_delay); 617 return DisableNagle(socket_, no_delay);
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 waiting_read_ = false; 992 waiting_read_ = false;
993 core_->read_iobuffer_ = NULL; 993 core_->read_iobuffer_ = NULL;
994 core_->read_buffer_length_ = 0; 994 core_->read_buffer_length_ = 0;
995 995
996 DCHECK_NE(rv, ERR_IO_PENDING); 996 DCHECK_NE(rv, ERR_IO_PENDING);
997 base::ResetAndReturn(&read_callback_).Run(rv); 997 base::ResetAndReturn(&read_callback_).Run(rv);
998 } 998 }
999 999
1000 } // namespace net 1000 } // namespace net
1001 1001
OLDNEW
« no previous file with comments | « net/socket/tcp_socket_win.h ('k') | net/socket/transport_client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698