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

Unified Diff: native_client_sdk/src/libraries/nacl_io/devfs/jspipe_node.h

Issue 242533005: [NaCl SDK] nacl_io: Add flow control the JavaScript pipes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 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/devfs/jspipe_node.h
diff --git a/native_client_sdk/src/libraries/nacl_io/devfs/jspipe_node.h b/native_client_sdk/src/libraries/nacl_io/devfs/jspipe_node.h
index ad7ac995477d6ebedb9d52b8efbfa09af103d025..460dd2491d63756d3ccabb360028cd1feeec5d16 100644
--- a/native_client_sdk/src/libraries/nacl_io/devfs/jspipe_node.h
+++ b/native_client_sdk/src/libraries/nacl_io/devfs/jspipe_node.h
@@ -5,27 +5,69 @@
#ifndef LIBRARIES_NACL_IO_DEVFS_JSPIPE_NODE_H_
#define LIBRARIES_NACL_IO_DEVFS_JSPIPE_NODE_H_
-#include "nacl_io/pipe/pipe_node.h"
-
+#include <ppapi/c/pp_var.h>
#include <string>
+#include "nacl_io/devfs/jspipe_event_emitter.h"
+#include "nacl_io/stream/stream_node.h"
+
namespace nacl_io {
-class JSPipeNode : public PipeNode {
+class MessagingInterface;
+class VarInterface;
+class VarArrayInterface;
+class VarArrayBufferInterface;
+class VarDictionaryInterface;
+
+/**
+ * JSPipeNode represents a two-way channel for communicating with JavaScript
+ * via calls to PostMessage. In order to use these some ammount of logic on
binji 2014/05/01 20:22:31 amount
Sam Clegg 2014/05/01 22:16:55 Done.
+ * the JavaScript side is also required. The protocol to the communication
+ * looks the same in both directions and consists of two message types:
+ * 'write' and 'ack'.
+ * The messages are formated as JavaScript dictionary objects and take the
+ * following form:
+ * { <pipe_name> : [ <massage_type>, <message_payload> ] }
+ * The payload for 'write' message is a ArrayBuffer containing binary data.
+ * The payload for 'ack' messages is the total number of bytes recieved at
+ * the other end.
+ * For example: { 'jspipe1' : [ 'ack', 234 ] }
+ *
+ * Messages comming from JavaScript must be delivered using the
binji 2014/05/01 20:22:31 coming
Sam Clegg 2014/05/01 22:16:55 Done.
+ * NACL_IOC_HANDLEMESSAGE ioctl on the file handle.
+ */
+class JSPipeNode : public Node {
public:
- explicit JSPipeNode(Filesystem* filesystem) : PipeNode(filesystem) {}
+ explicit JSPipeNode(Filesystem* filesystem);
+
+ virtual JSPipeEventEmitter* GetEventEmitter();
virtual Error VIoctl(int request, va_list args);
- // Writes go directly to PostMessage, reads come from a pipe
- // that gets populated by incoming messages
+ virtual Error Read(const HandleAttr& attr,
+ void* buf,
+ size_t count,
+ int* out_bytes);
virtual Error Write(const HandleAttr& attr,
const void* buf,
size_t count,
int* out_bytes);
- private:
+ protected:
+ Error HandleJSWrite(PP_Var message);
+ Error HandleJSAck(PP_Var message);
+ Error HandleJSMessage(PP_Var message);
+ Error SendAck();
+
+ ScopedJSPipeEventEmitter pipe_;
+
std::string name_;
+
+ MessagingInterface* messaging_iface_;
+ VarInterface* var_iface_;
+ VarArrayInterface* array_iface_;
+ VarArrayBufferInterface* buffer_iface_;
+ VarDictionaryInterface* dict_iface_;
};
} // namespace nacl_io

Powered by Google App Engine
This is Rietveld 408576698