GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: stream_pipe.h Lines: 0 3 0.0 %
Date: 2021-10-23 04:13:56 Branches: 0 0 - %

Line Branch Exec Source
1
#ifndef SRC_STREAM_PIPE_H_
2
#define SRC_STREAM_PIPE_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "stream_base.h"
7
8
namespace node {
9
10
class StreamPipe : public AsyncWrap {
11
 public:
12
  ~StreamPipe() override;
13
14
  void Unpipe(bool is_in_deletion = false);
15
16
  // TODO(RaisinTen): Just like MessagePort, add the following overload:
17
  // static StreamPipe* New(StreamBase* source, StreamBase* sink,
18
  //                        v8::Local<v8::Object> obj);
19
  // so that we can indicate if there is a pending exception/termination.
20
  static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
21
  static void Start(const v8::FunctionCallbackInfo<v8::Value>& args);
22
  static void Unpipe(const v8::FunctionCallbackInfo<v8::Value>& args);
23
  static void IsClosed(const v8::FunctionCallbackInfo<v8::Value>& args);
24
  static void PendingWrites(const v8::FunctionCallbackInfo<v8::Value>& args);
25
26
  SET_NO_MEMORY_INFO()
27
  SET_MEMORY_INFO_NAME(StreamPipe)
28
  SET_SELF_SIZE(StreamPipe)
29
30
 private:
31
  StreamPipe(StreamBase* source, StreamBase* sink, v8::Local<v8::Object> obj);
32
33
  inline StreamBase* source();
34
  inline StreamBase* sink();
35
36
  int pending_writes_ = 0;
37
  bool is_reading_ = false;
38
  bool is_eof_ = false;
39
  bool is_closed_ = true;
40
  bool sink_destroyed_ = false;
41
  bool source_destroyed_ = false;
42
  bool uses_wants_write_ = false;
43
44
  // Set a default value so that when we’re coming from Start(), we know
45
  // that we don’t want to read just yet.
46
  // This will likely need to be changed when supporting streams without
47
  // `OnStreamWantsWrite()` support.
48
  size_t wanted_data_ = 0;
49
50
  void ProcessData(size_t nread, std::unique_ptr<v8::BackingStore> bs);
51
52
  class ReadableListener : public StreamListener {
53
   public:
54
    uv_buf_t OnStreamAlloc(size_t suggested_size) override;
55
    void OnStreamRead(ssize_t nread, const uv_buf_t& buf) override;
56
    void OnStreamDestroy() override;
57
  };
58
59
  class WritableListener : public StreamListener {
60
   public:
61
    uv_buf_t OnStreamAlloc(size_t suggested_size) override;
62
    void OnStreamRead(ssize_t nread, const uv_buf_t& buf) override;
63
    void OnStreamAfterWrite(WriteWrap* w, int status) override;
64
    void OnStreamAfterShutdown(ShutdownWrap* w, int status) override;
65
    void OnStreamWantsWrite(size_t suggested_size) override;
66
    void OnStreamDestroy() override;
67
  };
68
69
  ReadableListener readable_listener_;
70
  WritableListener writable_listener_;
71
};
72
73
}  // namespace node
74
75
#endif
76
77
#endif  // SRC_STREAM_PIPE_H_