55#include " debug_utils-inl.h"
66#include " inspector/main_thread_interface.h"
77#include " inspector/node_string.h"
8+ #include " inspector/target_agent.h"
89#include " inspector_socket_server.h"
910#include " ncrypto.h"
1011#include " node.h"
1314#include " util-inl.h"
1415#include " v8-inspector.h"
1516#include " zlib.h"
16- #include " inspector/target_agent.h"
1717
1818#include < deque>
1919#include < cstring>
@@ -68,9 +68,9 @@ class RequestToServer {
6868 RequestToServer (TransportAction action,
6969 int session_id,
7070 std::unique_ptr<v8_inspector::StringBuffer> message)
71- : action_(action),
72- session_id_ (session_id),
73- message_(std::move(message)) {}
71+ : action_(action),
72+ session_id_ (session_id),
73+ message_(std::move(message)) {}
7474
7575 void Dispatch (InspectorSocketServer* server) const {
7676 switch (action_) {
@@ -99,7 +99,7 @@ class RequestQueueData {
9999 using MessageQueue = std::deque<RequestToServer>;
100100
101101 explicit RequestQueueData (uv_loop_t * loop)
102- : handle_(std::make_shared<RequestQueue>(this )) {
102+ : handle_(std::make_shared<RequestQueue>(this )) {
103103 int err = uv_async_init (loop, &async_, [](uv_async_t * async) {
104104 RequestQueueData* wrapper =
105105 node::ContainerOf (&RequestQueueData::async_, async);
@@ -342,11 +342,11 @@ void InspectorIoDelegate::StartSession(int session_id,
342342 fprintf (stderr, " Debugger attached.\n " );
343343}
344344
345- std::optional<std::string> InspectorIoDelegate::GetTargetSessionId (const std::string& message) {
345+ std::optional<std::string> InspectorIoDelegate::GetTargetSessionId (
346+ const std::string& message) {
346347 std::string_view view (message.data (), message.size ());
347348 std::unique_ptr<protocol::DictionaryValue> value =
348- protocol::DictionaryValue::cast (
349- protocol::StringUtil::parseJSON (view));
349+ protocol::DictionaryValue::cast (protocol::StringUtil::parseJSON (view));
350350 protocol::String target_session_id;
351351 protocol::Value* target_session_id_value = value->get (" sessionId" );
352352 if (target_session_id_value) {
@@ -361,34 +361,39 @@ std::optional<std::string> InspectorIoDelegate::GetTargetSessionId(const std::st
361361
362362void InspectorIoDelegate::MessageReceived (int session_id,
363363 const std::string& message) {
364- std::optional<std::string> target_session_id_str = GetTargetSessionId (message);
364+ std::optional<std::string> target_session_id_str =
365+ GetTargetSessionId (message);
365366 std::shared_ptr<MainThreadHandle> worker = nullptr ;
366367 int merged_session_id = session_id;
367- if (!target_session_id_str->empty ()) {
368+ if (!target_session_id_str->empty ()) {
368369 int target_session_id = std::stoi (*target_session_id_str);
369- worker = protocol::TargetAgent::target_session_id_worker_map_[target_session_id];
370- if (worker) {
370+ worker =
371+ protocol::TargetAgent::target_session_id_worker_map_[target_session_id];
372+ if (worker) {
371373 merged_session_id += target_session_id << 16 ;
372374 }
373375 }
374376
375377 auto session = sessions_.find (merged_session_id);
376378
377- if (session == sessions_.end ()) {
379+ if (session == sessions_.end ()) {
378380 std::unique_ptr<InspectorSession> session;
379- if (worker) {
381+ if (worker) {
380382 session = worker->Connect (
381- std::unique_ptr<InspectorSessionDelegate>(
382- new IoSessionDelegate (request_queue_->handle (), session_id)), true );
383+ std::unique_ptr<InspectorSessionDelegate>(
384+ new IoSessionDelegate (request_queue_->handle (), session_id)),
385+ true );
383386 } else {
384387 session = main_thread_->Connect (
385- std::unique_ptr<InspectorSessionDelegate>(
386- new IoSessionDelegate (request_queue_->handle (), session_id)), true );
388+ std::unique_ptr<InspectorSessionDelegate>(
389+ new IoSessionDelegate (request_queue_->handle (), session_id)),
390+ true );
387391 }
388392
389393 if (session) {
390394 sessions_[merged_session_id] = std::move (session);
391- sessions_[merged_session_id]->Dispatch (Utf8ToStringView (message)->string ());
395+ sessions_[merged_session_id]->Dispatch (
396+ Utf8ToStringView (message)->string ());
392397 } else {
393398 fprintf (stderr, " Failed to connect to inspector session.\n " );
394399 }
@@ -419,11 +424,11 @@ void RequestQueueData::CloseAndFree(RequestQueueData* queue) {
419424 queue->handle_ .reset ();
420425 uv_close (reinterpret_cast <uv_handle_t *>(&queue->async_ ),
421426 [](uv_handle_t * handle) {
422- uv_async_t * async = reinterpret_cast <uv_async_t *>(handle);
423- RequestQueueData* wrapper =
424- node::ContainerOf (&RequestQueueData::async_, async);
425- delete wrapper;
426- });
427+ uv_async_t * async = reinterpret_cast <uv_async_t *>(handle);
428+ RequestQueueData* wrapper =
429+ node::ContainerOf (&RequestQueueData::async_, async);
430+ delete wrapper;
431+ });
427432}
428433} // namespace inspector
429434} // namespace node
0 commit comments