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

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
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 SOCKET_H
6 #define SOCKET_H
7 #ifdef __GLIBC__
8
9 #include <deque>
10 #include <queue>
11 #include <vector>
12
13 #include "../include/ppapi/cpp/completion_callback.h"
Dmitry Polukhin 2012/05/31 14:06:45 I think it should be included as "ppapi/cpp/comple
vissi 2012/06/01 09:12:57 Done.
14 #include "../include/ppapi/cpp/private/tcp_socket_private.h"
15 #include "base/PthreadHelpers.h"
16 #include "net/SocketSubSystem.h"
17
18 class TCPSocket : public FileStream {
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 // __GLIBC__
74 #endif // SOCKET_H
75
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698