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

Side by Side Diff: net/socket/tcp_client_socket_win.h

Issue 8824006: Migrate net/socket/socket.h, net/socket/stream_socket.h to base::Bind(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 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 | Annotate | Revision Log
« no previous file with comments | « net/socket/tcp_client_socket_unittest.cc ('k') | net/socket/tcp_client_socket_win.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 (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 24 matching lines...) Expand all
35 // socket. This object must not be connected. This object takes ownership of 35 // socket. This object must not be connected. This object takes ownership of
36 // the given socket and then acts as if Connect() had been called. This 36 // the given socket and then acts as if Connect() had been called. This
37 // function is used by TCPServerSocket() to adopt accepted connections 37 // function is used by TCPServerSocket() to adopt accepted connections
38 // and for testing. 38 // and for testing.
39 int AdoptSocket(SOCKET socket); 39 int AdoptSocket(SOCKET socket);
40 40
41 // Binds the socket to a local IP address and port. 41 // Binds the socket to a local IP address and port.
42 int Bind(const IPEndPoint& address); 42 int Bind(const IPEndPoint& address);
43 43
44 // StreamSocket implementation. 44 // StreamSocket implementation.
45 virtual int Connect(OldCompletionCallback* callback);
46 virtual int Connect(const CompletionCallback& callback); 45 virtual int Connect(const CompletionCallback& callback);
47 virtual void Disconnect(); 46 virtual void Disconnect();
48 virtual bool IsConnected() const; 47 virtual bool IsConnected() const;
49 virtual bool IsConnectedAndIdle() const; 48 virtual bool IsConnectedAndIdle() const;
50 virtual int GetPeerAddress(AddressList* address) const; 49 virtual int GetPeerAddress(AddressList* address) const;
51 virtual int GetLocalAddress(IPEndPoint* address) const; 50 virtual int GetLocalAddress(IPEndPoint* address) const;
52 virtual const BoundNetLog& NetLog() const { return net_log_; } 51 virtual const BoundNetLog& NetLog() const { return net_log_; }
53 virtual void SetSubresourceSpeculation(); 52 virtual void SetSubresourceSpeculation();
54 virtual void SetOmniboxSpeculation(); 53 virtual void SetOmniboxSpeculation();
55 virtual bool WasEverUsed() const; 54 virtual bool WasEverUsed() const;
56 virtual bool UsingTCPFastOpen() const; 55 virtual bool UsingTCPFastOpen() const;
57 virtual int64 NumBytesRead() const; 56 virtual int64 NumBytesRead() const;
58 virtual base::TimeDelta GetConnectTimeMicros() const; 57 virtual base::TimeDelta GetConnectTimeMicros() const;
59 58
60 // Socket implementation. 59 // Socket implementation.
61 // Multiple outstanding requests are not supported. 60 // Multiple outstanding requests are not supported.
62 // Full duplex mode (reading and writing at the same time) is supported 61 // Full duplex mode (reading and writing at the same time) is supported
63 virtual int Read(IOBuffer* buf, int buf_len, OldCompletionCallback* callback);
64 virtual int Read(IOBuffer* buf, int buf_len, 62 virtual int Read(IOBuffer* buf, int buf_len,
65 const CompletionCallback& callback); 63 const CompletionCallback& callback);
66 virtual int Write(IOBuffer* buf, int buf_len, OldCompletionCallback* callback) ; 64 virtual int Write(IOBuffer* buf, int buf_len,
65 const CompletionCallback& callback);
67 66
68 virtual bool SetReceiveBufferSize(int32 size); 67 virtual bool SetReceiveBufferSize(int32 size);
69 virtual bool SetSendBufferSize(int32 size); 68 virtual bool SetSendBufferSize(int32 size);
70 69
71 private: 70 private:
72 // State machine for connecting the socket. 71 // State machine for connecting the socket.
73 enum ConnectState { 72 enum ConnectState {
74 CONNECT_STATE_CONNECT, 73 CONNECT_STATE_CONNECT,
75 CONNECT_STATE_CONNECT_COMPLETE, 74 CONNECT_STATE_CONNECT_COMPLETE,
76 CONNECT_STATE_NONE, 75 CONNECT_STATE_NONE,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // The various states that the socket could be in. 118 // The various states that the socket could be in.
120 bool waiting_read_; 119 bool waiting_read_;
121 bool waiting_write_; 120 bool waiting_write_;
122 121
123 // The core of the socket that can live longer than the socket itself. We pass 122 // The core of the socket that can live longer than the socket itself. We pass
124 // resources to the Windows async IO functions and we have to make sure that 123 // resources to the Windows async IO functions and we have to make sure that
125 // they are not destroyed while the OS still references them. 124 // they are not destroyed while the OS still references them.
126 scoped_refptr<Core> core_; 125 scoped_refptr<Core> core_;
127 126
128 // External callback; called when connect or read is complete. 127 // External callback; called when connect or read is complete.
129 OldCompletionCallback* old_read_callback_;
130 CompletionCallback read_callback_; 128 CompletionCallback read_callback_;
131 129
132 // External callback; called when write is complete. 130 // External callback; called when write is complete.
133 OldCompletionCallback* write_callback_; 131 CompletionCallback write_callback_;
134 132
135 // The next state for the Connect() state machine. 133 // The next state for the Connect() state machine.
136 ConnectState next_connect_state_; 134 ConnectState next_connect_state_;
137 135
138 // The OS error that CONNECT_STATE_CONNECT last completed with. 136 // The OS error that CONNECT_STATE_CONNECT last completed with.
139 int connect_os_error_; 137 int connect_os_error_;
140 138
141 BoundNetLog net_log_; 139 BoundNetLog net_log_;
142 140
143 // This socket was previously disconnected and has not been re-connected. 141 // This socket was previously disconnected and has not been re-connected.
144 bool previously_disconnected_; 142 bool previously_disconnected_;
145 143
146 // Record of connectivity and transmissions, for use in speculative connection 144 // Record of connectivity and transmissions, for use in speculative connection
147 // histograms. 145 // histograms.
148 UseHistory use_history_; 146 UseHistory use_history_;
149 147
150 base::TimeTicks connect_start_time_; 148 base::TimeTicks connect_start_time_;
151 base::TimeDelta connect_time_micros_; 149 base::TimeDelta connect_time_micros_;
152 int64 num_bytes_read_; 150 int64 num_bytes_read_;
153 151
154 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin); 152 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin);
155 }; 153 };
156 154
157 } // namespace net 155 } // namespace net
158 156
159 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_ 157 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_
OLDNEW
« no previous file with comments | « net/socket/tcp_client_socket_unittest.cc ('k') | net/socket/tcp_client_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698