GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/inspector_io.h Lines: 2 2 100.0 %
Date: 2019-02-13 22:28:58 Branches: 0 0 - %

Line Branch Exec Source
1
#ifndef SRC_INSPECTOR_IO_H_
2
#define SRC_INSPECTOR_IO_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "inspector_socket_server.h"
7
#include "node_mutex.h"
8
#include "uv.h"
9
10
#include <memory>
11
#include <stddef.h>
12
13
#if !HAVE_INSPECTOR
14
#error("This header can only be used when inspector is enabled")
15
#endif
16
17
18
namespace v8_inspector {
19
class StringBuffer;
20
class StringView;
21
}  // namespace v8_inspector
22
23
namespace node {
24
// Forward declaration to break recursive dependency chain with src/env.h.
25
class Environment;
26
namespace inspector {
27
28
std::string FormatWsAddress(const std::string& host, int port,
29
                            const std::string& target_id,
30
                            bool include_protocol);
31
32
class InspectorIoDelegate;
33
class MainThreadHandle;
34
class RequestQueue;
35
36
// kKill closes connections and stops the server, kStop only stops the server
37
enum class TransportAction {
38
  kKill,
39
  kSendMessage,
40
  kStop
41
};
42
43
class InspectorIo {
44
 public:
45
  // Start the inspector agent thread, waiting for it to initialize
46
  // bool Start();
47
  // Returns empty pointer if thread was not started
48
  static std::unique_ptr<InspectorIo> Start(
49
      std::shared_ptr<MainThreadHandle> main_thread,
50
      const std::string& path,
51
      std::shared_ptr<HostPort> host_port);
52
53
  // Will block till the transport thread shuts down
54
  ~InspectorIo();
55
56
  void StopAcceptingNewConnections();
57
3
  const std::string& host() const { return host_port_->host(); }
58
3
  int port() const { return host_port_->port(); }
59
  std::vector<std::string> GetTargetIds() const;
60
61
 private:
62
  InspectorIo(std::shared_ptr<MainThreadHandle> handle,
63
              const std::string& path,
64
              std::shared_ptr<HostPort> host_port);
65
66
  // Wrapper for agent->ThreadMain()
67
  static void ThreadMain(void* agent);
68
69
  // Runs a uv_loop_t
70
  void ThreadMain();
71
72
  // This is a thread-safe object that will post async tasks. It lives as long
73
  // as an Inspector object lives (almost as long as an Isolate).
74
  std::shared_ptr<MainThreadHandle> main_thread_;
75
  // Used to post on a frontend interface thread, lives while the server is
76
  // running
77
  std::shared_ptr<RequestQueue> request_queue_;
78
  std::shared_ptr<HostPort> host_port_;
79
80
  // The IO thread runs its own uv_loop to implement the TCP server off
81
  // the main thread.
82
  uv_thread_t thread_;
83
84
  // For setting up interthread communications
85
  Mutex thread_start_lock_;
86
  ConditionVariable thread_start_condition_;
87
  std::string script_name_;
88
  // May be accessed from any thread
89
  const std::string id_;
90
};
91
92
}  // namespace inspector
93
}  // namespace node
94
95
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
96
97
#endif  // SRC_INSPECTOR_IO_H_