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, |
|
cbentzel
2013/08/21 22:00:20
Nit: put a space back in.
hubbe
2013/08/22 23:41:02
Done.
| |
| 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 int SetTos(DiffServCodePoint dscp); | |
|
cbentzel
2013/08/21 22:00:20
Nit: SetDiffServeCodePoint
hubbe
2013/08/22 23:41:02
Done.
| |
| 157 | |
| 154 private: | 158 private: |
| 155 static const int kInvalidSocket = -1; | 159 static const int kInvalidSocket = -1; |
| 156 | 160 |
| 157 enum SocketOptions { | 161 enum SocketOptions { |
| 158 SOCKET_OPTION_REUSE_ADDRESS = 1 << 0, | 162 SOCKET_OPTION_REUSE_ADDRESS = 1 << 0, |
| 159 SOCKET_OPTION_BROADCAST = 1 << 1, | 163 SOCKET_OPTION_BROADCAST = 1 << 1, |
| 160 SOCKET_OPTION_MULTICAST_LOOP = 1 << 2 | 164 SOCKET_OPTION_MULTICAST_LOOP = 1 << 2 |
| 161 }; | 165 }; |
| 162 | 166 |
| 163 class ReadWatcher : public base::MessageLoopForIO::Watcher { | 167 class ReadWatcher : public base::MessageLoopForIO::Watcher { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 int addr_family_; | 234 int addr_family_; |
| 231 | 235 |
| 232 // Bitwise-or'd combination of SocketOptions. Specifies the set of | 236 // Bitwise-or'd combination of SocketOptions. Specifies the set of |
| 233 // options that should be applied to |socket_| before Bind(). | 237 // options that should be applied to |socket_| before Bind(). |
| 234 int socket_options_; | 238 int socket_options_; |
| 235 | 239 |
| 236 // Multicast socket options cached for SetSocketOption. | 240 // Multicast socket options cached for SetSocketOption. |
| 237 // Cannot be used after Bind(). | 241 // Cannot be used after Bind(). |
| 238 int multicast_time_to_live_; | 242 int multicast_time_to_live_; |
| 239 | 243 |
| 244 // Differentiated Services Code Point. | |
|
cbentzel
2013/08/21 22:00:20
This isn't being used.
hubbe
2013/08/22 23:41:02
Oops, fixed.
| |
| 245 DiffServCodePoint dscp_; | |
| 246 | |
| 240 // How to do source port binding, used only when UDPSocket is part of | 247 // How to do source port binding, used only when UDPSocket is part of |
| 241 // UDPClientSocket, since UDPServerSocket provides Bind. | 248 // UDPClientSocket, since UDPServerSocket provides Bind. |
| 242 DatagramSocket::BindType bind_type_; | 249 DatagramSocket::BindType bind_type_; |
| 243 | 250 |
| 244 // PRNG function for generating port numbers. | 251 // PRNG function for generating port numbers. |
| 245 RandIntCallback rand_int_cb_; | 252 RandIntCallback rand_int_cb_; |
| 246 | 253 |
| 247 // These are mutable since they're just cached copies to make | 254 // These are mutable since they're just cached copies to make |
| 248 // GetPeerAddress/GetLocalAddress smarter. | 255 // GetPeerAddress/GetLocalAddress smarter. |
| 249 mutable scoped_ptr<IPEndPoint> local_address_; | 256 mutable scoped_ptr<IPEndPoint> local_address_; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 274 CompletionCallback write_callback_; | 281 CompletionCallback write_callback_; |
| 275 | 282 |
| 276 BoundNetLog net_log_; | 283 BoundNetLog net_log_; |
| 277 | 284 |
| 278 DISALLOW_COPY_AND_ASSIGN(UDPSocketLibevent); | 285 DISALLOW_COPY_AND_ASSIGN(UDPSocketLibevent); |
| 279 }; | 286 }; |
| 280 | 287 |
| 281 } // namespace net | 288 } // namespace net |
| 282 | 289 |
| 283 #endif // NET_UDP_UDP_SOCKET_LIBEVENT_H_ | 290 #endif // NET_UDP_UDP_SOCKET_LIBEVENT_H_ |
| OLD | NEW |