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

Side by Side Diff: net/udp/udp_socket_libevent.h

Issue 8889036: Revert 113699 - base::Bind: Convert Socket::Write. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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/udp/udp_client_socket.cc ('k') | net/udp/udp_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_UDP_UDP_SOCKET_LIBEVENT_H_ 5 #ifndef NET_UDP_UDP_SOCKET_LIBEVENT_H_
6 #define NET_UDP_UDP_SOCKET_LIBEVENT_H_ 6 #define NET_UDP_UDP_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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Read from the socket. 54 // Read from the socket.
55 // Only usable from the client-side of a UDP socket, after the socket 55 // Only usable from the client-side of a UDP socket, after the socket
56 // has been connected. 56 // has been connected.
57 int Read(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); 57 int Read(IOBuffer* buf, int buf_len, OldCompletionCallback* callback);
58 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); 58 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback);
59 59
60 // Write to the socket. 60 // Write to the socket.
61 // Only usable from the client-side of a UDP socket, after the socket 61 // Only usable from the client-side of a UDP socket, after the socket
62 // has been connected. 62 // has been connected.
63 int Write(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); 63 int Write(IOBuffer* buf, int buf_len, OldCompletionCallback* callback);
64 int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback);
65 64
66 // Read from a socket and receive sender address information. 65 // Read from a socket and receive sender address information.
67 // |buf| is the buffer to read data into. 66 // |buf| is the buffer to read data into.
68 // |buf_len| is the maximum amount of data to read. 67 // |buf_len| is the maximum amount of data to read.
69 // |address| is a buffer provided by the caller for receiving the sender 68 // |address| is a buffer provided by the caller for receiving the sender
70 // address information about the received data. This buffer must be kept 69 // address information about the received data. This buffer must be kept
71 // alive by the caller until the callback is placed. 70 // alive by the caller until the callback is placed.
72 // |address_length| is a ptr to the length of the |address| buffer. This 71 // |address_length| is a ptr to the length of the |address| buffer. This
73 // is an input parameter containing the maximum size |address| can hold 72 // is an input parameter containing the maximum size |address| can hold
74 // and also an output parameter for the size of |address| upon completion. 73 // and also an output parameter for the size of |address| upon completion.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 133
135 class WriteWatcher : public MessageLoopForIO::Watcher { 134 class WriteWatcher : public MessageLoopForIO::Watcher {
136 public: 135 public:
137 explicit WriteWatcher(UDPSocketLibevent* socket) : socket_(socket) {} 136 explicit WriteWatcher(UDPSocketLibevent* socket) : socket_(socket) {}
138 137
139 // MessageLoopForIO::Watcher methods 138 // MessageLoopForIO::Watcher methods
140 139
141 virtual void OnFileCanReadWithoutBlocking(int /* fd */) OVERRIDE {} 140 virtual void OnFileCanReadWithoutBlocking(int /* fd */) OVERRIDE {}
142 141
143 virtual void OnFileCanWriteWithoutBlocking(int /* fd */) OVERRIDE { 142 virtual void OnFileCanWriteWithoutBlocking(int /* fd */) OVERRIDE {
144 if (socket_->old_write_callback_) 143 if (socket_->write_callback_)
145 socket_->DidCompleteWrite(); 144 socket_->DidCompleteWrite();
146 } 145 }
147 146
148 private: 147 private:
149 UDPSocketLibevent* const socket_; 148 UDPSocketLibevent* const socket_;
150 149
151 DISALLOW_COPY_AND_ASSIGN(WriteWatcher); 150 DISALLOW_COPY_AND_ASSIGN(WriteWatcher);
152 }; 151 };
153 152
154 void DoReadCallback(int rv); 153 void DoReadCallback(int rv);
(...skipping 12 matching lines...) Expand all
167 // Returns the OS error code (or 0 on success). 166 // Returns the OS error code (or 0 on success).
168 int CreateSocket(const IPEndPoint& address); 167 int CreateSocket(const IPEndPoint& address);
169 168
170 // Same as SendTo(), except that address is passed by pointer 169 // Same as SendTo(), except that address is passed by pointer
171 // instead of by reference. It is called from Write() with |address| 170 // instead of by reference. It is called from Write() with |address|
172 // set to NULL. 171 // set to NULL.
173 int SendToOrWrite(IOBuffer* buf, 172 int SendToOrWrite(IOBuffer* buf,
174 int buf_len, 173 int buf_len,
175 const IPEndPoint* address, 174 const IPEndPoint* address,
176 OldCompletionCallback* callback); 175 OldCompletionCallback* callback);
177 int SendToOrWrite(IOBuffer* buf,
178 int buf_len,
179 const IPEndPoint* address,
180 const CompletionCallback& callback);
181 176
182 int InternalConnect(const IPEndPoint& address); 177 int InternalConnect(const IPEndPoint& address);
183 int InternalRecvFrom(IOBuffer* buf, int buf_len, IPEndPoint* address); 178 int InternalRecvFrom(IOBuffer* buf, int buf_len, IPEndPoint* address);
184 int InternalSendTo(IOBuffer* buf, int buf_len, const IPEndPoint* address); 179 int InternalSendTo(IOBuffer* buf, int buf_len, const IPEndPoint* address);
185 180
186 int DoBind(const IPEndPoint& address); 181 int DoBind(const IPEndPoint& address);
187 int RandomBind(const IPEndPoint& address); 182 int RandomBind(const IPEndPoint& address);
188 183
189 int socket_; 184 int socket_;
190 185
(...skipping 25 matching lines...) Expand all
216 // The buffer used by InternalWrite() to retry Write requests 211 // The buffer used by InternalWrite() to retry Write requests
217 scoped_refptr<IOBuffer> write_buf_; 212 scoped_refptr<IOBuffer> write_buf_;
218 int write_buf_len_; 213 int write_buf_len_;
219 scoped_ptr<IPEndPoint> send_to_address_; 214 scoped_ptr<IPEndPoint> send_to_address_;
220 215
221 // External callback; called when read is complete. 216 // External callback; called when read is complete.
222 OldCompletionCallback* old_read_callback_; 217 OldCompletionCallback* old_read_callback_;
223 CompletionCallback read_callback_; 218 CompletionCallback read_callback_;
224 219
225 // External callback; called when write is complete. 220 // External callback; called when write is complete.
226 OldCompletionCallback* old_write_callback_; 221 OldCompletionCallback* write_callback_;
227 CompletionCallback write_callback_;
228 222
229 BoundNetLog net_log_; 223 BoundNetLog net_log_;
230 224
231 DISALLOW_COPY_AND_ASSIGN(UDPSocketLibevent); 225 DISALLOW_COPY_AND_ASSIGN(UDPSocketLibevent);
232 }; 226 };
233 227
234 } // namespace net 228 } // namespace net
235 229
236 #endif // NET_UDP_UDP_SOCKET_LIBEVENT_H_ 230 #endif // NET_UDP_UDP_SOCKET_LIBEVENT_H_
OLDNEW
« no previous file with comments | « net/udp/udp_client_socket.cc ('k') | net/udp/udp_socket_libevent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698