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 #ifndef NET_SOCKET_TCP_SOCKET_WIN_H_ | 5 #ifndef NET_SOCKET_TCP_SOCKET_WIN_H_ |
6 #define NET_SOCKET_TCP_SOCKET_WIN_H_ | 6 #define NET_SOCKET_TCP_SOCKET_WIN_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <winsock2.h> | 9 #include <winsock2.h> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
16 #include "base/win/object_watcher.h" | 16 #include "base/win/object_watcher.h" |
17 #include "net/base/address_family.h" | 17 #include "net/base/address_family.h" |
18 #include "net/base/completion_callback.h" | 18 #include "net/base/completion_callback.h" |
19 #include "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
20 #include "net/base/socket_performance_watcher.h" | |
20 #include "net/log/net_log.h" | 21 #include "net/log/net_log.h" |
21 | 22 |
22 namespace net { | 23 namespace net { |
23 | 24 |
24 class AddressList; | 25 class AddressList; |
25 class IOBuffer; | 26 class IOBuffer; |
26 class IPEndPoint; | 27 class IPEndPoint; |
27 | 28 |
28 class NET_EXPORT TCPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe), | 29 class NET_EXPORT TCPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe), |
29 public base::win::ObjectWatcher::Delegate { | 30 public base::win::ObjectWatcher::Delegate { |
30 public: | 31 public: |
31 TCPSocketWin(NetLog* net_log, const NetLog::Source& source); | 32 TCPSocketWin(scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
33 NetLog* net_log, | |
34 const NetLog::Source& source); | |
32 ~TCPSocketWin() override; | 35 ~TCPSocketWin() override; |
33 | 36 |
34 int Open(AddressFamily family); | 37 int Open(AddressFamily family); |
35 | 38 |
36 // Both AdoptConnectedSocket and AdoptListenSocket take ownership of an | 39 // Both AdoptConnectedSocket and AdoptListenSocket take ownership of an |
37 // existing socket. AdoptConnectedSocket takes an already connected | 40 // existing socket. AdoptConnectedSocket takes an already connected |
38 // socket. AdoptListenSocket takes a socket that is intended to accept | 41 // socket. AdoptListenSocket takes a socket that is intended to accept |
39 // connection. In some sense, AdoptListenSocket is more similar to Open. | 42 // connection. In some sense, AdoptListenSocket is more similar to Open. |
40 int AdoptConnectedSocket(SOCKET socket, const IPEndPoint& peer_address); | 43 int AdoptConnectedSocket(SOCKET socket, const IPEndPoint& peer_address); |
41 int AdoptListenSocket(SOCKET socket); | 44 int AdoptListenSocket(SOCKET socket); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 void LogConnectBegin(const AddressList& addresses); | 124 void LogConnectBegin(const AddressList& addresses); |
122 void LogConnectEnd(int net_error); | 125 void LogConnectEnd(int net_error); |
123 | 126 |
124 int DoRead(IOBuffer* buf, int buf_len, const CompletionCallback& callback); | 127 int DoRead(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
125 void DidCompleteConnect(); | 128 void DidCompleteConnect(); |
126 void DidCompleteWrite(); | 129 void DidCompleteWrite(); |
127 void DidSignalRead(); | 130 void DidSignalRead(); |
128 | 131 |
129 SOCKET socket_; | 132 SOCKET socket_; |
130 | 133 |
134 // Socket performance statistics may be reported to the | |
135 // |socket_performance_watcher_|. May be nullptr. | |
Ryan Sleevi
2016/04/11 22:06:57
The first sentence doesn't add value; that's docum
tbansal1
2016/04/12 16:14:34
Done.
| |
136 scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher_; | |
Ryan Sleevi
2016/04/11 22:06:57
Given that this isn't used, this seems pointless t
tbansal1
2016/04/12 16:14:34
Added comment in tcp_client_socket.h
| |
137 | |
131 HANDLE accept_event_; | 138 HANDLE accept_event_; |
132 base::win::ObjectWatcher accept_watcher_; | 139 base::win::ObjectWatcher accept_watcher_; |
133 | 140 |
134 scoped_ptr<TCPSocketWin>* accept_socket_; | 141 scoped_ptr<TCPSocketWin>* accept_socket_; |
135 IPEndPoint* accept_address_; | 142 IPEndPoint* accept_address_; |
136 CompletionCallback accept_callback_; | 143 CompletionCallback accept_callback_; |
137 | 144 |
138 // The various states that the socket could be in. | 145 // The various states that the socket could be in. |
139 bool waiting_connect_; | 146 bool waiting_connect_; |
140 bool waiting_read_; | 147 bool waiting_read_; |
(...skipping 17 matching lines...) Expand all Loading... | |
158 bool logging_multiple_connect_attempts_; | 165 bool logging_multiple_connect_attempts_; |
159 | 166 |
160 BoundNetLog net_log_; | 167 BoundNetLog net_log_; |
161 | 168 |
162 DISALLOW_COPY_AND_ASSIGN(TCPSocketWin); | 169 DISALLOW_COPY_AND_ASSIGN(TCPSocketWin); |
163 }; | 170 }; |
164 | 171 |
165 } // namespace net | 172 } // namespace net |
166 | 173 |
167 #endif // NET_SOCKET_TCP_SOCKET_WIN_H_ | 174 #endif // NET_SOCKET_TCP_SOCKET_WIN_H_ |
OLD | NEW |