Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <winsock2.h> | 8 #include <winsock2.h> |
| 9 | 9 |
| 10 #include "base/hash_tables.h" | |
| 10 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
| 13 #include "base/win/object_watcher.h" | 14 #include "base/win/object_watcher.h" |
| 14 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
| 15 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
| 16 #include "net/base/rand_callback.h" | 17 #include "net/base/rand_callback.h" |
| 17 #include "net/base/ip_endpoint.h" | 18 #include "net/base/ip_endpoint.h" |
| 18 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
| 19 #include "net/base/net_log.h" | 20 #include "net/base/net_log.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 // Sets corresponding flags in |socket_options_| to allow the socket | 109 // Sets corresponding flags in |socket_options_| to allow the socket |
| 109 // to share the local address to which the socket will be bound with | 110 // to share the local address to which the socket will be bound with |
| 110 // other processes. Should be called before Bind(). | 111 // other processes. Should be called before Bind(). |
| 111 void AllowAddressReuse(); | 112 void AllowAddressReuse(); |
| 112 | 113 |
| 113 // Sets corresponding flags in |socket_options_| to allow sending | 114 // Sets corresponding flags in |socket_options_| to allow sending |
| 114 // and receiving packets to and from broadcast addresses. Should be | 115 // and receiving packets to and from broadcast addresses. Should be |
| 115 // called before Bind(). | 116 // called before Bind(). |
| 116 void AllowBroadcast(); | 117 void AllowBroadcast(); |
| 117 | 118 |
| 119 int JoinGroup(const net::IPAddressNumber& group_address) const; | |
|
scheib
2013/04/02 18:25:17
Comment these member functions.
Bei Zhang
2013/04/05 00:38:59
Done.
| |
| 120 | |
| 121 int LeaveGroup(const net::IPAddressNumber& group_address) const; | |
| 122 | |
| 123 int SetMulticastTimeToLive(int timeToLive); | |
| 124 | |
| 125 int SetMulticastLoopbackMode(bool loopback); | |
| 126 | |
| 118 private: | 127 private: |
| 119 enum SocketOptions { | 128 enum SocketOptions { |
| 120 SOCKET_OPTION_REUSE_ADDRESS = 1 << 0, | 129 SOCKET_OPTION_REUSE_ADDRESS = 1 << 0, |
| 121 SOCKET_OPTION_BROADCAST = 1 << 1 | 130 SOCKET_OPTION_BROADCAST = 1 << 1 |
| 122 }; | 131 }; |
| 123 | 132 |
| 124 class Core; | 133 class Core; |
| 125 | 134 |
| 126 void DoReadCallback(int rv); | 135 void DoReadCallback(int rv); |
| 127 void DoWriteCallback(int rv); | 136 void DoWriteCallback(int rv); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 153 // Bind(). | 162 // Bind(). |
| 154 int SetSocketOptions(); | 163 int SetSocketOptions(); |
| 155 int DoBind(const IPEndPoint& address); | 164 int DoBind(const IPEndPoint& address); |
| 156 int RandomBind(const IPEndPoint& address); | 165 int RandomBind(const IPEndPoint& address); |
| 157 | 166 |
| 158 // 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_| |
| 159 // 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. |
| 160 bool ReceiveAddressToIPEndpoint(IPEndPoint* address) const; | 169 bool ReceiveAddressToIPEndpoint(IPEndPoint* address) const; |
| 161 | 170 |
| 162 SOCKET socket_; | 171 SOCKET socket_; |
| 172 int sock_addr_family_; | |
| 163 | 173 |
| 164 // Bitwise-or'd combination of SocketOptions. Specifies the set of | 174 // Bitwise-or'd combination of SocketOptions. Specifies the set of |
| 165 // options that should be applied to |socket_| before Bind(). | 175 // options that should be applied to |socket_| before Bind(). |
| 166 int socket_options_; | 176 int socket_options_; |
| 167 | 177 |
| 168 // How to do source port binding, used only when UDPSocket is part of | 178 // How to do source port binding, used only when UDPSocket is part of |
| 169 // UDPClientSocket, since UDPServerSocket provides Bind. | 179 // UDPClientSocket, since UDPServerSocket provides Bind. |
| 170 DatagramSocket::BindType bind_type_; | 180 DatagramSocket::BindType bind_type_; |
| 171 | 181 |
| 172 // PRNG function for generating port numbers. | 182 // PRNG function for generating port numbers. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 195 CompletionCallback write_callback_; | 205 CompletionCallback write_callback_; |
| 196 | 206 |
| 197 BoundNetLog net_log_; | 207 BoundNetLog net_log_; |
| 198 | 208 |
| 199 DISALLOW_COPY_AND_ASSIGN(UDPSocketWin); | 209 DISALLOW_COPY_AND_ASSIGN(UDPSocketWin); |
| 200 }; | 210 }; |
| 201 | 211 |
| 202 } // namespace net | 212 } // namespace net |
| 203 | 213 |
| 204 #endif // NET_UDP_UDP_SOCKET_WIN_H_ | 214 #endif // NET_UDP_UDP_SOCKET_WIN_H_ |
| OLD | NEW |