GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage/nodes/benchmark/out/../src/inspector_agent.h Lines: 7 7 100.0 %
Date: 2017-06-14 Branches: 1 2 50.0 %

Line Branch Exec Source
1
#ifndef SRC_INSPECTOR_AGENT_H_
2
#define SRC_INSPECTOR_AGENT_H_
3
4
#include <memory>
5
6
#include <stddef.h>
7
8
#if !HAVE_INSPECTOR
9
#error("This header can only be used when inspector is enabled")
10
#endif
11
12
#include "node_debug_options.h"
13
14
// Forward declaration to break recursive dependency chain with src/env.h.
15
namespace node {
16
class Environment;
17
}  // namespace node
18
19
namespace v8 {
20
class Context;
21
template <typename V>
22
class FunctionCallbackInfo;
23
template<typename T>
24
class Local;
25
class Message;
26
class Object;
27
class Platform;
28
class Value;
29
}  // namespace v8
30
31
namespace v8_inspector {
32
class StringView;
33
}  // namespace v8_inspector
34
35
namespace node {
36
namespace inspector {
37
38
8
class InspectorSessionDelegate {
39
 public:
40
8
  virtual ~InspectorSessionDelegate() = default;
41
  virtual bool WaitForFrontendMessageWhilePaused() = 0;
42
  virtual void SendMessageToFrontend(const v8_inspector::StringView& message)
43
                                     = 0;
44
};
45
46
class InspectorIo;
47
class NodeInspectorClient;
48
49
class Agent {
50
 public:
51
  explicit Agent(node::Environment* env);
52
  ~Agent();
53
54
  // Create client_, may create io_ if option enabled
55
  bool Start(v8::Platform* platform, const char* path,
56
             const DebugOptions& options);
57
  // Stop and destroy io_
58
  void Stop();
59
60
2525
  bool IsStarted() { return !!client_; }
61
62
  // IO thread started, and client connected
63
  bool IsConnected();
64
65
66
  void WaitForDisconnect();
67
  void FatalException(v8::Local<v8::Value> error,
68
                      v8::Local<v8::Message> message);
69
70
  // These methods are called by the WS protocol and JS binding to create
71
  // inspector sessions.  The inspector responds by using the delegate to send
72
  // messages back.
73
  void Connect(InspectorSessionDelegate* delegate);
74
  void Disconnect();
75
  void Dispatch(const v8_inspector::StringView& message);
76
  InspectorSessionDelegate* delegate();
77
78
  void RunMessageLoop();
79
9450
  bool enabled() { return enabled_; }
80
  void PauseOnNextJavascriptStatement(const std::string& reason);
81
82
  // Initialize 'inspector' module bindings
83
  static void InitInspector(v8::Local<v8::Object> target,
84
                            v8::Local<v8::Value> unused,
85
                            v8::Local<v8::Context> context,
86
                            void* priv);
87
88
66
  InspectorIo* io() {
89
66
    return io_.get();
90
  }
91
92
  // Can only be called from the the main thread.
93
  bool StartIoThread(bool wait_for_connect);
94
95
  // Calls StartIoThread() from off the main thread.
96
  void RequestIoThreadStart();
97
98
1
  DebugOptions& options() { return debug_options_; }
99
100
 private:
101
  node::Environment* parent_env_;
102
  std::unique_ptr<NodeInspectorClient> client_;
103
  std::unique_ptr<InspectorIo> io_;
104
  v8::Platform* platform_;
105
  bool enabled_;
106
  std::string path_;
107
  DebugOptions debug_options_;
108
};
109
110
}  // namespace inspector
111
}  // namespace node
112
113
#endif  // SRC_INSPECTOR_AGENT_H_