OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CLIENT_SOCKET_WIN_H_ | 5 #ifndef NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_ |
6 #define NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_ | 6 #define NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <winsock2.h> | 9 #include <winsock2.h> |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 virtual bool UsingTCPFastOpen() const; | 56 virtual bool UsingTCPFastOpen() const; |
57 virtual int64 NumBytesRead() const; | 57 virtual int64 NumBytesRead() const; |
58 virtual base::TimeDelta GetConnectTimeMicros() const; | 58 virtual base::TimeDelta GetConnectTimeMicros() const; |
59 | 59 |
60 // Socket implementation. | 60 // Socket implementation. |
61 // Multiple outstanding requests are not supported. | 61 // Multiple outstanding requests are not supported. |
62 // Full duplex mode (reading and writing at the same time) is supported | 62 // Full duplex mode (reading and writing at the same time) is supported |
63 virtual int Read(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); | 63 virtual int Read(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); |
64 virtual int Read(IOBuffer* buf, int buf_len, | 64 virtual int Read(IOBuffer* buf, int buf_len, |
65 const CompletionCallback& callback); | 65 const CompletionCallback& callback); |
66 virtual int Write(IOBuffer* buf, int buf_len, | 66 virtual int Write(IOBuffer* buf, int buf_len, OldCompletionCallback* callback)
; |
67 OldCompletionCallback* callback); | |
68 virtual int Write(IOBuffer* buf, int buf_len, | |
69 const CompletionCallback& callback); | |
70 | 67 |
71 virtual bool SetReceiveBufferSize(int32 size); | 68 virtual bool SetReceiveBufferSize(int32 size); |
72 virtual bool SetSendBufferSize(int32 size); | 69 virtual bool SetSendBufferSize(int32 size); |
73 | 70 |
74 private: | 71 private: |
75 // State machine for connecting the socket. | 72 // State machine for connecting the socket. |
76 enum ConnectState { | 73 enum ConnectState { |
77 CONNECT_STATE_CONNECT, | 74 CONNECT_STATE_CONNECT, |
78 CONNECT_STATE_CONNECT_COMPLETE, | 75 CONNECT_STATE_CONNECT_COMPLETE, |
79 CONNECT_STATE_NONE, | 76 CONNECT_STATE_NONE, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // The core of the socket that can live longer than the socket itself. We pass | 123 // The core of the socket that can live longer than the socket itself. We pass |
127 // resources to the Windows async IO functions and we have to make sure that | 124 // resources to the Windows async IO functions and we have to make sure that |
128 // they are not destroyed while the OS still references them. | 125 // they are not destroyed while the OS still references them. |
129 scoped_refptr<Core> core_; | 126 scoped_refptr<Core> core_; |
130 | 127 |
131 // External callback; called when connect or read is complete. | 128 // External callback; called when connect or read is complete. |
132 OldCompletionCallback* old_read_callback_; | 129 OldCompletionCallback* old_read_callback_; |
133 CompletionCallback read_callback_; | 130 CompletionCallback read_callback_; |
134 | 131 |
135 // External callback; called when write is complete. | 132 // External callback; called when write is complete. |
136 OldCompletionCallback* old_write_callback_; | 133 OldCompletionCallback* write_callback_; |
137 CompletionCallback write_callback_; | |
138 | 134 |
139 // The next state for the Connect() state machine. | 135 // The next state for the Connect() state machine. |
140 ConnectState next_connect_state_; | 136 ConnectState next_connect_state_; |
141 | 137 |
142 // The OS error that CONNECT_STATE_CONNECT last completed with. | 138 // The OS error that CONNECT_STATE_CONNECT last completed with. |
143 int connect_os_error_; | 139 int connect_os_error_; |
144 | 140 |
145 BoundNetLog net_log_; | 141 BoundNetLog net_log_; |
146 | 142 |
147 // This socket was previously disconnected and has not been re-connected. | 143 // This socket was previously disconnected and has not been re-connected. |
148 bool previously_disconnected_; | 144 bool previously_disconnected_; |
149 | 145 |
150 // Record of connectivity and transmissions, for use in speculative connection | 146 // Record of connectivity and transmissions, for use in speculative connection |
151 // histograms. | 147 // histograms. |
152 UseHistory use_history_; | 148 UseHistory use_history_; |
153 | 149 |
154 base::TimeTicks connect_start_time_; | 150 base::TimeTicks connect_start_time_; |
155 base::TimeDelta connect_time_micros_; | 151 base::TimeDelta connect_time_micros_; |
156 int64 num_bytes_read_; | 152 int64 num_bytes_read_; |
157 | 153 |
158 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin); | 154 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin); |
159 }; | 155 }; |
160 | 156 |
161 } // namespace net | 157 } // namespace net |
162 | 158 |
163 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_ | 159 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_ |
OLD | NEW |