66#include " inspector/main_thread_interface.h"
77#include " inspector/node_json.h"
88#include " inspector/node_string.h"
9+ #include " inspector/target_agent.h"
910#include " inspector_socket_server.h"
1011#include " ncrypto.h"
1112#include " node.h"
1415#include " util-inl.h"
1516#include " v8-inspector.h"
1617#include " zlib.h"
17- #include " inspector/target_agent.h"
1818
1919#include < deque>
2020#include < cstring>
@@ -69,9 +69,9 @@ class RequestToServer {
6969 RequestToServer (TransportAction action,
7070 int session_id,
7171 std::unique_ptr<v8_inspector::StringBuffer> message)
72- : action_(action),
73- session_id_ (session_id),
74- message_(std::move(message)) {}
72+ : action_(action),
73+ session_id_ (session_id),
74+ message_(std::move(message)) {}
7575
7676 void Dispatch (InspectorSocketServer* server) const {
7777 switch (action_) {
@@ -100,7 +100,7 @@ class RequestQueueData {
100100 using MessageQueue = std::deque<RequestToServer>;
101101
102102 explicit RequestQueueData (uv_loop_t * loop)
103- : handle_(std::make_shared<RequestQueue>(this )) {
103+ : handle_(std::make_shared<RequestQueue>(this )) {
104104 int err = uv_async_init (loop, &async_, [](uv_async_t * async) {
105105 RequestQueueData* wrapper =
106106 node::ContainerOf (&RequestQueueData::async_, async);
@@ -343,11 +343,11 @@ void InspectorIoDelegate::StartSession(int session_id,
343343 fprintf (stderr, " Debugger attached.\n " );
344344}
345345
346- std::optional<std::string> InspectorIoDelegate::GetTargetSessionId (const std::string& message) {
347- const std::string_view view (message.data (), message.size ());
346+ std::optional<std::string> InspectorIoDelegate::GetTargetSessionId (
347+ const std::string& message) {
348+ std::string_view view (message.data (), message.size ());
348349 std::unique_ptr<protocol::DictionaryValue> value =
349- protocol::DictionaryValue::cast (
350- JsonUtil::parseJSON (view));
350+ protocol::DictionaryValue::cast (JsonUtil::parseJSON (view));
351351 protocol::String target_session_id;
352352 protocol::Value* target_session_id_value = value->get (" sessionId" );
353353 if (target_session_id_value) {
@@ -362,34 +362,39 @@ std::optional<std::string> InspectorIoDelegate::GetTargetSessionId(const std::st
362362
363363void InspectorIoDelegate::MessageReceived (int session_id,
364364 const std::string& message) {
365- std::optional<std::string> target_session_id_str = GetTargetSessionId (message);
365+ std::optional<std::string> target_session_id_str =
366+ GetTargetSessionId (message);
366367 std::shared_ptr<MainThreadHandle> worker = nullptr ;
367368 int merged_session_id = session_id;
368- if (!target_session_id_str->empty ()) {
369+ if (!target_session_id_str->empty ()) {
369370 int target_session_id = std::stoi (*target_session_id_str);
370- worker = protocol::TargetAgent::target_session_id_worker_map_[target_session_id];
371- if (worker) {
371+ worker =
372+ protocol::TargetAgent::target_session_id_worker_map_[target_session_id];
373+ if (worker) {
372374 merged_session_id += target_session_id << 16 ;
373375 }
374376 }
375377
376378 auto session = sessions_.find (merged_session_id);
377379
378- if (session == sessions_.end ()) {
380+ if (session == sessions_.end ()) {
379381 std::unique_ptr<InspectorSession> session;
380- if (worker) {
382+ if (worker) {
381383 session = worker->Connect (
382- std::unique_ptr<InspectorSessionDelegate>(
383- new IoSessionDelegate (request_queue_->handle (), session_id)), true );
384+ std::unique_ptr<InspectorSessionDelegate>(
385+ new IoSessionDelegate (request_queue_->handle (), session_id)),
386+ true );
384387 } else {
385388 session = main_thread_->Connect (
386- std::unique_ptr<InspectorSessionDelegate>(
387- new IoSessionDelegate (request_queue_->handle (), session_id)), true );
389+ std::unique_ptr<InspectorSessionDelegate>(
390+ new IoSessionDelegate (request_queue_->handle (), session_id)),
391+ true );
388392 }
389393
390394 if (session) {
391395 sessions_[merged_session_id] = std::move (session);
392- sessions_[merged_session_id]->Dispatch (Utf8ToStringView (message)->string ());
396+ sessions_[merged_session_id]->Dispatch (
397+ Utf8ToStringView (message)->string ());
393398 } else {
394399 fprintf (stderr, " Failed to connect to inspector session.\n " );
395400 }
@@ -420,11 +425,11 @@ void RequestQueueData::CloseAndFree(RequestQueueData* queue) {
420425 queue->handle_ .reset ();
421426 uv_close (reinterpret_cast <uv_handle_t *>(&queue->async_ ),
422427 [](uv_handle_t * handle) {
423- uv_async_t * async = reinterpret_cast <uv_async_t *>(handle);
424- RequestQueueData* wrapper =
425- node::ContainerOf (&RequestQueueData::async_, async);
426- delete wrapper;
427- });
428+ uv_async_t * async = reinterpret_cast <uv_async_t *>(handle);
429+ RequestQueueData* wrapper =
430+ node::ContainerOf (&RequestQueueData::async_, async);
431+ delete wrapper;
432+ });
428433}
429434} // namespace inspector
430435} // namespace node
0 commit comments