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_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 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/threading/non_thread_safe.h" | 11 #include "base/threading/non_thread_safe.h" |
| 12 #include "net/base/completion_callback.h" | 12 #include "net/base/completion_callback.h" |
| 13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 14 #include "net/base/ip_endpoint.h" | 14 #include "net/base/ip_endpoint.h" |
| 15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
| 16 #include "net/base/net_log.h" | 16 #include "net/base/net_log.h" |
| 17 #include "net/base/rand_callback.h" | 17 #include "net/base/rand_callback.h" |
| 18 #include "net/udp/datagram_socket.h" | 18 #include "net/udp/datagram_socket.h" |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 | 21 |
| 22 class NET_EXPORT UDPSocketLibevent : public base::NonThreadSafe { | 22 class NET_EXPORT UDPSocketLibevent : public base::NonThreadSafe { |
| 23 public: | 23 public: |
| 24 UDPSocketLibevent(DatagramSocket::BindType bind_type, | 24 UDPSocketLibevent(DatagramSocket::BindType bind_type, |
| 25 const RandIntCallback& rand_int_cb, | 25 const RandIntCallback& rand_int_cb, |
| 26 net::NetLog* net_log, | 26 net::NetLog* net_log, |
| 27 const net::NetLog::Source& source); | 27 const net::NetLog::Source& source); |
| 28 virtual ~UDPSocketLibevent(); | 28 virtual ~UDPSocketLibevent(); |
| 29 | 29 |
| 30 // Connect the socket to connect with a certain |address|. | 30 // Connect the socket to connect with a certain |address|. |
| 31 // Returns a net error code. | 31 // Returns a net error code. |
| 32 int Connect(const IPEndPoint& address); | 32 int Connect(const IPEndPoint& address); |
| 33 | 33 |
| 34 // Bind the address/port for this socket to |address|. This is generally | 34 // Bind the address/port for this socket to |address|. This is generally |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 // Note: the behavior of |SetMulticastLoopbackMode| is slightly | 144 // Note: the behavior of |SetMulticastLoopbackMode| is slightly |
| 145 // different between Windows and Unix-like systems. The inconsistency only | 145 // different between Windows and Unix-like systems. The inconsistency only |
| 146 // happens when there are more than one applications on the same host | 146 // happens when there are more than one applications on the same host |
| 147 // joined to the same multicast group while having different settings on | 147 // joined to the same multicast group while having different settings on |
| 148 // multicast loopback mode. On Windows, the applications with loopback off | 148 // multicast loopback mode. On Windows, the applications with loopback off |
| 149 // will not RECEIVE the loopback packets; while on Unix-like systems, the | 149 // will not RECEIVE the loopback packets; while on Unix-like systems, the |
| 150 // applications with loopback off will not SEND the loopback packets to | 150 // applications with loopback off will not SEND the loopback packets to |
| 151 // other applications on the same host. See MSDN: http://goo.gl/6vqbj | 151 // other applications on the same host. See MSDN: http://goo.gl/6vqbj |
| 152 int SetMulticastLoopbackMode(bool loopback); | 152 int SetMulticastLoopbackMode(bool loopback); |
| 153 | 153 |
| 154 // Set the differentiated services flags on outgoing packets. May not | |
| 155 // do anything on some platforms. | |
| 156 // Some useful values: | |
| 157 // 46 (Expedited Forwarding) for telephony | |
| 158 // 34 (AF4) for interactive multimedia | |
| 159 // 26 (AF3) multimedia streaming | |
| 160 // 10 (AF1) bulk transfers | |
| 161 int SetToS(int dscp); | |
|
Alpha Left Google
2013/08/07 00:45:16
Should we provide a enum include file that lists a
hubbe
2013/08/07 17:20:35
Done.
| |
| 162 | |
| 154 private: | 163 private: |
| 155 static const int kInvalidSocket = -1; | 164 static const int kInvalidSocket = -1; |
| 156 | 165 |
| 157 enum SocketOptions { | 166 enum SocketOptions { |
| 158 SOCKET_OPTION_REUSE_ADDRESS = 1 << 0, | 167 SOCKET_OPTION_REUSE_ADDRESS = 1 << 0, |
| 159 SOCKET_OPTION_BROADCAST = 1 << 1, | 168 SOCKET_OPTION_BROADCAST = 1 << 1, |
| 160 SOCKET_OPTION_MULTICAST_LOOP = 1 << 2 | 169 SOCKET_OPTION_MULTICAST_LOOP = 1 << 2 |
| 161 }; | 170 }; |
| 162 | 171 |
| 163 class ReadWatcher : public base::MessageLoopForIO::Watcher { | 172 class ReadWatcher : public base::MessageLoopForIO::Watcher { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 int DoBind(const IPEndPoint& address); | 235 int DoBind(const IPEndPoint& address); |
| 227 int RandomBind(const IPEndPoint& address); | 236 int RandomBind(const IPEndPoint& address); |
| 228 | 237 |
| 229 int socket_; | 238 int socket_; |
| 230 int addr_family_; | 239 int addr_family_; |
| 231 | 240 |
| 232 // Bitwise-or'd combination of SocketOptions. Specifies the set of | 241 // Bitwise-or'd combination of SocketOptions. Specifies the set of |
| 233 // options that should be applied to |socket_| before Bind(). | 242 // options that should be applied to |socket_| before Bind(). |
| 234 int socket_options_; | 243 int socket_options_; |
| 235 | 244 |
| 245 // Differentiated Services Code Point. | |
| 246 int dscp_; | |
| 247 | |
| 236 // Multicast socket options cached for SetSocketOption. | 248 // Multicast socket options cached for SetSocketOption. |
| 237 // Cannot be used after Bind(). | 249 // Cannot be used after Bind(). |
| 238 int multicast_time_to_live_; | 250 int multicast_time_to_live_; |
| 239 | 251 |
| 240 // How to do source port binding, used only when UDPSocket is part of | 252 // How to do source port binding, used only when UDPSocket is part of |
| 241 // UDPClientSocket, since UDPServerSocket provides Bind. | 253 // UDPClientSocket, since UDPServerSocket provides Bind. |
| 242 DatagramSocket::BindType bind_type_; | 254 DatagramSocket::BindType bind_type_; |
| 243 | 255 |
| 244 // PRNG function for generating port numbers. | 256 // PRNG function for generating port numbers. |
| 245 RandIntCallback rand_int_cb_; | 257 RandIntCallback rand_int_cb_; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 274 CompletionCallback write_callback_; | 286 CompletionCallback write_callback_; |
| 275 | 287 |
| 276 BoundNetLog net_log_; | 288 BoundNetLog net_log_; |
| 277 | 289 |
| 278 DISALLOW_COPY_AND_ASSIGN(UDPSocketLibevent); | 290 DISALLOW_COPY_AND_ASSIGN(UDPSocketLibevent); |
| 279 }; | 291 }; |
| 280 | 292 |
| 281 } // namespace net | 293 } // namespace net |
| 282 | 294 |
| 283 #endif // NET_UDP_UDP_SOCKET_LIBEVENT_H_ | 295 #endif // NET_UDP_UDP_SOCKET_LIBEVENT_H_ |
| OLD | NEW |