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_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" |
11 #include "base/metrics/stats_counters.h" | 11 #include "base/metrics/stats_counters.h" |
12 #include "base/win/windows_version.h" | 12 #include "base/win/windows_version.h" |
13 #include "net/base/address_list.h" | 13 #include "net/base/address_list.h" |
14 #include "net/base/connection_type_histograms.h" | 14 #include "net/base/connection_type_histograms.h" |
15 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
16 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
17 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
18 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
19 #include "net/base/network_change_notifier.h" | 19 #include "net/base/network_change_notifier.h" |
20 #include "net/base/winsock_init.h" | 20 #include "net/base/winsock_init.h" |
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 { |
mmenke
2014/09/12 14:20:19
nit: add back linebreak.
Jana
2014/09/12 15:25:52
Done.
| |
28 | |
29 const int kTCPKeepAliveSeconds = 45; | 28 const int kTCPKeepAliveSeconds = 45; |
30 | 29 |
31 int SetSocketReceiveBufferSize(SOCKET socket, int32 size) { | 30 int SetSocketReceiveBufferSize(SOCKET socket, int32 size) { |
32 int rv = setsockopt(socket, SOL_SOCKET, SO_RCVBUF, | 31 int rv = setsockopt(socket, SOL_SOCKET, SO_RCVBUF, |
33 reinterpret_cast<const char*>(&size), sizeof(size)); | 32 reinterpret_cast<const char*>(&size), sizeof(size)); |
34 int net_error = (rv == 0) ? OK : MapSystemError(WSAGetLastError()); | 33 int net_error = (rv == 0) ? OK : MapSystemError(WSAGetLastError()); |
35 DCHECK(!rv) << "Could not set socket receive buffer size: " << net_error; | 34 DCHECK(!rv) << "Could not set socket receive buffer size: " << net_error; |
36 return net_error; | 35 return net_error; |
37 } | 36 } |
38 | 37 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 | 115 |
117 return net_error; | 116 return net_error; |
118 } | 117 } |
119 } | 118 } |
120 } | 119 } |
121 | 120 |
122 } // namespace | 121 } // namespace |
123 | 122 |
124 //----------------------------------------------------------------------------- | 123 //----------------------------------------------------------------------------- |
125 | 124 |
125 // Nothing to do for Windows since it doesn't support TCP FastOpen. | |
126 // TODO(jri): Remove these along with the corresponding global variables. | |
127 bool IsTCPFastOpenSupported() { return false; } | |
128 bool IsTCPFastOpenUserEnabled() { return false; } | |
129 void CheckSupportAndMaybeEnableTCPFastOpen(bool user_enabled) {} | |
130 | |
126 // This class encapsulates all the state that has to be preserved as long as | 131 // This class encapsulates all the state that has to be preserved as long as |
127 // there is a network IO operation in progress. If the owner TCPSocketWin is | 132 // there is a network IO operation in progress. If the owner TCPSocketWin is |
128 // destroyed while an operation is in progress, the Core is detached and it | 133 // destroyed while an operation is in progress, the Core is detached and it |
129 // lives until the operation completes and the OS doesn't reference any resource | 134 // lives until the operation completes and the OS doesn't reference any resource |
130 // declared on this class anymore. | 135 // declared on this class anymore. |
131 class TCPSocketWin::Core : public base::RefCounted<Core> { | 136 class TCPSocketWin::Core : public base::RefCounted<Core> { |
132 public: | 137 public: |
133 explicit Core(TCPSocketWin* socket); | 138 explicit Core(TCPSocketWin* socket); |
134 | 139 |
135 // Start watching for the end of a read or write operation. | 140 // Start watching for the end of a read or write operation. |
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1014 | 1019 |
1015 waiting_read_ = false; | 1020 waiting_read_ = false; |
1016 core_->read_iobuffer_ = NULL; | 1021 core_->read_iobuffer_ = NULL; |
1017 core_->read_buffer_length_ = 0; | 1022 core_->read_buffer_length_ = 0; |
1018 | 1023 |
1019 DCHECK_NE(rv, ERR_IO_PENDING); | 1024 DCHECK_NE(rv, ERR_IO_PENDING); |
1020 base::ResetAndReturn(&read_callback_).Run(rv); | 1025 base::ResetAndReturn(&read_callback_).Run(rv); |
1021 } | 1026 } |
1022 | 1027 |
1023 } // namespace net | 1028 } // namespace net |
1024 | |
OLD | NEW |