src: move DebugPortGetter/Setter to node_process.cc
PR-URL: https://github.com/nodejs/node/pull/22758 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
parent
efd4796fa9
commit
eaaee92d9b
27
src/node.cc
27
src/node.cc
@ -160,7 +160,6 @@ using v8::Object;
|
||||
using v8::ObjectTemplate;
|
||||
using v8::Promise;
|
||||
using v8::PropertyAttribute;
|
||||
using v8::PropertyCallbackInfo;
|
||||
using v8::ReadOnly;
|
||||
using v8::Script;
|
||||
using v8::ScriptCompiler;
|
||||
@ -1672,32 +1671,6 @@ static Local<Object> GetFeatures(Environment* env) {
|
||||
return scope.Escape(obj);
|
||||
}
|
||||
|
||||
|
||||
static void DebugPortGetter(Local<Name> property,
|
||||
const PropertyCallbackInfo<Value>& info) {
|
||||
Environment* env = Environment::GetCurrent(info);
|
||||
Mutex::ScopedLock lock(process_mutex);
|
||||
int port = env->options()->debug_options->port();
|
||||
#if HAVE_INSPECTOR
|
||||
if (port == 0) {
|
||||
if (auto io = env->inspector_agent()->io())
|
||||
port = io->port();
|
||||
}
|
||||
#endif // HAVE_INSPECTOR
|
||||
info.GetReturnValue().Set(port);
|
||||
}
|
||||
|
||||
|
||||
static void DebugPortSetter(Local<Name> property,
|
||||
Local<Value> value,
|
||||
const PropertyCallbackInfo<void>& info) {
|
||||
Environment* env = Environment::GetCurrent(info);
|
||||
Mutex::ScopedLock lock(process_mutex);
|
||||
env->options()->debug_options->host_port.port =
|
||||
value->Int32Value(env->context()).FromMaybe(0);
|
||||
}
|
||||
|
||||
|
||||
static void DebugProcess(const FunctionCallbackInfo<Value>& args);
|
||||
static void DebugEnd(const FunctionCallbackInfo<Value>& args);
|
||||
|
||||
|
@ -905,6 +905,11 @@ void EnvSetter(v8::Local<v8::Name> property,
|
||||
void EnvQuery(v8::Local<v8::Name> property,
|
||||
const v8::PropertyCallbackInfo<v8::Integer>& info);
|
||||
void EnvEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info);
|
||||
void DebugPortGetter(v8::Local<v8::Name> property,
|
||||
const v8::PropertyCallbackInfo<v8::Value>& info);
|
||||
void DebugPortSetter(v8::Local<v8::Name> property,
|
||||
v8::Local<v8::Value> value,
|
||||
const v8::PropertyCallbackInfo<void>& info);
|
||||
|
||||
void GetParentProcessId(v8::Local<v8::Name> property,
|
||||
const v8::PropertyCallbackInfo<v8::Value>& info);
|
||||
|
@ -7,6 +7,10 @@
|
||||
#include "uv.h"
|
||||
#include "v8.h"
|
||||
|
||||
#if HAVE_INSPECTOR
|
||||
#include "inspector_io.h"
|
||||
#endif
|
||||
|
||||
#include <limits.h> // PATH_MAX
|
||||
#include <stdio.h>
|
||||
|
||||
@ -842,4 +846,29 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
|
||||
args.GetReturnValue().Set(ary);
|
||||
}
|
||||
|
||||
void DebugPortGetter(Local<Name> property,
|
||||
const PropertyCallbackInfo<Value>& info) {
|
||||
Environment* env = Environment::GetCurrent(info);
|
||||
Mutex::ScopedLock lock(process_mutex);
|
||||
int port = env->options()->debug_options->port();
|
||||
#if HAVE_INSPECTOR
|
||||
if (port == 0) {
|
||||
if (auto io = env->inspector_agent()->io())
|
||||
port = io->port();
|
||||
}
|
||||
#endif // HAVE_INSPECTOR
|
||||
info.GetReturnValue().Set(port);
|
||||
}
|
||||
|
||||
|
||||
void DebugPortSetter(Local<Name> property,
|
||||
Local<Value> value,
|
||||
const PropertyCallbackInfo<void>& info) {
|
||||
Environment* env = Environment::GetCurrent(info);
|
||||
Mutex::ScopedLock lock(process_mutex);
|
||||
env->options()->debug_options->host_port.port =
|
||||
value->Int32Value(env->context()).FromMaybe(0);
|
||||
}
|
||||
|
||||
|
||||
} // namespace node
|
||||
|
Loading…
x
Reference in New Issue
Block a user