Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: mojo/services/network/udp_socket_impl.h

Issue 596383002: Mojo UDP API implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@udp_interface
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MOJO_SERVICES_NETWORK_UDP_SOCKET_IMPL_H_
6 #define MOJO_SERVICES_NETWORK_UDP_SOCKET_IMPL_H_
7
8 #include <queue>
9
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "mojo/public/cpp/bindings/interface_impl.h"
13 #include "mojo/services/public/interfaces/network/udp_socket.mojom.h"
14 #include "net/base/ip_endpoint.h"
15 #include "net/udp/udp_server_socket.h"
16
17 namespace net {
18 class IOBuffer;
19 class IOBufferWithSize;
20 }
21
22 namespace mojo {
23
24 class UDPSocketImpl : public InterfaceImpl<UDPSocket> {
25 public:
26 UDPSocketImpl();
27 virtual ~UDPSocketImpl();
28
29 virtual void SetSendBufferSize(
30 uint32_t size,
31 const Callback<void(NetworkErrorPtr)>& callback) OVERRIDE;
32
33 virtual void SetReceiveBufferSize(
34 uint32_t size,
35 const Callback<void(NetworkErrorPtr)>& callback) OVERRIDE;
36
37 virtual void AllowAddressReuse(
38 const Callback<void(NetworkErrorPtr)>& callback) OVERRIDE;
39
40 virtual void Bind(
41 NetAddressPtr addr,
42 const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback) OVERRIDE;
43
44 virtual void ReceiveMorePackets(uint32_t number) OVERRIDE;
45
46 virtual void SendToAndForget(NetAddressPtr addr,
47 Array<uint8_t> data) OVERRIDE;
48
49 virtual void SendTo(NetAddressPtr addr,
50 Array<uint8_t> data,
51 const Callback<void(NetworkErrorPtr)>& callback) OVERRIDE;
52
53 private:
54 struct PendingSendRequest {
55 PendingSendRequest();
56 ~PendingSendRequest();
57
58 NetAddressPtr addr;
59 Array<uint8_t> data;
60 Callback<void(NetworkErrorPtr)> callback;
61 };
62
63 void DoRecvFrom();
64 void DoSendTo(NetAddressPtr addr,
65 Array<uint8_t> data,
66 const Callback<void(NetworkErrorPtr)>& callback);
67
68 void OnRecvFromCompleted(int net_result);
69 void OnSendToCompleted(const Callback<void(NetworkErrorPtr)>& callback,
70 int net_result);
71
72 net::UDPServerSocket socket_;
73
74 bool bound_;
75
76 scoped_refptr<net::IOBuffer> recvfrom_buffer_;
77 scoped_refptr<net::IOBufferWithSize> sendto_buffer_;
brettw 2014/09/29 18:24:26 This seems to be used in a nontrivial way and has
yzshen1 2014/09/29 21:51:12 Done.
78
79 net::IPEndPoint recvfrom_address_;
80
81 size_t remaining_recv_slots_;
brettw 2014/09/29 18:24:26 This one isn't self-explanatory to me.
yzshen1 2014/09/29 21:51:12 Done.
82
83 std::queue<PendingSendRequest*> pending_send_requests_;
brettw 2014/09/29 18:24:26 Can you clarify these are owning pointers?
yzshen1 2014/09/29 21:51:12 Done.
84
85 DISALLOW_COPY_AND_ASSIGN(UDPSocketImpl);
86 };
87
88 } // namespace mojo
89
90 #endif // MOJO_SERVICES_NETWORK_UDP_SOCKET_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698