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

Unified Diff: libraries/nacl-mounts/net/ProxyStream.h

Issue 10392070: Socket subsystem implementation (Closed) Base URL: http://naclports.googlecode.com/svn/trunk/src/
Patch Set: Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: libraries/nacl-mounts/net/ProxyStream.h
===================================================================
--- libraries/nacl-mounts/net/ProxyStream.h (revision 0)
+++ libraries/nacl-mounts/net/ProxyStream.h (revision 0)
@@ -0,0 +1,88 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PROXY_STREAM_H
+#define PROXY_STREAM_H
+
+#include "base/pthread_helpers.h"
+#include "net/socket_subsystem.h"
+
+class ProxyStream : public FileStream {
+ public:
+ ProxyStream(int fd, int oflag, FileStream* orig)
+ : ref_(1), fd_(fd), oflag_(oflag), orig_(orig) {
+ orig->addref();
+ }
+ virtual ~ProxyStream() {
+ orig_->release();
+ }
+
+ void addref() {
+ ++ref_;
+ }
+ void release() {
+ if (!--ref_)
+ delete this;
+ }
+ virtual FileStream* dup(int fd) {
+ return new ProxyStream(fd, oflag_, orig_);
+ }
+
+ virtual void close() {
+ }
+ virtual int read(char* buf, size_t count, size_t* nread) {
+ return orig_->read(buf, count, nread);
+ }
+ virtual int write(const char* buf, size_t count, size_t* nwrote) {
+ return orig_->write(buf, count, nwrote);
+ }
+
+ virtual int seek(nacl_abi_off_t offset, int whence,
+ nacl_abi_off_t* new_offset) {
+ return orig_->seek(offset, whence, new_offset);
+ }
+ virtual int fstat(nacl_abi_stat* out) {
+ return orig_->fstat(out);
+ }
+ virtual int getdents(dirent* buf, size_t count, size_t* nread) {
+ return orig_->getdents(buf, count, nread);
+ }
+
+ virtual int isatty() {
+ return orig_->isatty();
+ }
+ virtual int tcgetattr(termios* termios_p) {
+ return orig_->tcgetattr(termios_p);
+ }
+ virtual int tcsetattr(int optional_actions, const termios* termios_p) {
+ return orig_->tcsetattr(optional_actions, termios_p);
+ }
+ virtual int fcntl(int cmd, va_list ap) {
+ return orig_->fcntl(cmd, ap);
+ }
+ virtual int ioctl(int request, va_list ap) {
+ return orig_->ioctl(request, ap);
+ }
+
+ virtual bool is_read_ready() {
+ return orig_->is_read_ready();
+ }
+ virtual bool is_write_ready() {
+ return orig_->is_write_ready();
+ }
+ virtual bool is_exception() {
+ return orig_->is_exception();
+ }
+
+ private:
+ int ref_;
+ int fd_;
+ int oflag_;
+ FileStream* orig_;
+
+ DISALLOW_COPY_AND_ASSIGN(ProxyStream);
+};
+
+#endif // PROXY_STREAM_H
+

Powered by Google App Engine
This is Rietveld 408576698