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

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

Issue 8801004: base::Bind: Convert StreamSocket::Connect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes 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_libevent.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 23 matching lines...) Expand all
34 // AdoptSocket causes the given, connected socket to be adopted as a TCP 34 // AdoptSocket causes the given, connected socket to be adopted as a TCP
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 methods: 44 // StreamSocket implementation.
45 virtual int Connect(OldCompletionCallback* callback); 45 virtual int Connect(OldCompletionCallback* callback);
46 virtual int Connect(const CompletionCallback& callback);
46 virtual void Disconnect(); 47 virtual void Disconnect();
47 virtual bool IsConnected() const; 48 virtual bool IsConnected() const;
48 virtual bool IsConnectedAndIdle() const; 49 virtual bool IsConnectedAndIdle() const;
49 virtual int GetPeerAddress(AddressList* address) const; 50 virtual int GetPeerAddress(AddressList* address) const;
50 virtual int GetLocalAddress(IPEndPoint* address) const; 51 virtual int GetLocalAddress(IPEndPoint* address) const;
51 virtual const BoundNetLog& NetLog() const { return net_log_; } 52 virtual const BoundNetLog& NetLog() const { return net_log_; }
52 virtual void SetSubresourceSpeculation(); 53 virtual void SetSubresourceSpeculation();
53 virtual void SetOmniboxSpeculation(); 54 virtual void SetOmniboxSpeculation();
54 virtual bool WasEverUsed() const; 55 virtual bool WasEverUsed() const;
55 virtual bool UsingTCPFastOpen() const; 56 virtual bool UsingTCPFastOpen() const;
56 virtual int64 NumBytesRead() const; 57 virtual int64 NumBytesRead() const;
57 virtual base::TimeDelta GetConnectTimeMicros() const; 58 virtual base::TimeDelta GetConnectTimeMicros() const;
58 59
59 // Socket methods: 60 // Socket implementation.
60 // Multiple outstanding requests are not supported. 61 // Multiple outstanding requests are not supported.
61 // 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
62 virtual int Read(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); 63 virtual int Read(IOBuffer* buf, int buf_len, OldCompletionCallback* callback);
63 virtual int Write(IOBuffer* buf, int buf_len, OldCompletionCallback* callback) ; 64 virtual int Write(IOBuffer* buf, int buf_len, OldCompletionCallback* callback) ;
64 65
65 virtual bool SetReceiveBufferSize(int32 size); 66 virtual bool SetReceiveBufferSize(int32 size);
66 virtual bool SetSendBufferSize(int32 size); 67 virtual bool SetSendBufferSize(int32 size);
67 68
68 private: 69 private:
69 // State machine for connecting the socket. 70 // State machine for connecting the socket.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // The various states that the socket could be in. 117 // The various states that the socket could be in.
117 bool waiting_read_; 118 bool waiting_read_;
118 bool waiting_write_; 119 bool waiting_write_;
119 120
120 // The core of the socket that can live longer than the socket itself. We pass 121 // The core of the socket that can live longer than the socket itself. We pass
121 // resources to the Windows async IO functions and we have to make sure that 122 // resources to the Windows async IO functions and we have to make sure that
122 // they are not destroyed while the OS still references them. 123 // they are not destroyed while the OS still references them.
123 scoped_refptr<Core> core_; 124 scoped_refptr<Core> core_;
124 125
125 // External callback; called when connect or read is complete. 126 // External callback; called when connect or read is complete.
126 OldCompletionCallback* read_callback_; 127 OldCompletionCallback* old_read_callback_;
128 CompletionCallback read_callback_;
127 129
128 // External callback; called when write is complete. 130 // External callback; called when write is complete.
129 OldCompletionCallback* write_callback_; 131 OldCompletionCallback* write_callback_;
130 132
131 // The next state for the Connect() state machine. 133 // The next state for the Connect() state machine.
132 ConnectState next_connect_state_; 134 ConnectState next_connect_state_;
133 135
134 // The OS error that CONNECT_STATE_CONNECT last completed with. 136 // The OS error that CONNECT_STATE_CONNECT last completed with.
135 int connect_os_error_; 137 int connect_os_error_;
136 138
137 BoundNetLog net_log_; 139 BoundNetLog net_log_;
138 140
139 // This socket was previously disconnected and has not been re-connected. 141 // This socket was previously disconnected and has not been re-connected.
140 bool previously_disconnected_; 142 bool previously_disconnected_;
141 143
142 // Record of connectivity and transmissions, for use in speculative connection 144 // Record of connectivity and transmissions, for use in speculative connection
143 // histograms. 145 // histograms.
144 UseHistory use_history_; 146 UseHistory use_history_;
145 147
146 base::TimeTicks connect_start_time_; 148 base::TimeTicks connect_start_time_;
147 base::TimeDelta connect_time_micros_; 149 base::TimeDelta connect_time_micros_;
148 int64 num_bytes_read_; 150 int64 num_bytes_read_;
149 151
150 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin); 152 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin);
151 }; 153 };
152 154
153 } // namespace net 155 } // namespace net
154 156
155 #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_libevent.cc ('k') | net/socket/tcp_client_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698