Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / libraries / nacl_io / socket / tcp_node.h
blobcb19acd957de2bf88848321e7945520527c6477a
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_TCP_NODE_H_
6 #define LIBRARIES_NACL_IO_SOCKET_TCP_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_tcp_socket.h>
14 #include "nacl_io/node.h"
15 #include "nacl_io/socket/socket_node.h"
16 #include "nacl_io/socket/tcp_event_emitter.h"
18 namespace nacl_io {
20 class TcpNode : public SocketNode {
21 public:
22 explicit TcpNode(Filesystem* filesystem);
23 TcpNode(Filesystem* filesystem, PP_Resource socket);
25 protected:
26 virtual Error Init(int open_flags);
27 virtual void Destroy();
29 public:
30 virtual EventEmitter* GetEventEmitter();
32 virtual void QueueAccept();
33 virtual void QueueConnect();
34 virtual void QueueInput();
35 virtual void QueueOutput();
37 virtual Error Accept(const HandleAttr& attr,
38 PP_Resource* out_sock,
39 struct sockaddr* addr,
40 socklen_t* len);
41 virtual Error Bind(const struct sockaddr* addr, socklen_t len);
42 virtual Error Connect(const HandleAttr& attr,
43 const struct sockaddr* addr,
44 socklen_t len);
45 virtual Error GetSockOpt(int lvl, int optname, void* optval, socklen_t* len);
46 virtual Error Listen(int backlog);
47 virtual Error Shutdown(int how);
49 virtual void SetError_Locked(int pp_error_num);
50 void ConnectDone_Locked();
51 void ConnectFailed_Locked();
53 protected:
54 Error SetNoDelay_Locked();
55 virtual Error Recv_Locked(void* buf,
56 size_t len,
57 PP_Resource* out_addr,
58 int* out_len);
60 virtual Error Send_Locked(const void* buf,
61 size_t len,
62 PP_Resource addr,
63 int* out_len);
65 virtual Error SetSockOptSocket(int opname, const void* optval, socklen_t len);
67 virtual Error SetSockOptTCP(int optname, const void* optval, socklen_t len);
69 protected:
70 ScopedTcpEventEmitter emitter_;
71 PP_Resource accepted_socket_;
72 bool tcp_nodelay_;
75 } // namespace nacl_io
77 #endif // PROVIDES_SOCKET_API
78 #endif // LIBRARIES_NACL_IO_SOCKET_TCP_NODE_H_