Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // 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.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef LIBRARIES_NACL_IO_DEVFS_JSPIPE_EVENT_EMITTER_H_ | |
| 6 #define LIBRARIES_NACL_IO_DEVFS_JSPIPE_EVENT_EMITTER_H_ | |
| 7 | |
| 8 #include <poll.h> | |
| 9 #include <stdint.h> | |
| 10 #include <stdlib.h> | |
| 11 | |
| 12 #include "nacl_io/devfs/fifo_post_message.h" | |
|
binji
2014/05/01 20:22:31
file doesn't exist?
| |
| 13 #include "nacl_io/fifo_char.h" | |
| 14 #include "nacl_io/pipe/pipe_event_emitter.h" | |
| 15 | |
| 16 #include "sdk_util/auto_lock.h" | |
| 17 #include "sdk_util/macros.h" | |
| 18 | |
| 19 namespace nacl_io { | |
| 20 | |
| 21 class PepperInterface; | |
| 22 class MessagingInterface; | |
| 23 class VarInterface; | |
| 24 class VarArrayInterface; | |
| 25 class VarArrayBufferInterface; | |
| 26 class VarDictionaryInterface; | |
| 27 | |
| 28 class JSPipeEventEmitter; | |
| 29 typedef sdk_util::ScopedRef<JSPipeEventEmitter> ScopedJSPipeEventEmitter; | |
| 30 | |
| 31 class JSPipeEventEmitter : public EventEmitter { | |
| 32 public: | |
| 33 JSPipeEventEmitter(PepperInterface* ppapi, size_t size); | |
| 34 | |
| 35 size_t Read_Locked(char* data, size_t len); | |
| 36 size_t Write_Locked(const char* data, size_t len); | |
| 37 | |
| 38 size_t HandleJSWrite(const char* data, size_t len); | |
| 39 void HandleJSAck(int64_t byte_count); | |
| 40 | |
| 41 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
| |
| 42 size_t GetISpace() { return input_fifo_.WriteAvailable(); }; | |
| 43 Error SetName(const char* name); | |
| 44 | |
| 45 protected: | |
| 46 void UpdateStatus_Locked(); | |
| 47 Error SendAckMessage(int64_t byte_count); | |
| 48 size_t BytesOutstanding() { return bytes_sent_ - bytes_acked_; } | |
| 49 Error SendMessageToJS(const char* message_type, PP_Var payload); | |
| 50 Error SendWriteMessage(const void* buf, size_t count); | |
| 51 | |
| 52 private: | |
| 53 std::string name_; | |
| 54 FIFOChar input_fifo_; | |
| 55 | |
| 56 // Number of bytes that to send via PostMessage before and ACK | |
| 57 // is required. | |
| 58 size_t post_message_buffer_size_; | |
| 59 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.
| |
| 60 int64_t bytes_acked_; | |
| 61 int64_t bytes_read_; | |
| 62 | |
| 63 PepperInterface* ppapi_; | |
| 64 MessagingInterface* messaging_iface_; | |
| 65 VarInterface* var_iface_; | |
| 66 VarArrayInterface* array_iface_; | |
| 67 VarArrayBufferInterface* buffer_iface_; | |
| 68 VarDictionaryInterface* dict_iface_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(JSPipeEventEmitter); | |
| 71 }; | |
| 72 | |
| 73 } // namespace nacl_io | |
| 74 | |
| 75 #endif // LIBRARIES_NACL_IO_DEVFS_JSPIPE_EVENT_EMITTER_H_ | |
| OLD | NEW |