OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef LIBRARIES_NACL_IO_DEVFS_TTY_EVENT_EMITTER_H_ | 5 #ifndef LIBRARIES_NACL_IO_DEVFS_TTY_EVENT_EMITTER_H_ |
6 #define LIBRARIES_NACL_IO_DEVFS_TTY_EVENT_EMITTER_H_ | 6 #define LIBRARIES_NACL_IO_DEVFS_TTY_EVENT_EMITTER_H_ |
7 | 7 |
8 #include <poll.h> | 8 #include <poll.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
11 | 11 |
12 #include "nacl_io/fifo_char.h" | 12 #include "nacl_io/fifo_char.h" |
13 #include "nacl_io/fifo_null.h" | 13 #include "nacl_io/fifo_null.h" |
14 #include "nacl_io/stream/stream_event_emitter.h" | 14 #include "nacl_io/stream/stream_event_emitter.h" |
15 | 15 |
16 #include "sdk_util/auto_lock.h" | 16 #include "sdk_util/auto_lock.h" |
17 #include "sdk_util/macros.h" | 17 #include "sdk_util/macros.h" |
18 | 18 |
19 namespace nacl_io { | 19 namespace nacl_io { |
20 | 20 |
21 class TtyEventEmitter; | 21 class TtyEventEmitter; |
22 typedef sdk_util::ScopedRef<TtyEventEmitter> ScopedTtyEventEmitter; | 22 typedef sdk_util::ScopedRef<TtyEventEmitter> ScopedTtyEventEmitter; |
23 | 23 |
24 class TtyEventEmitter : public StreamEventEmitter { | 24 class TtyEventEmitter : public StreamEventEmitter { |
25 public: | 25 public: |
26 explicit TtyEventEmitter(size_t size); | 26 explicit TtyEventEmitter(size_t size); |
27 | 27 |
28 size_t Read_Locked(char* data, size_t len); | 28 Error Read_Locked(char* data, size_t len, int* out_bytes); |
29 size_t Write_Locked(const char* data, size_t len); | 29 Error Write_Locked(const char* data, size_t len, int* out_bytes); |
30 | 30 |
31 protected: | 31 protected: |
32 virtual FIFOChar* in_fifo() { return &fifo_; } | 32 virtual FIFOChar* in_fifo() { return &fifo_; } |
33 virtual FIFONull* out_fifo() { return &null_; } | 33 virtual FIFONull* out_fifo() { return &null_; } |
34 | 34 |
35 private: | 35 private: |
36 FIFOChar fifo_; | 36 FIFOChar fifo_; |
37 FIFONull null_; | 37 FIFONull null_; |
38 DISALLOW_COPY_AND_ASSIGN(TtyEventEmitter); | 38 DISALLOW_COPY_AND_ASSIGN(TtyEventEmitter); |
39 }; | 39 }; |
40 | 40 |
41 } // namespace nacl_io | 41 } // namespace nacl_io |
42 | 42 |
43 #endif // LIBRARIES_NACL_IO_DEVFS_TTY_EVENT_EMITTER_H_ | 43 #endif // LIBRARIES_NACL_IO_DEVFS_TTY_EVENT_EMITTER_H_ |
OLD | NEW |