From 86cdfc60a9ae21f64058e7292db3566d91d09085 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 2 Nov 2019 21:04:57 +0100 Subject: src: use unique_ptr for InitializeInspector() This makes more sense than releasing and re-wrapping the raw pointer. PR-URL: https://github.com/nodejs/node/pull/30229 Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Joyee Cheung Reviewed-By: Shelley Vohr --- src/env.h | 3 ++- src/node.cc | 7 +++---- src/node_main_instance.cc | 6 +++++- src/node_worker.cc | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/env.h b/src/env.h index d6dd50b701..e5490c0a5b 100644 --- a/src/env.h +++ b/src/env.h @@ -860,7 +860,8 @@ class Environment : public MemoryRetainer { #if HAVE_INSPECTOR // If the environment is created for a worker, pass parent_handle and // the ownership if transferred into the Environment. - int InitializeInspector(inspector::ParentInspectorHandle* parent_handle); + int InitializeInspector( + std::unique_ptr parent_handle); #endif v8::MaybeLocal BootstrapInternalLoaders(); diff --git a/src/node.cc b/src/node.cc index 94c85cae74..5a8e6ea8c0 100644 --- a/src/node.cc +++ b/src/node.cc @@ -202,13 +202,12 @@ MaybeLocal ExecuteBootstrapper(Environment* env, #if HAVE_INSPECTOR int Environment::InitializeInspector( - inspector::ParentInspectorHandle* parent_handle) { + std::unique_ptr parent_handle) { std::string inspector_path; - if (parent_handle != nullptr) { + if (parent_handle) { DCHECK(!is_main_thread()); inspector_path = parent_handle->url(); - inspector_agent_->SetParentHandle( - std::unique_ptr(parent_handle)); + inspector_agent_->SetParentHandle(std::move(parent_handle)); } else { inspector_path = argv_.size() > 1 ? argv_[1].c_str() : ""; } diff --git a/src/node_main_instance.cc b/src/node_main_instance.cc index 64b3ceabaf..a4b2853b7c 100644 --- a/src/node_main_instance.cc +++ b/src/node_main_instance.cc @@ -7,6 +7,10 @@ #include #endif +#if HAVE_INSPECTOR +#include "inspector/worker_inspector.h" // ParentInspectorHandle +#endif + namespace node { using v8::Context; @@ -225,7 +229,7 @@ std::unique_ptr NodeMainInstance::CreateMainEnvironment( // TODO(joyeecheung): when we snapshot the bootstrapped context, // the inspector and diagnostics setup should after after deserialization. #if HAVE_INSPECTOR - *exit_code = env->InitializeInspector(nullptr); + *exit_code = env->InitializeInspector({}); #endif if (*exit_code != 0) { return env; diff --git a/src/node_worker.cc b/src/node_worker.cc index 8730e8b02b..b35b4040ca 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -325,7 +325,7 @@ void Worker::Run() { { env_->InitializeDiagnostics(); #if HAVE_INSPECTOR - env_->InitializeInspector(inspector_parent_handle_.release()); + env_->InitializeInspector(std::move(inspector_parent_handle_)); #endif HandleScope handle_scope(isolate_); InternalCallbackScope callback_scope( -- cgit v1.2.3