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:
James M Snell 2018-09-07 16:19:03 -07:00 committed by Anna Henningsen
parent efd4796fa9
commit eaaee92d9b
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9
3 changed files with 34 additions and 27 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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