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

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

Issue 8801005: base::Bind: Convert Socket::Read. (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/ssl_server_socket_unittest.cc ('k') | net/socket/tcp_client_socket_libevent.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_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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 virtual bool UsingTCPFastOpen() const OVERRIDE; 57 virtual bool UsingTCPFastOpen() const OVERRIDE;
58 virtual int64 NumBytesRead() const OVERRIDE; 58 virtual int64 NumBytesRead() const OVERRIDE;
59 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; 59 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE;
60 60
61 // Socket implementation. 61 // Socket implementation.
62 // Multiple outstanding requests are not supported. 62 // Multiple outstanding requests are not supported.
63 // 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
64 virtual int Read(IOBuffer* buf, 64 virtual int Read(IOBuffer* buf,
65 int buf_len, 65 int buf_len,
66 OldCompletionCallback* callback) OVERRIDE; 66 OldCompletionCallback* callback) OVERRIDE;
67 virtual int Read(IOBuffer* buf,
68 int buf_len,
69 const CompletionCallback& callback) OVERRIDE;
67 virtual int Write(IOBuffer* buf, 70 virtual int Write(IOBuffer* buf,
68 int buf_len, 71 int buf_len,
69 OldCompletionCallback* callback) OVERRIDE; 72 OldCompletionCallback* callback) OVERRIDE;
70 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; 73 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE;
71 virtual bool SetSendBufferSize(int32 size) OVERRIDE; 74 virtual bool SetSendBufferSize(int32 size) OVERRIDE;
72 75
73 private: 76 private:
74 // State machine for connecting the socket. 77 // State machine for connecting the socket.
75 enum ConnectState { 78 enum ConnectState {
76 CONNECT_STATE_CONNECT, 79 CONNECT_STATE_CONNECT,
77 CONNECT_STATE_CONNECT_COMPLETE, 80 CONNECT_STATE_CONNECT_COMPLETE,
78 CONNECT_STATE_NONE, 81 CONNECT_STATE_NONE,
79 }; 82 };
80 83
81 class ReadWatcher : public MessageLoopForIO::Watcher { 84 class ReadWatcher : public MessageLoopForIO::Watcher {
82 public: 85 public:
83 explicit ReadWatcher(TCPClientSocketLibevent* socket) : socket_(socket) {} 86 explicit ReadWatcher(TCPClientSocketLibevent* socket) : socket_(socket) {}
84 87
85 // MessageLoopForIO::Watcher methods 88 // MessageLoopForIO::Watcher methods
86 89
87 virtual void OnFileCanReadWithoutBlocking(int /* fd */) OVERRIDE { 90 virtual void OnFileCanReadWithoutBlocking(int /* fd */) OVERRIDE {
88 if (socket_->read_callback_) 91 if (socket_->old_read_callback_)
89 socket_->DidCompleteRead(); 92 socket_->DidCompleteRead();
90 } 93 }
91 94
92 virtual void OnFileCanWriteWithoutBlocking(int /* fd */) OVERRIDE {} 95 virtual void OnFileCanWriteWithoutBlocking(int /* fd */) OVERRIDE {}
93 96
94 private: 97 private:
95 TCPClientSocketLibevent* const socket_; 98 TCPClientSocketLibevent* const socket_;
96 99
97 DISALLOW_COPY_AND_ASSIGN(ReadWatcher); 100 DISALLOW_COPY_AND_ASSIGN(ReadWatcher);
98 }; 101 };
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 172
170 // The buffer used by OnSocketReady to retry Read requests 173 // The buffer used by OnSocketReady to retry Read requests
171 scoped_refptr<IOBuffer> read_buf_; 174 scoped_refptr<IOBuffer> read_buf_;
172 int read_buf_len_; 175 int read_buf_len_;
173 176
174 // The buffer used by OnSocketReady to retry Write requests 177 // The buffer used by OnSocketReady to retry Write requests
175 scoped_refptr<IOBuffer> write_buf_; 178 scoped_refptr<IOBuffer> write_buf_;
176 int write_buf_len_; 179 int write_buf_len_;
177 180
178 // External callback; called when read is complete. 181 // External callback; called when read is complete.
179 OldCompletionCallback* read_callback_; 182 OldCompletionCallback* old_read_callback_;
183 CompletionCallback read_callback_;
180 184
181 // External callback; called when write is complete. 185 // External callback; called when write is complete.
182 OldCompletionCallback* old_write_callback_; 186 OldCompletionCallback* old_write_callback_;
183 CompletionCallback write_callback_; 187 CompletionCallback write_callback_;
184 188
185 // The next state for the Connect() state machine. 189 // The next state for the Connect() state machine.
186 ConnectState next_connect_state_; 190 ConnectState next_connect_state_;
187 191
188 // The OS error that CONNECT_STATE_CONNECT last completed with. 192 // The OS error that CONNECT_STATE_CONNECT last completed with.
189 int connect_os_error_; 193 int connect_os_error_;
(...skipping 16 matching lines...) Expand all
206 base::TimeTicks connect_start_time_; 210 base::TimeTicks connect_start_time_;
207 base::TimeDelta connect_time_micros_; 211 base::TimeDelta connect_time_micros_;
208 int64 num_bytes_read_; 212 int64 num_bytes_read_;
209 213
210 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketLibevent); 214 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketLibevent);
211 }; 215 };
212 216
213 } // namespace net 217 } // namespace net
214 218
215 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ 219 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_
OLDNEW
« no previous file with comments | « net/socket/ssl_server_socket_unittest.cc ('k') | net/socket/tcp_client_socket_libevent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698