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

Unified Diff: native_client_sdk/src/libraries/nacl_io/mount_stream.h

Issue 23498015: [NaCl SDK] Support non blocking TCP/UDP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 7 years, 3 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: native_client_sdk/src/libraries/nacl_io/mount_stream.h
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_stream.h b/native_client_sdk/src/libraries/nacl_io/mount_stream.h
new file mode 100644
index 0000000000000000000000000000000000000000..757e1323b25f608e3ed166df17e52038b47612eb
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/mount_stream.h
@@ -0,0 +1,81 @@
+// Copyright (c) 2013 The Chromium 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 LIBRARIES_NACL_IO_MOUNT_STREAM_H_
+#define LIBRARIES_NACL_IO_MOUNT_STREAM_H_
+
+#include "nacl_io/mount.h"
+
+#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/c/pp_resource.h"
+
+
+namespace nacl_io {
+
+// MountStreams provides a "mount point" for stream objects which do not
+// provide a path, such as FDs returned by pipe, socket, and sockpair. It
+// also provides a background thread for dispatching completion callbacks.
+
+class MountStream;
+class MountNodeStream;
+
+class MountStream : public Mount {
+ public:
+ class Work {
+ public:
+ explicit Work(MountStream* mount) : mount_(mount) {}
+ virtual ~Work() {}
+
+ // Called by adding work the queue, val should be safe to ignore.
+ virtual bool Start(int32_t val) = 0;
+
+ // Called as a completion of work in Start. Value of val depend on
+ // the function invoked in Start.
+ virtual void Run(int32_t val) = 0;
+ MountStream* mount() { return mount_; }
+
+ private:
+ MountStream* mount_;
+ };
+
+ protected:
+ MountStream();
+ virtual ~MountStream();
+
+ public:
+ // Enqueue a work object onto this MountStream's thread
+ void EnqueueWork(Work* work);
+
+ // Returns a completion callback which will execute the StartWork member
+ // of a MountSocketWork object.
+ static PP_CompletionCallback GetStartCompletion(Work* work);
+
+ // Returns a completion callback which will execute the RunCallback member
+ // of a MountSocketWork object.
+ static PP_CompletionCallback GetRunCompletion(Work* work);
+
+ virtual Error Access(const Path& path, int a_mode);
+ virtual Error Open(const Path& path,
+ int o_flags,
+ ScopedMountNode* out_node);
+ virtual Error Unlink(const Path& path);
+ virtual Error Mkdir(const Path& path, int permissions);
+ virtual Error Rmdir(const Path& path);
+ virtual Error Remove(const Path& path);
+
+ static void* StreamThreadThunk(void*);
+ void StreamThread();
+
+ private:
+ PP_Resource message_loop_;
+ pthread_cond_t message_cond_;
+ sdk_util::SimpleLock message_lock_;
+
+ friend class KernelProxy;
+ DISALLOW_COPY_AND_ASSIGN(MountStream);
+};
+
+} // namespace nacl_io
+
+#endif // LIBRARIES_NACL_IO_MOUNT_STREAM_H_

Powered by Google App Engine
This is Rietveld 408576698