Skip to content

Commit b40eede

Browse files
addaleaxtargos
authored andcommitted
src: use unique_ptr for InitializeInspector()
This makes more sense than releasing and re-wrapping the raw pointer. PR-URL: #30229 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Shelley Vohr <[email protected]>
1 parent 79713ed commit b40eede

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/env.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,8 @@ class Environment : public MemoryRetainer {
872872
#if HAVE_INSPECTOR
873873
// If the environment is created for a worker, pass parent_handle and
874874
// the ownership if transferred into the Environment.
875-
int InitializeInspector(inspector::ParentInspectorHandle* parent_handle);
875+
int InitializeInspector(
876+
std::unique_ptr<inspector::ParentInspectorHandle> parent_handle);
876877
#endif
877878

878879
v8::MaybeLocal<v8::Value> BootstrapInternalLoaders();

src/node.cc

+3-4
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,12 @@ MaybeLocal<Value> ExecuteBootstrapper(Environment* env,
196196

197197
#if HAVE_INSPECTOR
198198
int Environment::InitializeInspector(
199-
inspector::ParentInspectorHandle* parent_handle) {
199+
std::unique_ptr<inspector::ParentInspectorHandle> parent_handle) {
200200
std::string inspector_path;
201-
if (parent_handle != nullptr) {
201+
if (parent_handle) {
202202
DCHECK(!is_main_thread());
203203
inspector_path = parent_handle->url();
204-
inspector_agent_->SetParentHandle(
205-
std::unique_ptr<inspector::ParentInspectorHandle>(parent_handle));
204+
inspector_agent_->SetParentHandle(std::move(parent_handle));
206205
} else {
207206
inspector_path = argv_.size() > 1 ? argv_[1].c_str() : "";
208207
}

src/node_main_instance.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
#include <sanitizer/lsan_interface.h>
88
#endif
99

10+
#if HAVE_INSPECTOR
11+
#include "inspector/worker_inspector.h" // ParentInspectorHandle
12+
#endif
13+
1014
namespace node {
1115

1216
using v8::Context;
@@ -217,7 +221,7 @@ std::unique_ptr<Environment> NodeMainInstance::CreateMainEnvironment(
217221
// TODO(joyeecheung): when we snapshot the bootstrapped context,
218222
// the inspector and diagnostics setup should after after deserialization.
219223
#if HAVE_INSPECTOR
220-
*exit_code = env->InitializeInspector(nullptr);
224+
*exit_code = env->InitializeInspector({});
221225
#endif
222226
if (*exit_code != 0) {
223227
return env;

src/node_worker.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void Worker::Run() {
251251
{
252252
env_->InitializeDiagnostics();
253253
#if HAVE_INSPECTOR
254-
env_->InitializeInspector(inspector_parent_handle_.release());
254+
env_->InitializeInspector(std::move(inspector_parent_handle_));
255255
#endif
256256
HandleScope handle_scope(isolate_);
257257
AsyncCallbackScope callback_scope(env_.get());

0 commit comments

Comments
 (0)