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_SOCKET_UDP_CLIENT_SOCKET_H_ | 5 #ifndef NET_SOCKET_UDP_CLIENT_SOCKET_H_ |
6 #define NET_SOCKET_UDP_CLIENT_SOCKET_H_ | 6 #define NET_SOCKET_UDP_CLIENT_SOCKET_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "net/base/rand_callback.h" | 10 #include "net/base/rand_callback.h" |
11 #include "net/log/net_log.h" | 11 #include "net/log/net_log.h" |
12 #include "net/udp/datagram_client_socket.h" | 12 #include "net/udp/datagram_client_socket.h" |
13 #include "net/udp/udp_socket.h" | 13 #include "net/udp/udp_socket.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 class BoundNetLog; | 17 class BoundNetLog; |
18 | 18 |
19 // A client socket that uses UDP as the transport layer. | 19 // A client socket that uses UDP as the transport layer. |
20 class NET_EXPORT_PRIVATE UDPClientSocket : public DatagramClientSocket { | 20 class NET_EXPORT_PRIVATE UDPClientSocket : public DatagramClientSocket { |
21 public: | 21 public: |
22 UDPClientSocket(DatagramSocket::BindType bind_type, | 22 UDPClientSocket(DatagramSocket::BindType bind_type, |
23 const RandIntCallback& rand_int_cb, | 23 const RandIntCallback& rand_int_cb, |
24 net::NetLog* net_log, | 24 net::NetLog* net_log, |
25 const net::NetLog::Source& source); | 25 const net::NetLog::Source& source); |
26 ~UDPClientSocket() override; | 26 ~UDPClientSocket() override; |
27 | 27 |
28 // DatagramClientSocket implementation. | 28 // DatagramClientSocket implementation. |
29 int BindToNetwork(NetworkChangeNotifier::NetworkHandle network) override; | 29 int BindToNetwork(NetworkChangeNotifier::NetworkHandle network) override; |
| 30 int BindToDefaultNetwork() override; |
| 31 NetworkChangeNotifier::NetworkHandle GetBoundNetwork() override; |
30 int Connect(const IPEndPoint& address) override; | 32 int Connect(const IPEndPoint& address) override; |
31 int Read(IOBuffer* buf, | 33 int Read(IOBuffer* buf, |
32 int buf_len, | 34 int buf_len, |
33 const CompletionCallback& callback) override; | 35 const CompletionCallback& callback) override; |
34 int Write(IOBuffer* buf, | 36 int Write(IOBuffer* buf, |
35 int buf_len, | 37 int buf_len, |
36 const CompletionCallback& callback) override; | 38 const CompletionCallback& callback) override; |
37 void Close() override; | 39 void Close() override; |
38 int GetPeerAddress(IPEndPoint* address) const override; | 40 int GetPeerAddress(IPEndPoint* address) const override; |
39 int GetLocalAddress(IPEndPoint* address) const override; | 41 int GetLocalAddress(IPEndPoint* address) const override; |
40 int SetReceiveBufferSize(int32_t size) override; | 42 int SetReceiveBufferSize(int32_t size) override; |
41 int SetSendBufferSize(int32_t size) override; | 43 int SetSendBufferSize(int32_t size) override; |
42 const BoundNetLog& NetLog() const override; | 44 const BoundNetLog& NetLog() const override; |
43 | 45 |
44 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
45 // Switch to use non-blocking IO. Must be called right after construction and | 47 // Switch to use non-blocking IO. Must be called right after construction and |
46 // before other calls. | 48 // before other calls. |
47 void UseNonBlockingIO(); | 49 void UseNonBlockingIO(); |
48 #endif | 50 #endif |
49 | 51 |
50 private: | 52 private: |
51 UDPSocket socket_; | 53 UDPSocket socket_; |
| 54 NetworkChangeNotifier::NetworkHandle network_; |
52 DISALLOW_COPY_AND_ASSIGN(UDPClientSocket); | 55 DISALLOW_COPY_AND_ASSIGN(UDPClientSocket); |
53 }; | 56 }; |
54 | 57 |
55 } // namespace net | 58 } // namespace net |
56 | 59 |
57 #endif // NET_SOCKET_UDP_CLIENT_SOCKET_H_ | 60 #endif // NET_SOCKET_UDP_CLIENT_SOCKET_H_ |
OLD | NEW |