Skip to content

Commit 86cdfc6

Browse files
committed
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 7e2a182 commit 86cdfc6

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/env.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,8 @@ class Environment : public MemoryRetainer {
860860
#if HAVE_INSPECTOR
861861
// If the environment is created for a worker, pass parent_handle and
862862
// the ownership if transferred into the Environment.
863-
int InitializeInspector(inspector::ParentInspectorHandle* parent_handle);
863+
int InitializeInspector(
864+
std::unique_ptr<inspector::ParentInspectorHandle> parent_handle);
864865
#endif
865866

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

src/node.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,12 @@ MaybeLocal<Value> ExecuteBootstrapper(Environment* env,
202202

203203
#if HAVE_INSPECTOR
204204
int Environment::InitializeInspector(
205-
inspector::ParentInspectorHandle* parent_handle) {
205+
std::unique_ptr<inspector::ParentInspectorHandle> parent_handle) {
206206
std::string inspector_path;
207-
if (parent_handle != nullptr) {
207+
if (parent_handle) {
208208
DCHECK(!is_main_thread());
209209
inspector_path = parent_handle->url();
210-
inspector_agent_->SetParentHandle(
211-
std::unique_ptr<inspector::ParentInspectorHandle>(parent_handle));
210+
inspector_agent_->SetParentHandle(std::move(parent_handle));
212211
} else {
213212
inspector_path = argv_.size() > 1 ? argv_[1].c_str() : "";
214213
}

src/node_main_instance.cc

Lines changed: 5 additions & 1 deletion
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;
@@ -225,7 +229,7 @@ std::unique_ptr<Environment> NodeMainInstance::CreateMainEnvironment(
225229
// TODO(joyeecheung): when we snapshot the bootstrapped context,
226230
// the inspector and diagnostics setup should after after deserialization.
227231
#if HAVE_INSPECTOR
228-
*exit_code = env->InitializeInspector(nullptr);
232+
*exit_code = env->InitializeInspector({});
229233
#endif
230234
if (*exit_code != 0) {
231235
return env;

src/node_worker.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ void Worker::Run() {
325325
{
326326
env_->InitializeDiagnostics();
327327
#if HAVE_INSPECTOR
328-
env_->InitializeInspector(inspector_parent_handle_.release());
328+
env_->InitializeInspector(std::move(inspector_parent_handle_));
329329
#endif
330330
HandleScope handle_scope(isolate_);
331331
InternalCallbackScope callback_scope(

0 commit comments

Comments
 (0)