OLD | NEW |
---|---|
(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 PROXY_STREAM_H | |
6 #define PROXY_STREAM_H | |
7 | |
8 #include "base/pthread_helpers.h" | |
9 #include "net/socket_subsystem.h" | |
10 | |
11 class ProxyStream : public FileStream { | |
Evgeniy Stepanov
2012/05/28 14:55:12
Also unused.
vissi
2012/05/28 15:20:21
Done.
| |
12 public: | |
13 ProxyStream(int fd, int oflag, FileStream* orig) | |
14 : ref_(1), fd_(fd), oflag_(oflag), orig_(orig) { | |
15 orig->addref(); | |
16 } | |
17 virtual ~ProxyStream() { | |
18 orig_->release(); | |
19 } | |
20 | |
21 void addref() { | |
22 ++ref_; | |
23 } | |
24 void release() { | |
25 if (!--ref_) | |
26 delete this; | |
27 } | |
28 virtual FileStream* dup(int fd) { | |
29 return new ProxyStream(fd, oflag_, orig_); | |
30 } | |
31 | |
32 virtual void close() { | |
33 } | |
34 virtual int read(char* buf, size_t count, size_t* nread) { | |
35 return orig_->read(buf, count, nread); | |
36 } | |
37 virtual int write(const char* buf, size_t count, size_t* nwrote) { | |
38 return orig_->write(buf, count, nwrote); | |
39 } | |
40 | |
41 virtual int seek(nacl_abi_off_t offset, int whence, | |
42 nacl_abi_off_t* new_offset) { | |
43 return orig_->seek(offset, whence, new_offset); | |
44 } | |
45 virtual int fstat(nacl_abi_stat* out) { | |
46 return orig_->fstat(out); | |
47 } | |
48 virtual int getdents(dirent* buf, size_t count, size_t* nread) { | |
49 return orig_->getdents(buf, count, nread); | |
50 } | |
51 | |
52 virtual int isatty() { | |
53 return orig_->isatty(); | |
54 } | |
55 virtual int tcgetattr(termios* termios_p) { | |
56 return orig_->tcgetattr(termios_p); | |
57 } | |
58 virtual int tcsetattr(int optional_actions, const termios* termios_p) { | |
59 return orig_->tcsetattr(optional_actions, termios_p); | |
60 } | |
61 virtual int fcntl(int cmd, va_list ap) { | |
62 return orig_->fcntl(cmd, ap); | |
63 } | |
64 virtual int ioctl(int request, va_list ap) { | |
65 return orig_->ioctl(request, ap); | |
66 } | |
67 | |
68 virtual bool is_read_ready() { | |
69 return orig_->is_read_ready(); | |
70 } | |
71 virtual bool is_write_ready() { | |
72 return orig_->is_write_ready(); | |
73 } | |
74 virtual bool is_exception() { | |
75 return orig_->is_exception(); | |
76 } | |
77 | |
78 private: | |
79 int ref_; | |
80 int fd_; | |
81 int oflag_; | |
82 FileStream* orig_; | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(ProxyStream); | |
85 }; | |
86 | |
87 #endif // PROXY_STREAM_H | |
88 | |
OLD | NEW |