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

Unified Diff: native_client_sdk/src/libraries/nacl_io/devfs/jspipe_event_emitter.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_event_emitter.h
diff --git a/native_client_sdk/src/libraries/nacl_io/devfs/jspipe_event_emitter.h b/native_client_sdk/src/libraries/nacl_io/devfs/jspipe_event_emitter.h
new file mode 100644
index 0000000000000000000000000000000000000000..daf07b468f24f52577f69e7cbb1453aabe60d26f
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/devfs/jspipe_event_emitter.h
@@ -0,0 +1,75 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
binji 2014/05/01 20:22:31 2014
Sam Clegg 2014/05/01 22:16:55 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIBRARIES_NACL_IO_DEVFS_JSPIPE_EVENT_EMITTER_H_
+#define LIBRARIES_NACL_IO_DEVFS_JSPIPE_EVENT_EMITTER_H_
+
+#include <poll.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "nacl_io/devfs/fifo_post_message.h"
binji 2014/05/01 20:22:31 file doesn't exist?
+#include "nacl_io/fifo_char.h"
+#include "nacl_io/pipe/pipe_event_emitter.h"
+
+#include "sdk_util/auto_lock.h"
+#include "sdk_util/macros.h"
+
+namespace nacl_io {
+
+class PepperInterface;
+class MessagingInterface;
+class VarInterface;
+class VarArrayInterface;
+class VarArrayBufferInterface;
+class VarDictionaryInterface;
+
+class JSPipeEventEmitter;
+typedef sdk_util::ScopedRef<JSPipeEventEmitter> ScopedJSPipeEventEmitter;
+
+class JSPipeEventEmitter : public EventEmitter {
+ public:
+ JSPipeEventEmitter(PepperInterface* ppapi, size_t size);
+
+ size_t Read_Locked(char* data, size_t len);
+ size_t Write_Locked(const char* data, size_t len);
+
+ size_t HandleJSWrite(const char* data, size_t len);
+ void HandleJSAck(int64_t byte_count);
+
+ size_t GetOSpace() { return post_message_buffer_size_ - BytesOutstanding(); };
binji 2014/05/01 20:22:31 these are called {Read,Write}Available in the fifo
Sam Clegg 2014/05/01 22:16:55 These are slightly different. They correspond to t
+ size_t GetISpace() { return input_fifo_.WriteAvailable(); };
+ Error SetName(const char* name);
+
+ protected:
+ void UpdateStatus_Locked();
+ Error SendAckMessage(int64_t byte_count);
+ size_t BytesOutstanding() { return bytes_sent_ - bytes_acked_; }
+ Error SendMessageToJS(const char* message_type, PP_Var payload);
+ Error SendWriteMessage(const void* buf, size_t count);
+
+ private:
+ std::string name_;
+ FIFOChar input_fifo_;
+
+ // Number of bytes that to send via PostMessage before and ACK
+ // is required.
+ size_t post_message_buffer_size_;
+ int64_t bytes_sent_;
binji 2014/05/01 20:22:31 why not use size_t?
Sam Clegg 2014/05/01 22:16:55 Done.
+ int64_t bytes_acked_;
+ int64_t bytes_read_;
+
+ PepperInterface* ppapi_;
+ MessagingInterface* messaging_iface_;
+ VarInterface* var_iface_;
+ VarArrayInterface* array_iface_;
+ VarArrayBufferInterface* buffer_iface_;
+ VarDictionaryInterface* dict_iface_;
+
+ DISALLOW_COPY_AND_ASSIGN(JSPipeEventEmitter);
+};
+
+} // namespace nacl_io
+
+#endif // LIBRARIES_NACL_IO_DEVFS_JSPIPE_EVENT_EMITTER_H_

Powered by Google App Engine
This is Rietveld 408576698