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

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

Issue 690903002: Remove timing limitation of SetOption invocation for PPAPI sockets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include <qos2.h> 8 #include <qos2.h>
9 #include <winsock2.h> 9 #include <winsock2.h>
10 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 // Set the send buffer size (in bytes) for the socket. 102 // Set the send buffer size (in bytes) for the socket.
103 // Returns a net error code. 103 // Returns a net error code.
104 int SetSendBufferSize(int32 size); 104 int SetSendBufferSize(int32 size);
105 105
106 // Returns true if the socket is already connected or bound. 106 // Returns true if the socket is already connected or bound.
107 bool is_connected() const { return socket_ != INVALID_SOCKET; } 107 bool is_connected() const { return socket_ != INVALID_SOCKET; }
108 108
109 const BoundNetLog& NetLog() const { return net_log_; } 109 const BoundNetLog& NetLog() const { return net_log_; }
110 110
111 // Sets corresponding flags in |socket_options_| to allow the socket 111 // Allows the socket to share the local address to which the socket will
112 // to share the local address to which the socket will be bound with 112 // be bound with other processes.
113 // other processes. Should be called before Bind(). 113 // Returns a net error code.
114 void AllowAddressReuse(); 114 int AllowAddressReuse();
115 115
116 // Sets corresponding flags in |socket_options_| to allow sending 116 // Disallows the socket to share the local address to which the socket will
117 // and receiving packets to and from broadcast addresses. Should be 117 // be bound with other processes.
118 // called before Bind(). 118 // Returns a net error code.
119 void AllowBroadcast(); 119 int DisallowAddressReuse();
120
121 // Allows sending and receiving packets to and from broadcast addresses.
122 // Returns a net error code.
123 int AllowBroadcast();
124
125 // Disallows sending and receiving packets to and from broadcast addresses.
126 // Returns a net error code.
127 int DisallowBroadcast();
120 128
121 // Join the multicast group. 129 // Join the multicast group.
122 // |group_address| is the group address to join, could be either 130 // |group_address| is the group address to join, could be either
123 // an IPv4 or IPv6 address. 131 // an IPv4 or IPv6 address.
124 // Return a network error code. 132 // Return a network error code.
125 int JoinGroup(const IPAddressNumber& group_address) const; 133 int JoinGroup(const IPAddressNumber& group_address) const;
126 134
127 // Leave the multicast group. 135 // Leave the multicast group.
128 // |group_address| is the group address to leave, could be either 136 // |group_address| is the group address to leave, could be either
129 // an IPv4 or IPv6 address. If the socket hasn't joined the group, 137 // an IPv4 or IPv6 address. If the socket hasn't joined the group,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // do anything on some platforms. 172 // do anything on some platforms.
165 int SetDiffServCodePoint(DiffServCodePoint dscp); 173 int SetDiffServCodePoint(DiffServCodePoint dscp);
166 174
167 // Resets the thread to be used for thread-safety checks. 175 // Resets the thread to be used for thread-safety checks.
168 void DetachFromThread(); 176 void DetachFromThread();
169 177
170 private: 178 private:
171 enum SocketOptions { 179 enum SocketOptions {
172 SOCKET_OPTION_REUSE_ADDRESS = 1 << 0, 180 SOCKET_OPTION_REUSE_ADDRESS = 1 << 0,
173 SOCKET_OPTION_BROADCAST = 1 << 1, 181 SOCKET_OPTION_BROADCAST = 1 << 1,
174 SOCKET_OPTION_MULTICAST_LOOP = 1 << 2 182 SOCKET_OPTION_MULTICAST_LOOP = 1 << 2,
183 SOCKET_OPTION_RCVBUF_SIZE = 1 << 3,
184 SOCKET_OPTION_SNDBUF_SIZE = 1 << 4
175 }; 185 };
176 186
177 class Core; 187 class Core;
178 188
179 void DoReadCallback(int rv); 189 void DoReadCallback(int rv);
180 void DoWriteCallback(int rv); 190 void DoWriteCallback(int rv);
181 void DidCompleteRead(); 191 void DidCompleteRead();
182 void DidCompleteWrite(); 192 void DidCompleteWrite();
183 193
184 // Handles stats and logging. |result| is the number of bytes transferred, on 194 // Handles stats and logging. |result| is the number of bytes transferred, on
(...skipping 13 matching lines...) Expand all
198 const IPEndPoint* address, 208 const IPEndPoint* address,
199 const CompletionCallback& callback); 209 const CompletionCallback& callback);
200 210
201 int InternalConnect(const IPEndPoint& address); 211 int InternalConnect(const IPEndPoint& address);
202 int InternalRecvFrom(IOBuffer* buf, int buf_len, IPEndPoint* address); 212 int InternalRecvFrom(IOBuffer* buf, int buf_len, IPEndPoint* address);
203 int InternalSendTo(IOBuffer* buf, int buf_len, const IPEndPoint* address); 213 int InternalSendTo(IOBuffer* buf, int buf_len, const IPEndPoint* address);
204 214
205 // Applies |socket_options_| to |socket_|. Should be called before 215 // Applies |socket_options_| to |socket_|. Should be called before
206 // Bind(). 216 // Bind().
207 int SetSocketOptions(); 217 int SetSocketOptions();
218 int SetAddressReuseInternal(bool value);
219 int SetBroadcastInternal(bool value);
220 int SetReceiveBufferSizeInternal(int32 size);
221 int SetSendBufferSizeInternal(int32 size);
222
208 int DoBind(const IPEndPoint& address); 223 int DoBind(const IPEndPoint& address);
209 // Binds to a random port on |address|. 224 // Binds to a random port on |address|.
210 int RandomBind(const IPAddressNumber& address); 225 int RandomBind(const IPAddressNumber& address);
211 226
212 // Attempts to convert the data in |recv_addr_storage_| and |recv_addr_len_| 227 // Attempts to convert the data in |recv_addr_storage_| and |recv_addr_len_|
213 // to an IPEndPoint and writes it to |address|. Returns true on success. 228 // to an IPEndPoint and writes it to |address|. Returns true on success.
214 bool ReceiveAddressToIPEndpoint(IPEndPoint* address) const; 229 bool ReceiveAddressToIPEndpoint(IPEndPoint* address) const;
215 230
216 SOCKET socket_; 231 SOCKET socket_;
217 int addr_family_; 232 int addr_family_;
218 233
219 // Bitwise-or'd combination of SocketOptions. Specifies the set of 234 // Bitwise-or'd combination of SocketOptions. Specifies the set of
220 // options that should be applied to |socket_| before Bind(). 235 // options that should be applied to |socket_| before Bind().
221 int socket_options_; 236 int socket_options_;
222 237
238 // Buffer size set before Bind(). This should be applied
239 // in SetSocketOptions().
240 int32 rcvbuf_size_;
241 int32 sndbuf_size_;
242
223 // Multicast interface. 243 // Multicast interface.
224 uint32 multicast_interface_; 244 uint32 multicast_interface_;
225 245
226 // Multicast socket options cached for SetSocketOption. 246 // Multicast socket options cached for SetSocketOption.
227 // Cannot be used after Bind(). 247 // Cannot be used after Bind().
228 int multicast_time_to_live_; 248 int multicast_time_to_live_;
229 249
230 // How to do source port binding, used only when UDPSocket is part of 250 // How to do source port binding, used only when UDPSocket is part of
231 // UDPClientSocket, since UDPServerSocket provides Bind. 251 // UDPClientSocket, since UDPServerSocket provides Bind.
232 DatagramSocket::BindType bind_type_; 252 DatagramSocket::BindType bind_type_;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 SetFlowFn set_flow_func_; 338 SetFlowFn set_flow_func_;
319 339
320 FRIEND_TEST_ALL_PREFIXES(UDPSocketTest, SetDSCPFake); 340 FRIEND_TEST_ALL_PREFIXES(UDPSocketTest, SetDSCPFake);
321 DISALLOW_COPY_AND_ASSIGN(QwaveAPI); 341 DISALLOW_COPY_AND_ASSIGN(QwaveAPI);
322 }; 342 };
323 343
324 344
325 } // namespace net 345 } // namespace net
326 346
327 #endif // NET_UDP_UDP_SOCKET_WIN_H_ 347 #endif // NET_UDP_UDP_SOCKET_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698