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

Unified Diff: libraries/nacl-mounts/net/SocketSubSystem.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/SocketSubSystem.h
===================================================================
--- libraries/nacl-mounts/net/SocketSubSystem.h (revision 0)
+++ libraries/nacl-mounts/net/SocketSubSystem.h (revision 0)
@@ -0,0 +1,73 @@
+// 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 SOCKET_SUBSYSTEM_H
+#define SOCKET_SUBSYSTEM_H
+
+#include <assert.h>
+#include <errno.h>
+#include <memory.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <map>
+#include <string>
+
+#include "../base/KernelProxy.h"
+#include "../net/BaseSocketSubSystem.h"
+#include "../net/IOInterfaces.h"
+#include "ppapi/cpp/file_ref.h"
+#include "ppapi/cpp/file_system.h"
+#include "ppapi/utility/completion_callback_factory.h"
+
+class SocketSubSystem : public BaseSocketSubSystem {
+ public:
+ explicit SocketSubSystem(pp::Instance* instance);
+ ~SocketSubSystem();
Dmitry Polukhin 2012/05/29 15:00:51 Please add virtual, because base class d-tor is vi
vissi 2012/05/30 08:10:51 Done.
+ pp::Instance* instance() { return pp_instance_; }
+
+ // Syscall implementations
+ int close(FileStream* stream);
+ int read(FileStream* stream, char* buf, size_t count, size_t* nread);
+ int write(FileStream* stream, const char* buf, size_t count, size_t* nwrote);
+ int seek(FileStream* stream, nacl_abi_off_t offset, int whence,
+ nacl_abi_off_t* new_offset);
+ int fstat(FileStream* stream, nacl_abi_stat* out);
+
+ int fcntl(FileStream* stream, int cmd, va_list ap);
+ int ioctl(FileStream* stream, int request, va_list ap);
+
+ unsigned long gethostbyname(const char* name);
+ int connect(FileStream** stream, unsigned long addr, unsigned short port);
+ int shutdown(FileStream* stream, int how);
+ int bind(FileStream** stream, unsigned long addr, unsigned short port);
+ int listen(FileStream* stream, int backlog);
+ FileStream* accept(FileStream* stream, struct sockaddr *addr,
+ socklen_t* addrlen);
Dmitry Polukhin 2012/05/29 15:00:51 Need 2 idents.
vissi 2012/05/30 08:10:51 Done.
+ Mutex& mutex() { return KernelProxy::KPInstance()->select_mutex(); }
+ Cond& cond() { return KernelProxy::KPInstance()->select_cond(); }
+ private:
+ // protect hosts_ and addrs_
+ Mutex mutex_;
+ unsigned long first_unused_addr_;
+ pp::Instance* pp_instance_;
+
+ typedef std::map<std::string, unsigned long> HostMap;
+ typedef std::map<unsigned long, std::string> AddressMap;
+
+ // we store a map of virtual addresses here, as PPAPA sockes are name-bound
Evgeniy Stepanov 2012/05/29 14:28:20 a TODO about getting rid of this with the new reso
vissi 2012/05/30 08:10:51 Done.
+ void AddHostAddress(const char* name, unsigned long addr);
+ std::string GetHostByAddr(unsigned long addr);
+
+ HostMap hosts_;
+ AddressMap addrs_;
+
+ DISALLOW_COPY_AND_ASSIGN(SocketSubSystem);
+};
+
+#endif // SOCKET_SUBSYSTEM_H
+

Powered by Google App Engine
This is Rietveld 408576698