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

Unified Diff: libraries/nacl-mounts/net/Socket.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 side-by-side diff with in-line comments
Download patch
Index: libraries/nacl-mounts/net/Socket.h
===================================================================
--- libraries/nacl-mounts/net/Socket.h (revision 0)
+++ libraries/nacl-mounts/net/Socket.h (revision 0)
@@ -0,0 +1,67 @@
+// 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 PACKAGES_LIBRARIES_NACL_MOUNTS_BASE_SOCKET_H
+#define PACKAGES_LIBRARIES_NACL_MOUNTS_BASE_SOCKET_H
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <string.h>
+#include <sys/dir.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "../base/nacl_dirent.h"
+
+class Socket {
+ public:
+ virtual ~Socket() {}
+
+ virtual void addref() = 0;
+ virtual void release() = 0;
+
+ virtual void close() = 0;
+ virtual int read(char* buf, size_t count, size_t* nread) = 0;
+ virtual int write(const char* buf, size_t count, size_t* nwrote) = 0;
+ virtual int seek(nacl_abi_off_t offset, int whence,
+ nacl_abi_off_t* new_offset) {
+ return ESPIPE;
+ }
+ virtual int fstat(nacl_abi_stat* out) {
+ memset(out, 0, sizeof(nacl_abi_stat));
+ return 0;
+ }
+ virtual int getdents(dirent* buf, size_t count, size_t* nread) {
+ return ENOTDIR;
+ }
+
+ virtual int isatty() {
+ errno = EINVAL;
+ return 0;
+ }
+
+ virtual int fcntl(int cmd, va_list ap) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ virtual int ioctl(int request, va_list ap) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ virtual bool is_read_ready() {
+ return true;
+ }
+ virtual bool is_write_ready() {
+ return true;
+ }
+ virtual bool is_exception() {
+ return false;
+ }
+};
+
+#endif // PACKAGES_LIBRARIES_NACL_MOUNTS_BASE_SOCKET_H
+

Powered by Google App Engine
This is Rietveld 408576698