| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MOJO_SERVICES_NETWORK_UDP_SOCKET_IMPL_H_ | 5 #ifndef MOJO_SERVICES_NETWORK_UDP_SOCKET_IMPL_H_ |
| 6 #define MOJO_SERVICES_NETWORK_UDP_SOCKET_IMPL_H_ | 6 #define MOJO_SERVICES_NETWORK_UDP_SOCKET_IMPL_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "mojo/public/cpp/bindings/interface_impl.h" | 12 #include "mojo/public/cpp/bindings/interface_impl.h" |
| 13 #include "mojo/services/public/interfaces/network/udp_socket.mojom.h" | 13 #include "mojo/services/public/interfaces/network/udp_socket.mojom.h" |
| 14 #include "net/base/ip_endpoint.h" | 14 #include "net/base/ip_endpoint.h" |
| 15 #include "net/udp/udp_server_socket.h" | 15 #include "net/udp/udp_server_socket.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 class IOBuffer; | 18 class IOBuffer; |
| 19 class IOBufferWithSize; | 19 class IOBufferWithSize; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace mojo { | 22 namespace mojo { |
| 23 | 23 |
| 24 class UDPSocketImpl : public InterfaceImpl<UDPSocket> { | 24 class UDPSocketImpl : public InterfaceImpl<UDPSocket> { |
| 25 public: | 25 public: |
| 26 UDPSocketImpl(); | 26 UDPSocketImpl(); |
| 27 virtual ~UDPSocketImpl(); | 27 ~UDPSocketImpl() override; |
| 28 | 28 |
| 29 // UDPSocket implementation. | 29 // UDPSocket implementation. |
| 30 virtual void AllowAddressReuse( | 30 void AllowAddressReuse( |
| 31 const Callback<void(NetworkErrorPtr)>& callback) override; | 31 const Callback<void(NetworkErrorPtr)>& callback) override; |
| 32 | 32 |
| 33 virtual void Bind( | 33 void Bind( |
| 34 NetAddressPtr addr, | 34 NetAddressPtr addr, |
| 35 const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback) override; | 35 const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback) override; |
| 36 | 36 |
| 37 virtual void SetSendBufferSize( | 37 void SetSendBufferSize( |
| 38 uint32_t size, | 38 uint32_t size, |
| 39 const Callback<void(NetworkErrorPtr)>& callback) override; | 39 const Callback<void(NetworkErrorPtr)>& callback) override; |
| 40 | 40 |
| 41 virtual void SetReceiveBufferSize( | 41 void SetReceiveBufferSize( |
| 42 uint32_t size, | 42 uint32_t size, |
| 43 const Callback<void(NetworkErrorPtr)>& callback) override; | 43 const Callback<void(NetworkErrorPtr)>& callback) override; |
| 44 | 44 |
| 45 virtual void NegotiateMaxPendingSendRequests( | 45 void NegotiateMaxPendingSendRequests( |
| 46 uint32_t requested_size, | 46 uint32_t requested_size, |
| 47 const Callback<void(uint32_t)>& callback) override; | 47 const Callback<void(uint32_t)>& callback) override; |
| 48 | 48 |
| 49 virtual void ReceiveMore(uint32_t datagram_number) override; | 49 void ReceiveMore(uint32_t datagram_number) override; |
| 50 | 50 |
| 51 virtual void SendTo(NetAddressPtr dest_addr, | 51 void SendTo(NetAddressPtr dest_addr, |
| 52 Array<uint8_t> data, | 52 Array<uint8_t> data, |
| 53 const Callback<void(NetworkErrorPtr)>& callback) override; | 53 const Callback<void(NetworkErrorPtr)>& callback) override; |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 struct PendingSendRequest { | 56 struct PendingSendRequest { |
| 57 PendingSendRequest(); | 57 PendingSendRequest(); |
| 58 ~PendingSendRequest(); | 58 ~PendingSendRequest(); |
| 59 | 59 |
| 60 NetAddressPtr addr; | 60 NetAddressPtr addr; |
| 61 Array<uint8_t> data; | 61 Array<uint8_t> data; |
| 62 Callback<void(NetworkErrorPtr)> callback; | 62 Callback<void(NetworkErrorPtr)> callback; |
| 63 }; | 63 }; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 89 std::deque<PendingSendRequest*> pending_send_requests_; | 89 std::deque<PendingSendRequest*> pending_send_requests_; |
| 90 // The maximum size of the |pending_send_requests_| queue. | 90 // The maximum size of the |pending_send_requests_| queue. |
| 91 size_t max_pending_send_requests_; | 91 size_t max_pending_send_requests_; |
| 92 | 92 |
| 93 DISALLOW_COPY_AND_ASSIGN(UDPSocketImpl); | 93 DISALLOW_COPY_AND_ASSIGN(UDPSocketImpl); |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 } // namespace mojo | 96 } // namespace mojo |
| 97 | 97 |
| 98 #endif // MOJO_SERVICES_NETWORK_UDP_SOCKET_IMPL_H_ | 98 #endif // MOJO_SERVICES_NETWORK_UDP_SOCKET_IMPL_H_ |
| OLD | NEW |