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

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

Issue 8801004: base::Bind: Convert StreamSocket::Connect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Build 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
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_LIBEVENT_H_ 5 #ifndef NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_
6 #define NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ 6 #define NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 24 matching lines...) Expand all
35 // AdoptSocket causes the given, connected socket to be adopted as a TCP 35 // AdoptSocket causes the given, connected socket to be adopted as a TCP
36 // socket. This object must not be connected. This object takes ownership of 36 // socket. This object must not be connected. This object takes ownership of
37 // the given socket and then acts as if Connect() had been called. This 37 // the given socket and then acts as if Connect() had been called. This
38 // function is used by TCPServerSocket() to adopt accepted connections 38 // function is used by TCPServerSocket() to adopt accepted connections
39 // and for testing. 39 // and for testing.
40 int AdoptSocket(int socket); 40 int AdoptSocket(int socket);
41 41
42 // Binds the socket to a local IP address and port. 42 // Binds the socket to a local IP address and port.
43 int Bind(const IPEndPoint& address); 43 int Bind(const IPEndPoint& address);
44 44
45 // StreamSocket methods: 45 // StreamSocket implementation.
46 virtual int Connect(OldCompletionCallback* callback) OVERRIDE; 46 virtual int Connect(OldCompletionCallback* callback) OVERRIDE;
47 virtual int Connect(const CompletionCallback& callback) OVERRIDE;
47 virtual void Disconnect() OVERRIDE; 48 virtual void Disconnect() OVERRIDE;
48 virtual bool IsConnected() const OVERRIDE; 49 virtual bool IsConnected() const OVERRIDE;
49 virtual bool IsConnectedAndIdle() const OVERRIDE; 50 virtual bool IsConnectedAndIdle() const OVERRIDE;
50 virtual int GetPeerAddress(AddressList* address) const OVERRIDE; 51 virtual int GetPeerAddress(AddressList* address) const OVERRIDE;
51 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; 52 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE;
52 virtual const BoundNetLog& NetLog() const OVERRIDE; 53 virtual const BoundNetLog& NetLog() const OVERRIDE;
53 virtual void SetSubresourceSpeculation() OVERRIDE; 54 virtual void SetSubresourceSpeculation() OVERRIDE;
54 virtual void SetOmniboxSpeculation() OVERRIDE; 55 virtual void SetOmniboxSpeculation() OVERRIDE;
55 virtual bool WasEverUsed() const OVERRIDE; 56 virtual bool WasEverUsed() const OVERRIDE;
56 virtual bool UsingTCPFastOpen() const OVERRIDE; 57 virtual bool UsingTCPFastOpen() const OVERRIDE;
57 virtual int64 NumBytesRead() const OVERRIDE; 58 virtual int64 NumBytesRead() const OVERRIDE;
58 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; 59 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE;
59 60
60 // Socket methods: 61 // Socket implementation.
61 // Multiple outstanding requests are not supported. 62 // Multiple outstanding requests are not supported.
62 // Full duplex mode (reading and writing at the same time) is supported 63 // Full duplex mode (reading and writing at the same time) is supported
63 virtual int Read(IOBuffer* buf, 64 virtual int Read(IOBuffer* buf,
64 int buf_len, 65 int buf_len,
65 OldCompletionCallback* callback) OVERRIDE; 66 OldCompletionCallback* callback) OVERRIDE;
66 virtual int Write(IOBuffer* buf, 67 virtual int Write(IOBuffer* buf,
67 int buf_len, 68 int buf_len,
68 OldCompletionCallback* callback) OVERRIDE; 69 OldCompletionCallback* callback) OVERRIDE;
69 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; 70 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE;
70 virtual bool SetSendBufferSize(int32 size) OVERRIDE; 71 virtual bool SetSendBufferSize(int32 size) OVERRIDE;
(...skipping 29 matching lines...) Expand all
100 public: 101 public:
101 explicit WriteWatcher(TCPClientSocketLibevent* socket) : socket_(socket) {} 102 explicit WriteWatcher(TCPClientSocketLibevent* socket) : socket_(socket) {}
102 103
103 // MessageLoopForIO::Watcher methods 104 // MessageLoopForIO::Watcher methods
104 105
105 virtual void OnFileCanReadWithoutBlocking(int /* fd */) OVERRIDE {} 106 virtual void OnFileCanReadWithoutBlocking(int /* fd */) OVERRIDE {}
106 107
107 virtual void OnFileCanWriteWithoutBlocking(int /* fd */) OVERRIDE { 108 virtual void OnFileCanWriteWithoutBlocking(int /* fd */) OVERRIDE {
108 if (socket_->waiting_connect()) { 109 if (socket_->waiting_connect()) {
109 socket_->DidCompleteConnect(); 110 socket_->DidCompleteConnect();
110 } else if (socket_->write_callback_) { 111 } else if (socket_->old_write_callback_) {
csilv 2011/12/06 21:03:18 seems like we should also check write_callback?
James Hawkins 2011/12/06 22:19:30 Done.
111 socket_->DidCompleteWrite(); 112 socket_->DidCompleteWrite();
112 } 113 }
113 } 114 }
114 115
115 private: 116 private:
116 TCPClientSocketLibevent* const socket_; 117 TCPClientSocketLibevent* const socket_;
117 118
118 DISALLOW_COPY_AND_ASSIGN(WriteWatcher); 119 DISALLOW_COPY_AND_ASSIGN(WriteWatcher);
119 }; 120 };
120 121
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 int read_buf_len_; 173 int read_buf_len_;
173 174
174 // The buffer used by OnSocketReady to retry Write requests 175 // The buffer used by OnSocketReady to retry Write requests
175 scoped_refptr<IOBuffer> write_buf_; 176 scoped_refptr<IOBuffer> write_buf_;
176 int write_buf_len_; 177 int write_buf_len_;
177 178
178 // External callback; called when read is complete. 179 // External callback; called when read is complete.
179 OldCompletionCallback* read_callback_; 180 OldCompletionCallback* read_callback_;
180 181
181 // External callback; called when write is complete. 182 // External callback; called when write is complete.
182 OldCompletionCallback* write_callback_; 183 OldCompletionCallback* old_write_callback_;
184 CompletionCallback write_callback_;
183 185
184 // The next state for the Connect() state machine. 186 // The next state for the Connect() state machine.
185 ConnectState next_connect_state_; 187 ConnectState next_connect_state_;
186 188
187 // The OS error that CONNECT_STATE_CONNECT last completed with. 189 // The OS error that CONNECT_STATE_CONNECT last completed with.
188 int connect_os_error_; 190 int connect_os_error_;
189 191
190 BoundNetLog net_log_; 192 BoundNetLog net_log_;
191 193
192 // This socket was previously disconnected and has not been re-connected. 194 // This socket was previously disconnected and has not been re-connected.
(...skipping 12 matching lines...) Expand all
205 base::TimeTicks connect_start_time_; 207 base::TimeTicks connect_start_time_;
206 base::TimeDelta connect_time_micros_; 208 base::TimeDelta connect_time_micros_;
207 int64 num_bytes_read_; 209 int64 num_bytes_read_;
208 210
209 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketLibevent); 211 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketLibevent);
210 }; 212 };
211 213
212 } // namespace net 214 } // namespace net
213 215
214 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ 216 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698