Chromium Code Reviews| 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_ |