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

Side by Side Diff: libraries/nacl-mounts/net/TcpSocket.h

Issue 10392070: Socket subsystem implementation (Closed) Base URL: http://naclports.googlecode.com/svn/trunk/src/
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « libraries/nacl-mounts/net/TcpServerSocket.cc ('k') | libraries/nacl-mounts/net/TcpSocket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium OS 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 PACKAGES_LIBRARIES_NACL_MOUNTS_NET_SOCKET_H_
6 #define PACKAGES_LIBRARIES_NACL_MOUNTS_NET_SOCKET_H_
7
8 #include <deque>
9 #include <queue>
10 #include <vector>
11
12 #include "../net/Socket.h"
13 #include "../net/SocketSubSystem.h"
14 #include "ppapi/cpp/completion_callback.h"
15 #include "../ppapi/cpp/private/tcp_socket_private.h"
16 #include "../util/PthreadHelpers.h"
17
18 class TCPSocket : public Socket {
19 public:
20 TCPSocket(SocketSubSystem* sys, int oflag);
21 virtual ~TCPSocket();
22
23 int oflag() { return oflag_; }
24 bool is_block() { return !(oflag_ & O_NONBLOCK); }
25 bool is_open() { return socket_ != NULL; }
26
27 bool connect(const char* host, uint16_t port);
28 bool acceptFrom(PP_Resource resource);
29
30 virtual void addref();
31 virtual void release();
32
33 virtual void close();
34 virtual int read(char* buf, size_t count, size_t* nread);
35 virtual int write(const char* buf, size_t count, size_t* nwrote);
36
37 virtual int fcntl(int cmd, va_list ap);
38
39 virtual bool is_read_ready();
40 virtual bool is_write_ready();
41 virtual bool is_exception();
42
43 private:
44 void Connect(int32_t result, const char* host, uint16_t port, int32_t* pres);
45 void OnConnect(int32_t result, int32_t* pres);
46
47 void Read(int32_t result, int32_t* pres);
48 void OnRead(int32_t result, int32_t* pres);
49
50 void Write(int32_t result, int32_t* pres);
51 void OnWrite(int32_t result, int32_t* pres);
52
53 void Close(int32_t result, int32_t* pres);
54
55 bool Accept(int32_t result, PP_Resource resource, int32_t* pres);
56
57 static const size_t kBufSize = 64 * 1024;
58
59 SocketSubSystem* sys_;
60 int ref_;
61 int oflag_;
62 pp::CompletionCallbackFactory<TCPSocket, ThreadSafeRefCount> factory_;
63 pp::TCPSocketPrivate* socket_;
64 std::deque<char> in_buf_;
65 std::vector<char> out_buf_;
66 std::vector<char> read_buf_;
67 std::vector<char> write_buf_;
68 bool write_sent_;
69
70 DISALLOW_COPY_AND_ASSIGN(TCPSocket);
71 };
72
73 #endif // PACKAGES_LIBRARIES_NACL_MOUNTS_NET_SOCKET_H_
74
OLDNEW
« no previous file with comments | « libraries/nacl-mounts/net/TcpServerSocket.cc ('k') | libraries/nacl-mounts/net/TcpSocket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698