GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/tcp_wrap.h Lines: 7 8 87.5 %
Date: 2019-09-16 22:31:04 Branches: 3 5 60.0 %

Line Branch Exec Source
1
// Copyright Joyent, Inc. and other Node contributors.
2
//
3
// Permission is hereby granted, free of charge, to any person obtaining a
4
// copy of this software and associated documentation files (the
5
// "Software"), to deal in the Software without restriction, including
6
// without limitation the rights to use, copy, modify, merge, publish,
7
// distribute, sublicense, and/or sell copies of the Software, and to permit
8
// persons to whom the Software is furnished to do so, subject to the
9
// following conditions:
10
//
11
// The above copyright notice and this permission notice shall be included
12
// in all copies or substantial portions of the Software.
13
//
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22
#ifndef SRC_TCP_WRAP_H_
23
#define SRC_TCP_WRAP_H_
24
25
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
27
#include "async_wrap.h"
28
#include "env.h"
29
#include "connection_wrap.h"
30
31
namespace node {
32
33
80264
class TCPWrap : public ConnectionWrap<TCPWrap, uv_tcp_t> {
34
 public:
35
  enum SocketType {
36
    SOCKET,
37
    SERVER
38
  };
39
40
  static v8::MaybeLocal<v8::Object> Instantiate(Environment* env,
41
                                                AsyncWrap* parent,
42
                                                SocketType type);
43
  static void Initialize(v8::Local<v8::Object> target,
44
                         v8::Local<v8::Value> unused,
45
                         v8::Local<v8::Context> context,
46
                         void* priv);
47
48
20
  SET_NO_MEMORY_INFO()
49
20
  SET_SELF_SIZE(TCPWrap)
50
20
  std::string MemoryInfoName() const override {
51
20
    switch (provider_type()) {
52
      case ProviderType::PROVIDER_TCPWRAP:
53
13
        return "TCPSocketWrap";
54
      case ProviderType::PROVIDER_TCPSERVERWRAP:
55
7
        return "TCPServerWrap";
56
      default:
57
        UNREACHABLE();
58
    }
59
  }
60
61
 private:
62
  typedef uv_tcp_t HandleType;
63
64
  template <typename T,
65
            int (*F)(const typename T::HandleType*, sockaddr*, int*)>
66
  friend void GetSockOrPeerName(const v8::FunctionCallbackInfo<v8::Value>&);
67
68
  TCPWrap(Environment* env, v8::Local<v8::Object> object,
69
          ProviderType provider);
70
71
  static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
72
  static void SetNoDelay(const v8::FunctionCallbackInfo<v8::Value>& args);
73
  static void SetKeepAlive(const v8::FunctionCallbackInfo<v8::Value>& args);
74
  static void Bind(const v8::FunctionCallbackInfo<v8::Value>& args);
75
  static void Bind6(const v8::FunctionCallbackInfo<v8::Value>& args);
76
  static void Listen(const v8::FunctionCallbackInfo<v8::Value>& args);
77
  static void Connect(const v8::FunctionCallbackInfo<v8::Value>& args);
78
  static void Connect6(const v8::FunctionCallbackInfo<v8::Value>& args);
79
  template <typename T>
80
  static void Connect(const v8::FunctionCallbackInfo<v8::Value>& args,
81
      std::function<int(const char* ip_address, T* addr)> uv_ip_addr);
82
  static void Open(const v8::FunctionCallbackInfo<v8::Value>& args);
83
  template <typename T>
84
  static void Bind(
85
      const v8::FunctionCallbackInfo<v8::Value>& args,
86
      int family,
87
      std::function<int(const char* ip_address, int port, T* addr)> uv_ip_addr);
88
89
#ifdef _WIN32
90
  static void SetSimultaneousAccepts(
91
      const v8::FunctionCallbackInfo<v8::Value>& args);
92
#endif
93
};
94
95
96
}  // namespace node
97
98
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
99
100
#endif  // SRC_TCP_WRAP_H_