| 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_PUBLIC_CPP_UDP_SOCKET_WRAPPER_H_ | 5 #ifndef MOJO_SERVICES_NETWORK_PUBLIC_CPP_UDP_SOCKET_WRAPPER_H_ |
| 6 #define MOJO_SERVICES_NETWORK_PUBLIC_CPP_UDP_SOCKET_WRAPPER_H_ | 6 #define MOJO_SERVICES_NETWORK_PUBLIC_CPP_UDP_SOCKET_WRAPPER_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "network/public/interfaces/udp_socket.mojom.h" | 10 #include "network/public/interfaces/udp_socket.mojom.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 uint32_t receive_queue_slots, | 36 uint32_t receive_queue_slots, |
| 37 uint32_t requested_max_pending_sends); | 37 uint32_t requested_max_pending_sends); |
| 38 | 38 |
| 39 ~UDPSocketWrapper() override; | 39 ~UDPSocketWrapper() override; |
| 40 | 40 |
| 41 void AllowAddressReuse(const ErrorCallback& callback); | 41 void AllowAddressReuse(const ErrorCallback& callback); |
| 42 | 42 |
| 43 void Bind(NetAddressPtr addr, | 43 void Bind(NetAddressPtr addr, |
| 44 const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback); | 44 const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback); |
| 45 | 45 |
| 46 void Connect(NetAddressPtr remote_addr, |
| 47 const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback); |
| 48 |
| 46 void SetSendBufferSize(uint32_t size, const ErrorCallback& callback); | 49 void SetSendBufferSize(uint32_t size, const ErrorCallback& callback); |
| 47 | 50 |
| 48 void SetReceiveBufferSize(uint32_t size, const ErrorCallback& callback); | 51 void SetReceiveBufferSize(uint32_t size, const ErrorCallback& callback); |
| 49 | 52 |
| 50 // If there are already incoming datagrams cached locally, this method runs | 53 // If there are already incoming datagrams cached locally, this method runs |
| 51 // |callback| before it returns, and the return value is set to true. | 54 // |callback| before it returns, and the return value is set to true. |
| 52 // Otherwise, the return value is set to false and the callback will be run | 55 // Otherwise, the return value is set to false and the callback will be run |
| 53 // asynchronously. | 56 // asynchronously. |
| 57 // If the socket is connected, the net address pointer passed into the |
| 58 // callback is set to null. |
| 54 bool ReceiveFrom(const ReceiveCallback& callback); | 59 bool ReceiveFrom(const ReceiveCallback& callback); |
| 55 | 60 |
| 56 // This method is aware of the max pending send requests allowed by the | 61 // This method is aware of the max pending send requests allowed by the |
| 57 // service, and caches send requests locally if necessary. | 62 // service, and caches send requests locally if necessary. |
| 63 // |dest_addr| is allowed to be null if the socket is connected. |
| 58 void SendTo(NetAddressPtr dest_addr, | 64 void SendTo(NetAddressPtr dest_addr, |
| 59 Array<uint8_t> data, | 65 Array<uint8_t> data, |
| 60 const ErrorCallback& callback); | 66 const ErrorCallback& callback); |
| 61 | 67 |
| 62 private: | 68 private: |
| 63 class NegotiateCallbackHandler : public Callback<void(uint32_t)>::Runnable { | 69 class NegotiateCallbackHandler : public Callback<void(uint32_t)>::Runnable { |
| 64 public: | 70 public: |
| 65 explicit NegotiateCallbackHandler(UDPSocketWrapper* delegate); | 71 explicit NegotiateCallbackHandler(UDPSocketWrapper* delegate); |
| 66 ~NegotiateCallbackHandler() override; | 72 ~NegotiateCallbackHandler() override; |
| 67 | 73 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 uint32_t max_pending_sends_; | 142 uint32_t max_pending_sends_; |
| 137 uint32_t current_pending_sends_; | 143 uint32_t current_pending_sends_; |
| 138 | 144 |
| 139 // Owns all the objects that its elements point to. | 145 // Owns all the objects that its elements point to. |
| 140 std::queue<SendRequest*> send_requests_; | 146 std::queue<SendRequest*> send_requests_; |
| 141 }; | 147 }; |
| 142 | 148 |
| 143 } // namespace mojo | 149 } // namespace mojo |
| 144 | 150 |
| 145 #endif // MOJO_SERVICES_NETWORK_PUBLIC_CPP_UDP_SOCKET_WRAPPER_H_ | 151 #endif // MOJO_SERVICES_NETWORK_PUBLIC_CPP_UDP_SOCKET_WRAPPER_H_ |
| OLD | NEW |