1 #ifndef SRC_INSPECTOR_IO_H_ 2 #define SRC_INSPECTOR_IO_H_ 14 #error("This header can only be used when inspector is enabled") 32 const std::string& target_id,
33 bool include_protocol);
35 class InspectorIoDelegate;
52 InspectorIo(node::Environment* env, v8::Platform* platform,
54 bool wait_for_connect);
66 void WaitForDisconnect();
70 const std::string& message);
72 uv_sem_post(&thread_start_sem_);
75 uv_close(reinterpret_cast<uv_handle_t*>(&thread_req_),
nullptr);
78 int port()
const {
return port_; }
79 std::string
host()
const {
return options_.host_name(); }
80 std::vector<std::string> GetTargetIds()
const;
83 template <
typename Action>
85 std::deque<std::tuple<Action, int,
86 std::unique_ptr<v8_inspector::StringBuffer>>>;
97 static void MainThreadReqAsyncCb(uv_async_t*
req);
100 static void ThreadMain(
void* agent);
103 template <
typename Transport>
void ThreadMain();
106 template <
typename Transport>
static void IoThreadAsyncCb(uv_async_t* async);
108 void SetConnected(
bool connected);
109 void DispatchMessages();
112 const v8_inspector::StringView& message);
115 template <
typename ActionType>
116 bool AppendMessage(MessageQueue<ActionType>* vector, ActionType action,
118 std::unique_ptr<v8_inspector::StringBuffer> buffer);
120 template <
typename ActionType>
121 void SwapBehindLock(MessageQueue<ActionType>* vector1,
122 MessageQueue<ActionType>* vector2);
124 void WaitForFrontendMessageWhilePaused();
126 void NotifyMessageReceived();
135 uv_sem_t thread_start_sem_;
139 node::Environment* parent_env_;
142 uv_async_t thread_req_;
145 std::pair<uv_async_t, Agent*>* main_thread_req_;
146 std::unique_ptr<InspectorSessionDelegate> session_delegate_;
147 v8::Platform* platform_;
152 MessageQueue<InspectorAction> incoming_message_queue_;
153 MessageQueue<TransportAction> outgoing_message_queue_;
154 MessageQueue<InspectorAction> dispatching_message_queue_;
156 bool dispatching_messages_;
159 std::string script_name_;
160 std::string script_path_;
161 const bool wait_for_connect_;
170 const std::string& message);
175 #endif // SRC_INSPECTOR_IO_H_ std::unique_ptr< StringBuffer > Utf8ToStringView(const std::string &message)
void InterruptCallback(v8::Isolate *, void *agent)
std::string FormatWsAddress(const std::string &host, int port, const std::string &target_id, bool include_protocol)
int Start(Isolate *isolate, IsolateData *isolate_data, int argc, const char *const *argv, int exec_argc, const char *const *exec_argv)