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

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

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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 | « net/socket/tcp_socket_win.h ('k') | net/socket/transport_client_socket_pool.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 // 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 #include "net/socket/tcp_socket_win.h" 6 #include "net/socket/tcp_socket_win.h"
7 7
8 #include <errno.h> 8 #include <errno.h>
9 #include <mstcpip.h> 9 #include <mstcpip.h>
10 10
11 #include "base/callback_helpers.h" 11 #include "base/callback_helpers.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h"
14 #include "base/profiler/scoped_tracker.h" 15 #include "base/profiler/scoped_tracker.h"
15 #include "base/win/windows_version.h" 16 #include "base/win/windows_version.h"
16 #include "net/base/address_list.h" 17 #include "net/base/address_list.h"
17 #include "net/base/connection_type_histograms.h" 18 #include "net/base/connection_type_histograms.h"
18 #include "net/base/io_buffer.h" 19 #include "net/base/io_buffer.h"
19 #include "net/base/ip_endpoint.h" 20 #include "net/base/ip_endpoint.h"
20 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
21 #include "net/base/net_util.h" 22 #include "net/base/net_util.h"
22 #include "net/base/network_activity_monitor.h" 23 #include "net/base/network_activity_monitor.h"
23 #include "net/base/network_change_notifier.h" 24 #include "net/base/network_change_notifier.h"
24 #include "net/base/winsock_init.h" 25 #include "net/base/winsock_init.h"
25 #include "net/base/winsock_util.h" 26 #include "net/base/winsock_util.h"
26 #include "net/socket/socket_descriptor.h" 27 #include "net/socket/socket_descriptor.h"
27 #include "net/socket/socket_net_log_params.h" 28 #include "net/socket/socket_net_log_params.h"
28 29
29 namespace net { 30 namespace net {
30 31
31 namespace { 32 namespace {
32 33
33 const int kTCPKeepAliveSeconds = 45; 34 const int kTCPKeepAliveSeconds = 45;
34 35
35 int SetSocketReceiveBufferSize(SOCKET socket, int32 size) { 36 int SetSocketReceiveBufferSize(SOCKET socket, int32_t size) {
36 int rv = setsockopt(socket, SOL_SOCKET, SO_RCVBUF, 37 int rv = setsockopt(socket, SOL_SOCKET, SO_RCVBUF,
37 reinterpret_cast<const char*>(&size), sizeof(size)); 38 reinterpret_cast<const char*>(&size), sizeof(size));
38 int net_error = (rv == 0) ? OK : MapSystemError(WSAGetLastError()); 39 int net_error = (rv == 0) ? OK : MapSystemError(WSAGetLastError());
39 DCHECK(!rv) << "Could not set socket receive buffer size: " << net_error; 40 DCHECK(!rv) << "Could not set socket receive buffer size: " << net_error;
40 return net_error; 41 return net_error;
41 } 42 }
42 43
43 int SetSocketSendBufferSize(SOCKET socket, int32 size) { 44 int SetSocketSendBufferSize(SOCKET socket, int32_t size) {
44 int rv = setsockopt(socket, SOL_SOCKET, SO_SNDBUF, 45 int rv = setsockopt(socket, SOL_SOCKET, SO_SNDBUF,
45 reinterpret_cast<const char*>(&size), sizeof(size)); 46 reinterpret_cast<const char*>(&size), sizeof(size));
46 int net_error = (rv == 0) ? OK : MapSystemError(WSAGetLastError()); 47 int net_error = (rv == 0) ? OK : MapSystemError(WSAGetLastError());
47 DCHECK(!rv) << "Could not set socket send buffer size: " << net_error; 48 DCHECK(!rv) << "Could not set socket send buffer size: " << net_error;
48 return net_error; 49 return net_error;
49 } 50 }
50 51
51 // Disable Nagle. 52 // Disable Nagle.
52 // The Nagle implementation on windows is governed by RFC 896. The idea 53 // The Nagle implementation on windows is governed by RFC 896. The idea
53 // behind Nagle is to reduce small packets on the network. When Nagle is 54 // behind Nagle is to reduce small packets on the network. When Nagle is
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 // performance testing, there is substantial benefit by increasing from 8KB 584 // performance testing, there is substantial benefit by increasing from 8KB
584 // to 64KB. 585 // to 64KB.
585 // See also: 586 // See also:
586 // http://support.microsoft.com/kb/823764/EN-US 587 // http://support.microsoft.com/kb/823764/EN-US
587 // On Vista, if we manually set these sizes, Vista turns off its receive 588 // On Vista, if we manually set these sizes, Vista turns off its receive
588 // window auto-tuning feature. 589 // window auto-tuning feature.
589 // http://blogs.msdn.com/wndp/archive/2006/05/05/Winhec-blog-tcpip-2.aspx 590 // http://blogs.msdn.com/wndp/archive/2006/05/05/Winhec-blog-tcpip-2.aspx
590 // Since Vista's auto-tune is better than any static value we can could set, 591 // Since Vista's auto-tune is better than any static value we can could set,
591 // only change these on pre-vista machines. 592 // only change these on pre-vista machines.
592 if (base::win::GetVersion() < base::win::VERSION_VISTA) { 593 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
593 const int32 kSocketBufferSize = 64 * 1024; 594 const int32_t kSocketBufferSize = 64 * 1024;
594 SetSocketReceiveBufferSize(socket_, kSocketBufferSize); 595 SetSocketReceiveBufferSize(socket_, kSocketBufferSize);
595 SetSocketSendBufferSize(socket_, kSocketBufferSize); 596 SetSocketSendBufferSize(socket_, kSocketBufferSize);
596 } 597 }
597 598
598 DisableNagle(socket_, true); 599 DisableNagle(socket_, true);
599 SetTCPKeepAlive(socket_, true, kTCPKeepAliveSeconds); 600 SetTCPKeepAlive(socket_, true, kTCPKeepAliveSeconds);
600 } 601 }
601 602
602 int TCPSocketWin::SetExclusiveAddrUse() { 603 int TCPSocketWin::SetExclusiveAddrUse() {
603 // On Windows, a bound end point can be hijacked by another process by 604 // On Windows, a bound end point can be hijacked by another process by
(...skipping 14 matching lines...) Expand all
618 619
619 BOOL true_value = 1; 620 BOOL true_value = 1;
620 int rv = setsockopt(socket_, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, 621 int rv = setsockopt(socket_, SOL_SOCKET, SO_EXCLUSIVEADDRUSE,
621 reinterpret_cast<const char*>(&true_value), 622 reinterpret_cast<const char*>(&true_value),
622 sizeof(true_value)); 623 sizeof(true_value));
623 if (rv < 0) 624 if (rv < 0)
624 return MapSystemError(errno); 625 return MapSystemError(errno);
625 return OK; 626 return OK;
626 } 627 }
627 628
628 int TCPSocketWin::SetReceiveBufferSize(int32 size) { 629 int TCPSocketWin::SetReceiveBufferSize(int32_t size) {
629 DCHECK(CalledOnValidThread()); 630 DCHECK(CalledOnValidThread());
630 return SetSocketReceiveBufferSize(socket_, size); 631 return SetSocketReceiveBufferSize(socket_, size);
631 } 632 }
632 633
633 int TCPSocketWin::SetSendBufferSize(int32 size) { 634 int TCPSocketWin::SetSendBufferSize(int32_t size) {
634 DCHECK(CalledOnValidThread()); 635 DCHECK(CalledOnValidThread());
635 return SetSocketSendBufferSize(socket_, size); 636 return SetSocketSendBufferSize(socket_, size);
636 } 637 }
637 638
638 bool TCPSocketWin::SetKeepAlive(bool enable, int delay) { 639 bool TCPSocketWin::SetKeepAlive(bool enable, int delay) {
639 return SetTCPKeepAlive(socket_, enable, delay); 640 return SetTCPKeepAlive(socket_, enable, delay);
640 } 641 }
641 642
642 bool TCPSocketWin::SetNoDelay(bool no_delay) { 643 bool TCPSocketWin::SetNoDelay(bool no_delay) {
643 return DisableNagle(socket_, no_delay); 644 return DisableNagle(socket_, no_delay);
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 } 1051 }
1051 1052
1052 bool TCPSocketWin::GetEstimatedRoundTripTime(base::TimeDelta* out_rtt) const { 1053 bool TCPSocketWin::GetEstimatedRoundTripTime(base::TimeDelta* out_rtt) const {
1053 DCHECK(out_rtt); 1054 DCHECK(out_rtt);
1054 // TODO(bmcquade): Consider implementing using 1055 // TODO(bmcquade): Consider implementing using
1055 // GetPerTcpConnectionEStats/GetPerTcp6ConnectionEStats. 1056 // GetPerTcpConnectionEStats/GetPerTcp6ConnectionEStats.
1056 return false; 1057 return false;
1057 } 1058 }
1058 1059
1059 } // namespace net 1060 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/tcp_socket_win.h ('k') | net/socket/transport_client_socket_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698