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