OLD | NEW |
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_WIN_H_ | 5 #ifndef NET_UDP_UDP_SOCKET_WIN_H_ |
6 #define NET_UDP_UDP_SOCKET_WIN_H_ | 6 #define NET_UDP_UDP_SOCKET_WIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <winsock2.h> | 9 #include <winsock2.h> |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // Read from the socket. | 55 // Read from the socket. |
56 // Only usable from the client-side of a UDP socket, after the socket | 56 // Only usable from the client-side of a UDP socket, after the socket |
57 // has been connected. | 57 // has been connected. |
58 int Read(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); | 58 int Read(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); |
59 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); | 59 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
60 | 60 |
61 // Write to the socket. | 61 // Write to the socket. |
62 // Only usable from the client-side of a UDP socket, after the socket | 62 // Only usable from the client-side of a UDP socket, after the socket |
63 // has been connected. | 63 // has been connected. |
64 int Write(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); | 64 int Write(IOBuffer* buf, int buf_len, OldCompletionCallback* callback); |
| 65 int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
65 | 66 |
66 // Read from a socket and receive sender address information. | 67 // Read from a socket and receive sender address information. |
67 // |buf| is the buffer to read data into. | 68 // |buf| is the buffer to read data into. |
68 // |buf_len| is the maximum amount of data to read. | 69 // |buf_len| is the maximum amount of data to read. |
69 // |address| is a buffer provided by the caller for receiving the sender | 70 // |address| is a buffer provided by the caller for receiving the sender |
70 // address information about the received data. This buffer must be kept | 71 // address information about the received data. This buffer must be kept |
71 // alive by the caller until the callback is placed. | 72 // alive by the caller until the callback is placed. |
72 // |address_length| is a ptr to the length of the |address| buffer. This | 73 // |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 | 74 // is an input parameter containing the maximum size |address| can hold |
74 // and also an output parameter for the size of |address| upon completion. | 75 // and also an output parameter for the size of |address| upon completion. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // Returns the OS error code (or 0 on success). | 150 // Returns the OS error code (or 0 on success). |
150 int CreateSocket(const IPEndPoint& address); | 151 int CreateSocket(const IPEndPoint& address); |
151 | 152 |
152 // Same as SendTo(), except that address is passed by pointer | 153 // Same as SendTo(), except that address is passed by pointer |
153 // instead of by reference. It is called from Write() with |address| | 154 // instead of by reference. It is called from Write() with |address| |
154 // set to NULL. | 155 // set to NULL. |
155 int SendToOrWrite(IOBuffer* buf, | 156 int SendToOrWrite(IOBuffer* buf, |
156 int buf_len, | 157 int buf_len, |
157 const IPEndPoint* address, | 158 const IPEndPoint* address, |
158 OldCompletionCallback* callback); | 159 OldCompletionCallback* callback); |
| 160 int SendToOrWrite(IOBuffer* buf, |
| 161 int buf_len, |
| 162 const IPEndPoint* address, |
| 163 const CompletionCallback& callback); |
159 | 164 |
160 int InternalConnect(const IPEndPoint& address); | 165 int InternalConnect(const IPEndPoint& address); |
161 int InternalRecvFrom(IOBuffer* buf, int buf_len, IPEndPoint* address); | 166 int InternalRecvFrom(IOBuffer* buf, int buf_len, IPEndPoint* address); |
162 int InternalSendTo(IOBuffer* buf, int buf_len, const IPEndPoint* address); | 167 int InternalSendTo(IOBuffer* buf, int buf_len, const IPEndPoint* address); |
163 | 168 |
164 int DoBind(const IPEndPoint& address); | 169 int DoBind(const IPEndPoint& address); |
165 int RandomBind(const IPEndPoint& address); | 170 int RandomBind(const IPEndPoint& address); |
166 | 171 |
167 // Attempts to convert the data in |recv_addr_storage_| and |recv_addr_len_| | 172 // Attempts to convert the data in |recv_addr_storage_| and |recv_addr_len_| |
168 // to an IPEndPoint and writes it to |address|. Returns true on success. | 173 // to an IPEndPoint and writes it to |address|. Returns true on success. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 scoped_ptr<IPEndPoint> send_to_address_; | 210 scoped_ptr<IPEndPoint> send_to_address_; |
206 | 211 |
207 // The buffer used by InternalWrite() to retry Write requests | 212 // The buffer used by InternalWrite() to retry Write requests |
208 scoped_refptr<IOBuffer> write_iobuffer_; | 213 scoped_refptr<IOBuffer> write_iobuffer_; |
209 | 214 |
210 // External callback; called when read is complete. | 215 // External callback; called when read is complete. |
211 OldCompletionCallback* old_read_callback_; | 216 OldCompletionCallback* old_read_callback_; |
212 CompletionCallback read_callback_; | 217 CompletionCallback read_callback_; |
213 | 218 |
214 // External callback; called when write is complete. | 219 // External callback; called when write is complete. |
215 OldCompletionCallback* write_callback_; | 220 OldCompletionCallback* old_write_callback_; |
| 221 CompletionCallback write_callback_; |
216 | 222 |
217 BoundNetLog net_log_; | 223 BoundNetLog net_log_; |
218 | 224 |
219 DISALLOW_COPY_AND_ASSIGN(UDPSocketWin); | 225 DISALLOW_COPY_AND_ASSIGN(UDPSocketWin); |
220 }; | 226 }; |
221 | 227 |
222 } // namespace net | 228 } // namespace net |
223 | 229 |
224 #endif // NET_UDP_UDP_SOCKET_WIN_H_ | 230 #endif // NET_UDP_UDP_SOCKET_WIN_H_ |
OLD | NEW |