Skip to content

Commit d2d3bf8

Browse files
Eugene Ostroukhovtargos
Eugene Ostroukhov
authored andcommitted
inspector: code cleanup
1. Do not rely on a string comparison to identify when the frontend is ready to run and override a callback instead. 2. Remove unused boolean flag. PR-URL: #27591 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Aleksei Koziatinskii <[email protected]>
1 parent 2f512e3 commit d2d3bf8

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/inspector_agent.cc

+6-10
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
237237
worker_agent_.reset(); // Dispose before the dispatchers
238238
}
239239

240-
std::string dispatchProtocolMessage(const StringView& message) {
240+
void dispatchProtocolMessage(const StringView& message) {
241241
std::string raw_message = protocol::StringUtil::StringViewToUtf8(message);
242242
std::unique_ptr<protocol::DictionaryValue> value =
243243
protocol::DictionaryValue::cast(protocol::StringUtil::parseMessage(
@@ -252,7 +252,6 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
252252
node_dispatcher_->dispatch(call_id, method, std::move(value),
253253
raw_message);
254254
}
255-
return method;
256255
}
257256

258257
void schedulePauseOnNextStatement(const std::string& reason) {
@@ -494,9 +493,12 @@ class NodeInspectorClient : public V8InspectorClient {
494493
waiting_for_resume_ = false;
495494
}
496495

496+
void runIfWaitingForDebugger(int context_group_id) override {
497+
waiting_for_frontend_ = false;
498+
}
499+
497500
int connectFrontend(std::unique_ptr<InspectorSessionDelegate> delegate,
498501
bool prevent_shutdown) {
499-
events_dispatched_ = true;
500502
int session_id = next_session_id_++;
501503
channels_[session_id] = std::make_unique<ChannelImpl>(env_,
502504
client_,
@@ -508,16 +510,11 @@ class NodeInspectorClient : public V8InspectorClient {
508510
}
509511

510512
void disconnectFrontend(int session_id) {
511-
events_dispatched_ = true;
512513
channels_.erase(session_id);
513514
}
514515

515516
void dispatchMessageFromFrontend(int session_id, const StringView& message) {
516-
events_dispatched_ = true;
517-
std::string method =
518-
channels_[session_id]->dispatchProtocolMessage(message);
519-
if (waiting_for_frontend_)
520-
waiting_for_frontend_ = method != "Runtime.runIfWaitingForDebugger";
517+
channels_[session_id]->dispatchProtocolMessage(message);
521518
}
522519

523520
Local<Context> ensureDefaultContextInGroup(int contextGroupId) override {
@@ -678,7 +675,6 @@ class NodeInspectorClient : public V8InspectorClient {
678675
std::unordered_map<int, std::unique_ptr<ChannelImpl>> channels_;
679676
std::unordered_map<void*, InspectorTimerHandle> timers_;
680677
int next_session_id_ = 1;
681-
bool events_dispatched_ = false;
682678
bool waiting_for_resume_ = false;
683679
bool waiting_for_frontend_ = false;
684680
bool waiting_for_io_shutdown_ = false;

0 commit comments

Comments
 (0)