Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / libraries / nacl_io / socket / udp_node.h
blobc8ea6779ff446fe63cfba2b92e84d8add716ef14
1 // Copyright 2013 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.
5 #ifndef LIBRARIES_NACL_IO_SOCKET_UDP_NODE_H_
6 #define LIBRARIES_NACL_IO_SOCKET_UDP_NODE_H_
8 #include "nacl_io/ossocket.h"
9 #ifdef PROVIDES_SOCKET_API
11 #include <ppapi/c/pp_resource.h>
12 #include <ppapi/c/ppb_udp_socket.h>
14 #include "nacl_io/socket/socket_node.h"
15 #include "nacl_io/socket/udp_event_emitter.h"
17 namespace nacl_io {
19 class UdpNode : public SocketNode {
20 public:
21 explicit UdpNode(Filesystem* filesystem);
23 protected:
24 virtual Error Init(int open_flags);
25 virtual void Destroy();
27 public:
28 virtual UdpEventEmitter* GetEventEmitter();
30 virtual void QueueInput();
31 virtual void QueueOutput();
33 virtual Error Bind(const struct sockaddr* addr, socklen_t len);
34 virtual Error Connect(const HandleAttr& attr,
35 const struct sockaddr* addr,
36 socklen_t len);
38 protected:
39 virtual Error Recv_Locked(void* buf,
40 size_t len,
41 PP_Resource* addr,
42 int* out_len);
44 virtual Error Send_Locked(const void* buf,
45 size_t len,
46 PP_Resource addr,
47 int* out_len);
49 virtual Error SetSockOptSocket(int opname, const void* optval, socklen_t len);
51 virtual Error SetSockOptIP(int optname, const void* optval, socklen_t len);
53 virtual Error SetSockOptIPV6(int optname, const void* optval, socklen_t len);
55 protected:
56 ScopedUdpEventEmitter emitter_;
59 } // namespace nacl_io
61 #endif // PROVIDES_SOCKET_API
62 #endif // LIBRARIES_NACL_IO_SOCKET_UDP_NODE_H_