| 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/application/app_lifetime_helper.h" |
| 12 #include "mojo/services/network/public/interfaces/udp_socket.mojom.h" | 13 #include "mojo/services/network/public/interfaces/udp_socket.mojom.h" |
| 13 #include "net/base/ip_endpoint.h" | 14 #include "net/base/ip_endpoint.h" |
| 14 #include "net/udp/udp_socket.h" | 15 #include "net/udp/udp_socket.h" |
| 15 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h" | 16 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h" |
| 16 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" | 17 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 class IOBuffer; | 20 class IOBuffer; |
| 20 class IOBufferWithSize; | 21 class IOBufferWithSize; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace mojo { | 24 namespace mojo { |
| 24 | 25 |
| 25 class UDPSocketImpl : public UDPSocket { | 26 class UDPSocketImpl : public UDPSocket { |
| 26 public: | 27 public: |
| 27 // The lifetime of a new UDPSocketImpl is bound to the connection associated | 28 // The lifetime of a new UDPSocketImpl is bound to the connection associated |
| 28 // with |request|. | 29 // with |request|. |
| 29 explicit UDPSocketImpl(InterfaceRequest<UDPSocket> request); | 30 UDPSocketImpl(InterfaceRequest<UDPSocket> request, |
| 31 scoped_ptr<mojo::AppRefCount> app_refcount); |
| 30 ~UDPSocketImpl() override; | 32 ~UDPSocketImpl() override; |
| 31 | 33 |
| 32 // UDPSocket implementation. | 34 // UDPSocket implementation. |
| 33 void AllowAddressReuse( | 35 void AllowAddressReuse( |
| 34 const Callback<void(NetworkErrorPtr)>& callback) override; | 36 const Callback<void(NetworkErrorPtr)>& callback) override; |
| 35 | 37 |
| 36 void Bind(NetAddressPtr addr, | 38 void Bind(NetAddressPtr addr, |
| 37 const Callback<void(NetworkErrorPtr, | 39 const Callback<void(NetworkErrorPtr, |
| 38 NetAddressPtr, | 40 NetAddressPtr, |
| 39 InterfaceRequest<UDPSocketReceiver>)>& callback) | 41 InterfaceRequest<UDPSocketReceiver>)>& callback) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 UDPSocketReceiverPtr receiver_; | 114 UDPSocketReceiverPtr receiver_; |
| 113 | 115 |
| 114 // How many more packets the client side expects to receive. | 116 // How many more packets the client side expects to receive. |
| 115 size_t remaining_recv_slots_; | 117 size_t remaining_recv_slots_; |
| 116 | 118 |
| 117 // The queue owns the PendingSendRequest instances. | 119 // The queue owns the PendingSendRequest instances. |
| 118 std::deque<PendingSendRequest*> pending_send_requests_; | 120 std::deque<PendingSendRequest*> pending_send_requests_; |
| 119 // The maximum size of the |pending_send_requests_| queue. | 121 // The maximum size of the |pending_send_requests_| queue. |
| 120 size_t max_pending_send_requests_; | 122 size_t max_pending_send_requests_; |
| 121 | 123 |
| 124 scoped_ptr<mojo::AppRefCount> app_refcount_; |
| 125 |
| 122 DISALLOW_COPY_AND_ASSIGN(UDPSocketImpl); | 126 DISALLOW_COPY_AND_ASSIGN(UDPSocketImpl); |
| 123 }; | 127 }; |
| 124 | 128 |
| 125 } // namespace mojo | 129 } // namespace mojo |
| 126 | 130 |
| 127 #endif // MOJO_SERVICES_NETWORK_UDP_SOCKET_IMPL_H_ | 131 #endif // MOJO_SERVICES_NETWORK_UDP_SOCKET_IMPL_H_ |
| OLD | NEW |