@kungfu-tech/libnode-win32-x64 0.0.0-bootstrap.0 → 22.22.3-kf.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +3 -0
- package/dist/node/include/acorn_version.h +6 -0
- package/dist/node/include/aliased_buffer-inl.h +244 -0
- package/dist/node/include/aliased_buffer.h +206 -0
- package/dist/node/include/aliased_struct-inl.h +54 -0
- package/dist/node/include/aliased_struct.h +63 -0
- package/dist/node/include/amaro_version.h +6 -0
- package/dist/node/include/async_context_frame.h +33 -0
- package/dist/node/include/async_wrap-inl.h +96 -0
- package/dist/node/include/async_wrap.h +243 -0
- package/dist/node/include/base_object-inl.h +335 -0
- package/dist/node/include/base_object.h +342 -0
- package/dist/node/include/base_object_types.h +74 -0
- package/dist/node/include/blob_serializer_deserializer-inl.h +385 -0
- package/dist/node/include/blob_serializer_deserializer.h +132 -0
- package/dist/node/include/callback_queue-inl.h +97 -0
- package/dist/node/include/callback_queue.h +79 -0
- package/dist/node/include/cares_wrap.h +447 -0
- package/dist/node/include/cjs_module_lexer_version.h +6 -0
- package/dist/node/include/cleanup_queue-inl.h +36 -0
- package/dist/node/include/cleanup_queue.h +79 -0
- package/dist/node/include/compile_cache.h +104 -0
- package/dist/node/include/connect_wrap.h +26 -0
- package/dist/node/include/connection_wrap.h +30 -0
- package/dist/node/include/cppgc/allocation.h +310 -0
- package/dist/node/include/cppgc/common.h +28 -0
- package/dist/node/include/cppgc/cross-thread-persistent.h +466 -0
- package/dist/node/include/cppgc/custom-space.h +97 -0
- package/dist/node/include/cppgc/default-platform.h +67 -0
- package/dist/node/include/cppgc/ephemeron-pair.h +30 -0
- package/dist/node/include/cppgc/explicit-management.h +100 -0
- package/dist/node/include/cppgc/garbage-collected.h +106 -0
- package/dist/node/include/cppgc/heap-consistency.h +309 -0
- package/dist/node/include/cppgc/heap-handle.h +48 -0
- package/dist/node/include/cppgc/heap-state.h +82 -0
- package/dist/node/include/cppgc/heap-statistics.h +120 -0
- package/dist/node/include/cppgc/heap.h +202 -0
- package/dist/node/include/cppgc/internal/api-constants.h +87 -0
- package/dist/node/include/cppgc/internal/atomic-entry-flag.h +48 -0
- package/dist/node/include/cppgc/internal/base-page-handle.h +45 -0
- package/dist/node/include/cppgc/internal/caged-heap-local-data.h +121 -0
- package/dist/node/include/cppgc/internal/caged-heap.h +68 -0
- package/dist/node/include/cppgc/internal/compiler-specific.h +38 -0
- package/dist/node/include/cppgc/internal/finalizer-trait.h +93 -0
- package/dist/node/include/cppgc/internal/gc-info.h +148 -0
- package/dist/node/include/cppgc/internal/logging.h +50 -0
- package/dist/node/include/cppgc/internal/member-storage.h +256 -0
- package/dist/node/include/cppgc/internal/name-trait.h +137 -0
- package/dist/node/include/cppgc/internal/persistent-node.h +214 -0
- package/dist/node/include/cppgc/internal/pointer-policies.h +243 -0
- package/dist/node/include/cppgc/internal/write-barrier.h +487 -0
- package/dist/node/include/cppgc/liveness-broker.h +78 -0
- package/dist/node/include/cppgc/macros.h +35 -0
- package/dist/node/include/cppgc/member.h +629 -0
- package/dist/node/include/cppgc/name-provider.h +65 -0
- package/dist/node/include/cppgc/object-size-trait.h +58 -0
- package/dist/node/include/cppgc/persistent.h +377 -0
- package/dist/node/include/cppgc/platform.h +163 -0
- package/dist/node/include/cppgc/prefinalizer.h +75 -0
- package/dist/node/include/cppgc/process-heap-statistics.h +36 -0
- package/dist/node/include/cppgc/sentinel-pointer.h +39 -0
- package/dist/node/include/cppgc/source-location.h +16 -0
- package/dist/node/include/cppgc/testing.h +106 -0
- package/dist/node/include/cppgc/trace-trait.h +128 -0
- package/dist/node/include/cppgc/type-traits.h +271 -0
- package/dist/node/include/cppgc/visitor.h +504 -0
- package/dist/node/include/crypto/crypto_aes.h +88 -0
- package/dist/node/include/crypto/crypto_bio.h +193 -0
- package/dist/node/include/crypto/crypto_cipher.h +293 -0
- package/dist/node/include/crypto/crypto_clienthello-inl.h +90 -0
- package/dist/node/include/crypto/crypto_clienthello.h +131 -0
- package/dist/node/include/crypto/crypto_common.h +64 -0
- package/dist/node/include/crypto/crypto_context.h +171 -0
- package/dist/node/include/crypto/crypto_dh.h +126 -0
- package/dist/node/include/crypto/crypto_dsa.h +52 -0
- package/dist/node/include/crypto/crypto_ec.h +164 -0
- package/dist/node/include/crypto/crypto_hash.h +91 -0
- package/dist/node/include/crypto/crypto_hkdf.h +61 -0
- package/dist/node/include/crypto/crypto_hmac.h +92 -0
- package/dist/node/include/crypto/crypto_keygen.h +299 -0
- package/dist/node/include/crypto/crypto_keys.h +392 -0
- package/dist/node/include/crypto/crypto_pbkdf2.h +74 -0
- package/dist/node/include/crypto/crypto_random.h +124 -0
- package/dist/node/include/crypto/crypto_rsa.h +136 -0
- package/dist/node/include/crypto/crypto_scrypt.h +85 -0
- package/dist/node/include/crypto/crypto_sig.h +165 -0
- package/dist/node/include/crypto/crypto_spkac.h +21 -0
- package/dist/node/include/crypto/crypto_timing.h +20 -0
- package/dist/node/include/crypto/crypto_tls.h +305 -0
- package/dist/node/include/crypto/crypto_util.h +725 -0
- package/dist/node/include/crypto/crypto_x509.h +140 -0
- package/dist/node/include/dataqueue/queue.h +306 -0
- package/dist/node/include/debug_utils-inl.h +278 -0
- package/dist/node/include/debug_utils.h +196 -0
- package/dist/node/include/diagnosticfilename-inl.h +33 -0
- package/dist/node/include/embedded_data.h +17 -0
- package/dist/node/include/encoding_binding.h +61 -0
- package/dist/node/include/env-inl.h +984 -0
- package/dist/node/include/env.h +1287 -0
- package/dist/node/include/env_properties.h +540 -0
- package/dist/node/include/handle_wrap.h +123 -0
- package/dist/node/include/histogram-inl.h +107 -0
- package/dist/node/include/histogram.h +279 -0
- package/dist/node/include/inspector/io_agent.h +30 -0
- package/dist/node/include/inspector/main_thread_interface.h +116 -0
- package/dist/node/include/inspector/network_agent.h +94 -0
- package/dist/node/include/inspector/network_inspector.h +45 -0
- package/dist/node/include/inspector/network_requests_buffer.h +195 -0
- package/dist/node/include/inspector/network_resource_manager.h +29 -0
- package/dist/node/include/inspector/node_json.h +24 -0
- package/dist/node/include/inspector/node_string.h +101 -0
- package/dist/node/include/inspector/protocol_helper.h +27 -0
- package/dist/node/include/inspector/runtime_agent.h +41 -0
- package/dist/node/include/inspector/target_agent.h +75 -0
- package/dist/node/include/inspector/tracing_agent.h +43 -0
- package/dist/node/include/inspector/worker_agent.h +40 -0
- package/dist/node/include/inspector/worker_inspector.h +124 -0
- package/dist/node/include/inspector_agent.h +165 -0
- package/dist/node/include/inspector_io.h +78 -0
- package/dist/node/include/inspector_profiler.h +149 -0
- package/dist/node/include/inspector_socket.h +60 -0
- package/dist/node/include/inspector_socket_server.h +110 -0
- package/dist/node/include/js_native_api.h +607 -0
- package/dist/node/include/js_native_api_types.h +226 -0
- package/dist/node/include/js_native_api_v8.h +485 -0
- package/dist/node/include/js_native_api_v8_internals.h +45 -0
- package/dist/node/include/js_stream.h +52 -0
- package/dist/node/include/json_utils.h +172 -0
- package/dist/node/include/large_pages/node_large_page.h +34 -0
- package/dist/node/include/libplatform/libplatform-export.h +29 -0
- package/dist/node/include/libplatform/libplatform.h +112 -0
- package/dist/node/include/libplatform/v8-tracing.h +333 -0
- package/dist/node/include/memory_tracker-inl.h +359 -0
- package/dist/node/include/memory_tracker.h +289 -0
- package/dist/node/include/module_wrap.h +216 -0
- package/dist/node/include/node.h +1593 -0
- package/dist/node/include/node_api.h +265 -0
- package/dist/node/include/node_api_internals.h +48 -0
- package/dist/node/include/node_api_types.h +56 -0
- package/dist/node/include/node_binding.h +161 -0
- package/dist/node/include/node_blob.h +159 -0
- package/dist/node/include/node_bob-inl.h +36 -0
- package/dist/node/include/node_bob.h +107 -0
- package/dist/node/include/node_buffer.h +92 -0
- package/dist/node/include/node_builtins.h +220 -0
- package/dist/node/include/node_config_file.h +46 -0
- package/dist/node/include/node_constants.h +82 -0
- package/dist/node/include/node_context_data.h +168 -0
- package/dist/node/include/node_contextify.h +204 -0
- package/dist/node/include/node_crypto.h +56 -0
- package/dist/node/include/node_debug.h +30 -0
- package/dist/node/include/node_dir.h +52 -0
- package/dist/node/include/node_dotenv.h +45 -0
- package/dist/node/include/node_errors.h +380 -0
- package/dist/node/include/node_exit_code.h +54 -0
- package/dist/node/include/node_external_reference.h +165 -0
- package/dist/node/include/node_file-inl.h +406 -0
- package/dist/node/include/node_file.h +537 -0
- package/dist/node/include/node_http2.h +1177 -0
- package/dist/node/include/node_http2_state.h +159 -0
- package/dist/node/include/node_http_common-inl.h +202 -0
- package/dist/node/include/node_http_common.h +535 -0
- package/dist/node/include/node_i18n.h +132 -0
- package/dist/node/include/node_internals.h +483 -0
- package/dist/node/include/node_main_instance.h +67 -0
- package/dist/node/include/node_mem-inl.h +113 -0
- package/dist/node/include/node_mem.h +45 -0
- package/dist/node/include/node_messaging.h +389 -0
- package/dist/node/include/node_metadata.h +164 -0
- package/dist/node/include/node_modules.h +91 -0
- package/dist/node/include/node_mutex.h +323 -0
- package/dist/node/include/node_object_wrap.h +132 -0
- package/dist/node/include/node_options-inl.h +490 -0
- package/dist/node/include/node_options.h +615 -0
- package/dist/node/include/node_perf.h +166 -0
- package/dist/node/include/node_perf_common.h +102 -0
- package/dist/node/include/node_platform.h +238 -0
- package/dist/node/include/node_process-inl.h +26 -0
- package/dist/node/include/node_process.h +112 -0
- package/dist/node/include/node_realm-inl.h +151 -0
- package/dist/node/include/node_realm.h +183 -0
- package/dist/node/include/node_report.h +43 -0
- package/dist/node/include/node_revert.h +82 -0
- package/dist/node/include/node_root_certs.h +3520 -0
- package/dist/node/include/node_sea.h +74 -0
- package/dist/node/include/node_shadow_realm.h +46 -0
- package/dist/node/include/node_snapshot_builder.h +57 -0
- package/dist/node/include/node_snapshotable.h +174 -0
- package/dist/node/include/node_sockaddr-inl.h +257 -0
- package/dist/node/include/node_sockaddr.h +394 -0
- package/dist/node/include/node_sqlite.h +270 -0
- package/dist/node/include/node_stat_watcher.h +73 -0
- package/dist/node/include/node_task_runner.h +92 -0
- package/dist/node/include/node_threadsafe_cow-inl.h +54 -0
- package/dist/node/include/node_threadsafe_cow.h +105 -0
- package/dist/node/include/node_union_bytes.h +81 -0
- package/dist/node/include/node_url.h +96 -0
- package/dist/node/include/node_v8.h +77 -0
- package/dist/node/include/node_v8_platform-inl.h +185 -0
- package/dist/node/include/node_version.h +110 -0
- package/dist/node/include/node_wasi.h +184 -0
- package/dist/node/include/node_wasm_web_api.h +55 -0
- package/dist/node/include/node_watchdog.h +154 -0
- package/dist/node/include/node_webstorage.h +60 -0
- package/dist/node/include/node_worker.h +158 -0
- package/dist/node/include/path.h +33 -0
- package/dist/node/include/permission/addon_permission.h +31 -0
- package/dist/node/include/permission/child_process_permission.h +31 -0
- package/dist/node/include/permission/fs_permission.h +167 -0
- package/dist/node/include/permission/inspector_permission.h +31 -0
- package/dist/node/include/permission/permission.h +138 -0
- package/dist/node/include/permission/permission_base.h +65 -0
- package/dist/node/include/permission/wasi_permission.h +31 -0
- package/dist/node/include/permission/worker_permission.h +31 -0
- package/dist/node/include/pipe_wrap.h +80 -0
- package/dist/node/include/quic/application.h +159 -0
- package/dist/node/include/quic/bindingdata.h +272 -0
- package/dist/node/include/quic/cid.h +127 -0
- package/dist/node/include/quic/data.h +148 -0
- package/dist/node/include/quic/defs.h +245 -0
- package/dist/node/include/quic/endpoint.h +458 -0
- package/dist/node/include/quic/http3.h +15 -0
- package/dist/node/include/quic/logstream.h +81 -0
- package/dist/node/include/quic/packet.h +152 -0
- package/dist/node/include/quic/preferredaddress.h +72 -0
- package/dist/node/include/quic/session.h +443 -0
- package/dist/node/include/quic/sessionticket.h +108 -0
- package/dist/node/include/quic/streams.h +232 -0
- package/dist/node/include/quic/tlscontext.h +227 -0
- package/dist/node/include/quic/tokens.h +256 -0
- package/dist/node/include/quic/transportparams.h +165 -0
- package/dist/node/include/req_wrap-inl.h +171 -0
- package/dist/node/include/req_wrap.h +77 -0
- package/dist/node/include/spawn_sync.h +243 -0
- package/dist/node/include/stream_base-inl.h +173 -0
- package/dist/node/include/stream_base.h +478 -0
- package/dist/node/include/stream_pipe.h +76 -0
- package/dist/node/include/stream_wrap.h +132 -0
- package/dist/node/include/string_bytes.h +113 -0
- package/dist/node/include/string_decoder-inl.h +31 -0
- package/dist/node/include/string_decoder.h +49 -0
- package/dist/node/include/tcp_wrap.h +105 -0
- package/dist/node/include/threadpoolwork-inl.h +70 -0
- package/dist/node/include/timer_wrap-inl.h +32 -0
- package/dist/node/include/timer_wrap.h +85 -0
- package/dist/node/include/timers.h +70 -0
- package/dist/node/include/tracing/agent.h +195 -0
- package/dist/node/include/tracing/node_trace_buffer.h +83 -0
- package/dist/node/include/tracing/node_trace_writer.h +75 -0
- package/dist/node/include/tracing/trace_event.h +722 -0
- package/dist/node/include/tracing/trace_event_common.h +1109 -0
- package/dist/node/include/tracing/traced_value.h +129 -0
- package/dist/node/include/tty_wrap.h +65 -0
- package/dist/node/include/udp_wrap.h +230 -0
- package/dist/node/include/undici_version.h +6 -0
- package/dist/node/include/util-inl.h +700 -0
- package/dist/node/include/util.h +1021 -0
- package/dist/node/include/uv/aix.h +32 -0
- package/dist/node/include/uv/bsd.h +34 -0
- package/dist/node/include/uv/darwin.h +61 -0
- package/dist/node/include/uv/errno.h +483 -0
- package/dist/node/include/uv/linux.h +34 -0
- package/dist/node/include/uv/os390.h +33 -0
- package/dist/node/include/uv/posix.h +31 -0
- package/dist/node/include/uv/sunos.h +44 -0
- package/dist/node/include/uv/threadpool.h +37 -0
- package/dist/node/include/uv/tree.h +521 -0
- package/dist/node/include/uv/unix.h +512 -0
- package/dist/node/include/uv/version.h +43 -0
- package/dist/node/include/uv/win.h +698 -0
- package/dist/node/include/uv.h +1990 -0
- package/dist/node/include/v8-array-buffer.h +525 -0
- package/dist/node/include/v8-callbacks.h +462 -0
- package/dist/node/include/v8-container.h +183 -0
- package/dist/node/include/v8-context.h +485 -0
- package/dist/node/include/v8-cppgc.h +245 -0
- package/dist/node/include/v8-data.h +80 -0
- package/dist/node/include/v8-date.h +48 -0
- package/dist/node/include/v8-debug.h +168 -0
- package/dist/node/include/v8-embedder-heap.h +82 -0
- package/dist/node/include/v8-embedder-state-scope.h +52 -0
- package/dist/node/include/v8-exception.h +223 -0
- package/dist/node/include/v8-extension.h +62 -0
- package/dist/node/include/v8-external.h +37 -0
- package/dist/node/include/v8-fast-api-calls.h +984 -0
- package/dist/node/include/v8-forward.h +82 -0
- package/dist/node/include/v8-function-callback.h +607 -0
- package/dist/node/include/v8-function.h +140 -0
- package/dist/node/include/v8-handle-base.h +137 -0
- package/dist/node/include/v8-initialization.h +289 -0
- package/dist/node/include/v8-inspector-protocol.h +13 -0
- package/dist/node/include/v8-inspector.h +419 -0
- package/dist/node/include/v8-internal.h +1397 -0
- package/dist/node/include/v8-isolate.h +1767 -0
- package/dist/node/include/v8-json.h +47 -0
- package/dist/node/include/v8-local-handle.h +758 -0
- package/dist/node/include/v8-locker.h +138 -0
- package/dist/node/include/v8-maybe.h +160 -0
- package/dist/node/include/v8-memory-span.h +198 -0
- package/dist/node/include/v8-message.h +233 -0
- package/dist/node/include/v8-metrics.h +264 -0
- package/dist/node/include/v8-microtask-queue.h +157 -0
- package/dist/node/include/v8-microtask.h +28 -0
- package/dist/node/include/v8-object.h +824 -0
- package/dist/node/include/v8-persistent-handle.h +582 -0
- package/dist/node/include/v8-platform.h +1358 -0
- package/dist/node/include/v8-primitive-object.h +118 -0
- package/dist/node/include/v8-primitive.h +877 -0
- package/dist/node/include/v8-profiler.h +1302 -0
- package/dist/node/include/v8-promise.h +174 -0
- package/dist/node/include/v8-proxy.h +50 -0
- package/dist/node/include/v8-regexp.h +106 -0
- package/dist/node/include/v8-script.h +904 -0
- package/dist/node/include/v8-snapshot.h +266 -0
- package/dist/node/include/v8-source-location.h +92 -0
- package/dist/node/include/v8-statistics.h +238 -0
- package/dist/node/include/v8-template.h +1297 -0
- package/dist/node/include/v8-traced-handle.h +432 -0
- package/dist/node/include/v8-typed-array.h +390 -0
- package/dist/node/include/v8-unwinder-state.h +31 -0
- package/dist/node/include/v8-unwinder.h +132 -0
- package/dist/node/include/v8-util.h +665 -0
- package/dist/node/include/v8-value-serializer-version.h +24 -0
- package/dist/node/include/v8-value-serializer.h +316 -0
- package/dist/node/include/v8-value.h +655 -0
- package/dist/node/include/v8-version-string.h +38 -0
- package/dist/node/include/v8-version.h +20 -0
- package/dist/node/include/v8-wasm-trap-handler-posix.h +31 -0
- package/dist/node/include/v8-wasm-trap-handler-win.h +28 -0
- package/dist/node/include/v8-wasm.h +201 -0
- package/dist/node/include/v8-weak-callback-info.h +80 -0
- package/dist/node/include/v8.h +88 -0
- package/dist/node/include/v8config.h +981 -0
- package/dist/node/include/zlib_version.h +6 -0
- package/dist/node/libnode.dll +0 -0
- package/dist/node/libnode.lib +0 -0
- package/dist/node/libnodebuildinfo.json +10 -0
- package/dist/node/link_node.lib +0 -0
- package/dist/node/link_node.node +0 -0
- package/index.js +5 -0
- package/libnode.release.json +8 -0
- package/package.json +29 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#ifndef SRC_INSPECTOR_WORKER_AGENT_H_
|
|
2
|
+
#define SRC_INSPECTOR_WORKER_AGENT_H_
|
|
3
|
+
|
|
4
|
+
#include "node/inspector/protocol/NodeWorker.h"
|
|
5
|
+
#include "v8.h"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
namespace node {
|
|
9
|
+
namespace inspector {
|
|
10
|
+
class WorkerManagerEventHandle;
|
|
11
|
+
class WorkerManager;
|
|
12
|
+
|
|
13
|
+
namespace protocol {
|
|
14
|
+
class NodeWorkers;
|
|
15
|
+
|
|
16
|
+
class WorkerAgent : public NodeWorker::Backend {
|
|
17
|
+
public:
|
|
18
|
+
explicit WorkerAgent(std::weak_ptr<WorkerManager> manager);
|
|
19
|
+
~WorkerAgent() override = default;
|
|
20
|
+
|
|
21
|
+
void Wire(UberDispatcher* dispatcher);
|
|
22
|
+
|
|
23
|
+
DispatchResponse sendMessageToWorker(const String& message,
|
|
24
|
+
const String& sessionId) override;
|
|
25
|
+
|
|
26
|
+
DispatchResponse enable(bool waitForDebuggerOnStart) override;
|
|
27
|
+
DispatchResponse disable() override;
|
|
28
|
+
DispatchResponse detach(const String& sessionId) override;
|
|
29
|
+
|
|
30
|
+
private:
|
|
31
|
+
std::shared_ptr<NodeWorker::Frontend> frontend_;
|
|
32
|
+
std::weak_ptr<WorkerManager> manager_;
|
|
33
|
+
std::unique_ptr<WorkerManagerEventHandle> event_handle_;
|
|
34
|
+
std::shared_ptr<NodeWorkers> workers_;
|
|
35
|
+
};
|
|
36
|
+
} // namespace protocol
|
|
37
|
+
} // namespace inspector
|
|
38
|
+
} // namespace node
|
|
39
|
+
|
|
40
|
+
#endif // SRC_INSPECTOR_WORKER_AGENT_H_
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#ifndef SRC_INSPECTOR_WORKER_INSPECTOR_H_
|
|
2
|
+
#define SRC_INSPECTOR_WORKER_INSPECTOR_H_
|
|
3
|
+
|
|
4
|
+
#include "inspector/network_resource_manager.h"
|
|
5
|
+
#if !HAVE_INSPECTOR
|
|
6
|
+
#error("This header can only be used when inspector is enabled")
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
#include <cstdint>
|
|
10
|
+
#include <memory>
|
|
11
|
+
#include <string>
|
|
12
|
+
#include <unordered_map>
|
|
13
|
+
#include <unordered_set>
|
|
14
|
+
|
|
15
|
+
namespace node {
|
|
16
|
+
namespace inspector {
|
|
17
|
+
class InspectorSession;
|
|
18
|
+
class InspectorSessionDelegate;
|
|
19
|
+
class MainThreadHandle;
|
|
20
|
+
class WorkerManager;
|
|
21
|
+
|
|
22
|
+
class WorkerDelegate {
|
|
23
|
+
public:
|
|
24
|
+
virtual void WorkerCreated(const std::string& title,
|
|
25
|
+
const std::string& url,
|
|
26
|
+
bool waiting,
|
|
27
|
+
std::shared_ptr<MainThreadHandle> worker) = 0;
|
|
28
|
+
virtual ~WorkerDelegate() = default;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
class WorkerManagerEventHandle {
|
|
32
|
+
public:
|
|
33
|
+
explicit WorkerManagerEventHandle(std::shared_ptr<WorkerManager> manager,
|
|
34
|
+
int id)
|
|
35
|
+
: manager_(manager), id_(id) {}
|
|
36
|
+
void SetWaitOnStart(bool wait_on_start);
|
|
37
|
+
~WorkerManagerEventHandle();
|
|
38
|
+
|
|
39
|
+
private:
|
|
40
|
+
std::shared_ptr<WorkerManager> manager_;
|
|
41
|
+
int id_;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
struct WorkerInfo {
|
|
45
|
+
WorkerInfo(const std::string& target_title,
|
|
46
|
+
const std::string& target_url,
|
|
47
|
+
std::shared_ptr<MainThreadHandle> worker_thread)
|
|
48
|
+
: title(target_title),
|
|
49
|
+
url(target_url),
|
|
50
|
+
worker_thread(worker_thread) {}
|
|
51
|
+
std::string title;
|
|
52
|
+
std::string url;
|
|
53
|
+
std::shared_ptr<MainThreadHandle> worker_thread;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
class ParentInspectorHandle {
|
|
57
|
+
public:
|
|
58
|
+
ParentInspectorHandle(
|
|
59
|
+
uint64_t id,
|
|
60
|
+
std::string_view url,
|
|
61
|
+
std::shared_ptr<MainThreadHandle> parent_thread,
|
|
62
|
+
bool wait_for_connect,
|
|
63
|
+
std::string_view name,
|
|
64
|
+
std::shared_ptr<NetworkResourceManager> network_resource_manager);
|
|
65
|
+
~ParentInspectorHandle();
|
|
66
|
+
std::unique_ptr<ParentInspectorHandle> NewParentInspectorHandle(
|
|
67
|
+
uint64_t thread_id, std::string_view url, std::string_view name) {
|
|
68
|
+
return std::make_unique<ParentInspectorHandle>(
|
|
69
|
+
thread_id, url, parent_thread_, wait_, name, network_resource_manager_);
|
|
70
|
+
}
|
|
71
|
+
void WorkerStarted(std::shared_ptr<MainThreadHandle> worker_thread,
|
|
72
|
+
bool waiting);
|
|
73
|
+
bool WaitForConnect() {
|
|
74
|
+
return wait_;
|
|
75
|
+
}
|
|
76
|
+
const std::string& url() const { return url_; }
|
|
77
|
+
std::unique_ptr<inspector::InspectorSession> Connect(
|
|
78
|
+
std::unique_ptr<inspector::InspectorSessionDelegate> delegate,
|
|
79
|
+
bool prevent_shutdown);
|
|
80
|
+
std::shared_ptr<NetworkResourceManager> GetNetworkResourceManager() {
|
|
81
|
+
return network_resource_manager_;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private:
|
|
85
|
+
uint64_t id_;
|
|
86
|
+
std::string url_;
|
|
87
|
+
std::shared_ptr<MainThreadHandle> parent_thread_;
|
|
88
|
+
bool wait_;
|
|
89
|
+
std::string name_;
|
|
90
|
+
std::shared_ptr<NetworkResourceManager> network_resource_manager_;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
class WorkerManager : public std::enable_shared_from_this<WorkerManager> {
|
|
94
|
+
public:
|
|
95
|
+
explicit WorkerManager(std::shared_ptr<MainThreadHandle> thread)
|
|
96
|
+
: thread_(thread) {}
|
|
97
|
+
|
|
98
|
+
std::unique_ptr<ParentInspectorHandle> NewParentHandle(
|
|
99
|
+
uint64_t thread_id,
|
|
100
|
+
std::string_view url,
|
|
101
|
+
std::string_view name,
|
|
102
|
+
std::shared_ptr<NetworkResourceManager> network_resource_manager);
|
|
103
|
+
void WorkerStarted(uint64_t session_id, const WorkerInfo& info, bool waiting);
|
|
104
|
+
void WorkerFinished(uint64_t session_id);
|
|
105
|
+
std::unique_ptr<WorkerManagerEventHandle> SetAutoAttach(
|
|
106
|
+
std::unique_ptr<WorkerDelegate> attach_delegate);
|
|
107
|
+
void SetWaitOnStartForDelegate(int id, bool wait);
|
|
108
|
+
void RemoveAttachDelegate(int id);
|
|
109
|
+
std::shared_ptr<MainThreadHandle> MainThread() {
|
|
110
|
+
return thread_;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private:
|
|
114
|
+
std::shared_ptr<MainThreadHandle> thread_;
|
|
115
|
+
std::unordered_map<uint64_t, WorkerInfo> children_;
|
|
116
|
+
std::unordered_map<int, std::unique_ptr<WorkerDelegate>> delegates_;
|
|
117
|
+
// If any one needs it, workers stop for all
|
|
118
|
+
std::unordered_set<int> delegates_waiting_on_start_;
|
|
119
|
+
int next_delegate_id_ = 0;
|
|
120
|
+
};
|
|
121
|
+
} // namespace inspector
|
|
122
|
+
} // namespace node
|
|
123
|
+
|
|
124
|
+
#endif // SRC_INSPECTOR_WORKER_INSPECTOR_H_
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "inspector/network_resource_manager.h"
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#if !HAVE_INSPECTOR
|
|
7
|
+
#error("This header can only be used when inspector is enabled")
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
#include "node_options.h"
|
|
11
|
+
#include "v8.h"
|
|
12
|
+
|
|
13
|
+
#include <cstddef>
|
|
14
|
+
#include <memory>
|
|
15
|
+
|
|
16
|
+
namespace v8_inspector {
|
|
17
|
+
class StringView;
|
|
18
|
+
} // namespace v8_inspector
|
|
19
|
+
|
|
20
|
+
namespace node {
|
|
21
|
+
// Forward declaration to break recursive dependency chain with src/env.h.
|
|
22
|
+
class Environment;
|
|
23
|
+
struct ContextInfo;
|
|
24
|
+
|
|
25
|
+
namespace inspector {
|
|
26
|
+
class InspectorIo;
|
|
27
|
+
class ParentInspectorHandle;
|
|
28
|
+
class NodeInspectorClient;
|
|
29
|
+
class WorkerManager;
|
|
30
|
+
|
|
31
|
+
class InspectorSession {
|
|
32
|
+
public:
|
|
33
|
+
virtual ~InspectorSession() = default;
|
|
34
|
+
virtual void Dispatch(const v8_inspector::StringView& message) = 0;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
class InspectorSessionDelegate {
|
|
38
|
+
public:
|
|
39
|
+
virtual ~InspectorSessionDelegate() = default;
|
|
40
|
+
virtual void SendMessageToFrontend(const v8_inspector::StringView& message)
|
|
41
|
+
= 0;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
class Agent {
|
|
45
|
+
public:
|
|
46
|
+
explicit Agent(node::Environment* env);
|
|
47
|
+
~Agent();
|
|
48
|
+
|
|
49
|
+
// Create client_, may create io_ if option enabled
|
|
50
|
+
bool Start(const std::string& path,
|
|
51
|
+
const DebugOptions& options,
|
|
52
|
+
std::shared_ptr<ExclusiveAccess<HostPort>> host_port,
|
|
53
|
+
bool is_main);
|
|
54
|
+
// Stop and destroy io_
|
|
55
|
+
void Stop();
|
|
56
|
+
|
|
57
|
+
bool IsListening() { return io_ != nullptr; }
|
|
58
|
+
// Returns true if the Node inspector is actually in use. It will be true
|
|
59
|
+
// if either the user explicitly opted into inspector (e.g. with the
|
|
60
|
+
// --inspect command line flag) or if inspector JS API had been used.
|
|
61
|
+
bool IsActive();
|
|
62
|
+
|
|
63
|
+
// Blocks till frontend connects and sends "runIfWaitingForDebugger"
|
|
64
|
+
void WaitForConnect();
|
|
65
|
+
bool WaitForConnectByOptions();
|
|
66
|
+
void StopIfWaitingForConnect();
|
|
67
|
+
|
|
68
|
+
// Blocks till all the sessions with "WaitForDisconnectOnShutdown" disconnect
|
|
69
|
+
void WaitForDisconnect();
|
|
70
|
+
void ReportUncaughtException(v8::Local<v8::Value> error,
|
|
71
|
+
v8::Local<v8::Message> message);
|
|
72
|
+
|
|
73
|
+
void EmitProtocolEvent(v8::Local<v8::Context> context,
|
|
74
|
+
const v8_inspector::StringView& event,
|
|
75
|
+
v8::Local<v8::Object> params);
|
|
76
|
+
|
|
77
|
+
void SetupNetworkTracking(v8::Local<v8::Function> enable_function,
|
|
78
|
+
v8::Local<v8::Function> disable_function);
|
|
79
|
+
void EnableNetworkTracking();
|
|
80
|
+
void DisableNetworkTracking();
|
|
81
|
+
|
|
82
|
+
// Async stack traces instrumentation.
|
|
83
|
+
void AsyncTaskScheduled(const v8_inspector::StringView& taskName, void* task,
|
|
84
|
+
bool recurring);
|
|
85
|
+
void AsyncTaskCanceled(void* task);
|
|
86
|
+
void AsyncTaskStarted(void* task);
|
|
87
|
+
void AsyncTaskFinished(void* task);
|
|
88
|
+
void AllAsyncTasksCanceled();
|
|
89
|
+
|
|
90
|
+
void RegisterAsyncHook(v8::Isolate* isolate,
|
|
91
|
+
v8::Local<v8::Function> enable_function,
|
|
92
|
+
v8::Local<v8::Function> disable_function);
|
|
93
|
+
void EnableAsyncHook();
|
|
94
|
+
void DisableAsyncHook();
|
|
95
|
+
|
|
96
|
+
void SetParentHandle(std::unique_ptr<ParentInspectorHandle> parent_handle);
|
|
97
|
+
std::unique_ptr<ParentInspectorHandle> GetParentHandle(uint64_t thread_id,
|
|
98
|
+
std::string_view url,
|
|
99
|
+
std::string_view name);
|
|
100
|
+
|
|
101
|
+
// Called to create inspector sessions that can be used from the same thread.
|
|
102
|
+
// The inspector responds by using the delegate to send messages back.
|
|
103
|
+
std::unique_ptr<InspectorSession> Connect(
|
|
104
|
+
std::unique_ptr<InspectorSessionDelegate> delegate,
|
|
105
|
+
bool prevent_shutdown);
|
|
106
|
+
|
|
107
|
+
// Called from the worker to create inspector sessions that is connected
|
|
108
|
+
// to the main thread.
|
|
109
|
+
// The inspector responds by using the delegate to send messages back.
|
|
110
|
+
std::unique_ptr<InspectorSession> ConnectToMainThread(
|
|
111
|
+
std::unique_ptr<InspectorSessionDelegate> delegate,
|
|
112
|
+
bool prevent_shutdown);
|
|
113
|
+
|
|
114
|
+
void PauseOnNextJavascriptStatement(const std::string& reason);
|
|
115
|
+
|
|
116
|
+
std::string GetWsUrl() const;
|
|
117
|
+
|
|
118
|
+
// Can only be called from the main thread.
|
|
119
|
+
bool StartIoThread();
|
|
120
|
+
|
|
121
|
+
// Calls StartIoThread() from off the main thread.
|
|
122
|
+
void RequestIoThreadStart();
|
|
123
|
+
|
|
124
|
+
const DebugOptions& options() { return debug_options_; }
|
|
125
|
+
std::shared_ptr<ExclusiveAccess<HostPort>> host_port() { return host_port_; }
|
|
126
|
+
void ContextCreated(v8::Local<v8::Context> context, const ContextInfo& info);
|
|
127
|
+
|
|
128
|
+
// Interface for interacting with inspectors in worker threads
|
|
129
|
+
std::shared_ptr<WorkerManager> GetWorkerManager();
|
|
130
|
+
|
|
131
|
+
inline Environment* env() const { return parent_env_; }
|
|
132
|
+
std::shared_ptr<NetworkResourceManager> GetNetworkResourceManager();
|
|
133
|
+
|
|
134
|
+
private:
|
|
135
|
+
void ToggleAsyncHook(v8::Isolate* isolate, v8::Local<v8::Function> fn);
|
|
136
|
+
void ToggleNetworkTracking(v8::Isolate* isolate, v8::Local<v8::Function> fn);
|
|
137
|
+
|
|
138
|
+
node::Environment* parent_env_;
|
|
139
|
+
// Encapsulates majority of the Inspector functionality
|
|
140
|
+
std::shared_ptr<NodeInspectorClient> client_;
|
|
141
|
+
// Interface for transports, e.g. WebSocket server
|
|
142
|
+
std::unique_ptr<InspectorIo> io_;
|
|
143
|
+
std::unique_ptr<ParentInspectorHandle> parent_handle_;
|
|
144
|
+
std::string path_;
|
|
145
|
+
|
|
146
|
+
// This is a copy of the debug options parsed from CLI in the Environment.
|
|
147
|
+
// Do not use the host_port in that, instead manipulate the shared host_port_
|
|
148
|
+
// pointer which is meant to store the actual host and port of the inspector
|
|
149
|
+
// server.
|
|
150
|
+
DebugOptions debug_options_;
|
|
151
|
+
std::shared_ptr<ExclusiveAccess<HostPort>> host_port_;
|
|
152
|
+
|
|
153
|
+
bool pending_enable_async_hook_ = false;
|
|
154
|
+
bool pending_disable_async_hook_ = false;
|
|
155
|
+
|
|
156
|
+
bool network_tracking_enabled_ = false;
|
|
157
|
+
bool pending_enable_network_tracking = false;
|
|
158
|
+
bool pending_disable_network_tracking = false;
|
|
159
|
+
std::shared_ptr<NetworkResourceManager> network_resource_manager_;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
} // namespace inspector
|
|
163
|
+
} // namespace node
|
|
164
|
+
|
|
165
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
4
|
+
|
|
5
|
+
#if !HAVE_INSPECTOR
|
|
6
|
+
#error("This header can only be used when inspector is enabled")
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
#include "inspector_socket_server.h"
|
|
10
|
+
#include "node_mutex.h"
|
|
11
|
+
|
|
12
|
+
#include "uv.h"
|
|
13
|
+
|
|
14
|
+
#include <cstddef>
|
|
15
|
+
#include <memory>
|
|
16
|
+
|
|
17
|
+
namespace node {
|
|
18
|
+
// Forward declaration to break recursive dependency chain with src/env.h.
|
|
19
|
+
class Environment;
|
|
20
|
+
namespace inspector {
|
|
21
|
+
|
|
22
|
+
class MainThreadHandle;
|
|
23
|
+
class RequestQueue;
|
|
24
|
+
|
|
25
|
+
class InspectorIo {
|
|
26
|
+
public:
|
|
27
|
+
// Start the inspector agent thread, waiting for it to initialize
|
|
28
|
+
// bool Start();
|
|
29
|
+
// Returns empty pointer if thread was not started
|
|
30
|
+
static std::unique_ptr<InspectorIo> Start(
|
|
31
|
+
std::shared_ptr<MainThreadHandle> main_thread,
|
|
32
|
+
const std::string& path,
|
|
33
|
+
std::shared_ptr<ExclusiveAccess<HostPort>> host_port,
|
|
34
|
+
const InspectPublishUid& inspect_publish_uid);
|
|
35
|
+
|
|
36
|
+
// Will block till the transport thread shuts down
|
|
37
|
+
~InspectorIo();
|
|
38
|
+
|
|
39
|
+
void StopAcceptingNewConnections();
|
|
40
|
+
std::string GetWsUrl() const;
|
|
41
|
+
|
|
42
|
+
private:
|
|
43
|
+
InspectorIo(std::shared_ptr<MainThreadHandle> handle,
|
|
44
|
+
const std::string& path,
|
|
45
|
+
std::shared_ptr<ExclusiveAccess<HostPort>> host_port,
|
|
46
|
+
const InspectPublishUid& inspect_publish_uid);
|
|
47
|
+
|
|
48
|
+
// Wrapper for agent->ThreadMain()
|
|
49
|
+
static void ThreadMain(void* agent);
|
|
50
|
+
|
|
51
|
+
// Runs a uv_loop_t
|
|
52
|
+
void ThreadMain();
|
|
53
|
+
|
|
54
|
+
// This is a thread-safe object that will post async tasks. It lives as long
|
|
55
|
+
// as an Inspector object lives (almost as long as an Isolate).
|
|
56
|
+
std::shared_ptr<MainThreadHandle> main_thread_;
|
|
57
|
+
// Used to post on a frontend interface thread, lives while the server is
|
|
58
|
+
// running
|
|
59
|
+
std::shared_ptr<RequestQueue> request_queue_;
|
|
60
|
+
std::shared_ptr<ExclusiveAccess<HostPort>> host_port_;
|
|
61
|
+
InspectPublishUid inspect_publish_uid_;
|
|
62
|
+
|
|
63
|
+
// The IO thread runs its own uv_loop to implement the TCP server off
|
|
64
|
+
// the main thread.
|
|
65
|
+
uv_thread_t thread_;
|
|
66
|
+
|
|
67
|
+
// For setting up interthread communications
|
|
68
|
+
Mutex thread_start_lock_;
|
|
69
|
+
ConditionVariable thread_start_condition_;
|
|
70
|
+
std::string script_name_;
|
|
71
|
+
// May be accessed from any thread
|
|
72
|
+
const std::string id_;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace inspector
|
|
76
|
+
} // namespace node
|
|
77
|
+
|
|
78
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#ifndef SRC_INSPECTOR_PROFILER_H_
|
|
2
|
+
#define SRC_INSPECTOR_PROFILER_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#if !HAVE_INSPECTOR
|
|
7
|
+
#error("This header can only be used when inspector is enabled")
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
#include <optional>
|
|
11
|
+
#include <unordered_set>
|
|
12
|
+
#include "inspector_agent.h"
|
|
13
|
+
#include "simdjson.h"
|
|
14
|
+
|
|
15
|
+
namespace node {
|
|
16
|
+
// Forward declaration to break recursive dependency chain with src/env.h.
|
|
17
|
+
class Environment;
|
|
18
|
+
|
|
19
|
+
namespace profiler {
|
|
20
|
+
|
|
21
|
+
class V8ProfilerConnection {
|
|
22
|
+
public:
|
|
23
|
+
class V8ProfilerSessionDelegate : public inspector::InspectorSessionDelegate {
|
|
24
|
+
public:
|
|
25
|
+
explicit V8ProfilerSessionDelegate(V8ProfilerConnection* connection)
|
|
26
|
+
: connection_(connection) {}
|
|
27
|
+
|
|
28
|
+
void SendMessageToFrontend(
|
|
29
|
+
const v8_inspector::StringView& message) override;
|
|
30
|
+
|
|
31
|
+
private:
|
|
32
|
+
V8ProfilerConnection* connection_;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
explicit V8ProfilerConnection(Environment* env);
|
|
36
|
+
virtual ~V8ProfilerConnection() = default;
|
|
37
|
+
|
|
38
|
+
Environment* env() const { return env_; }
|
|
39
|
+
|
|
40
|
+
// Dispatch a protocol message, and returns the id of the message.
|
|
41
|
+
// `method` does not need to be surrounded by quotes.
|
|
42
|
+
// The optional `params` should be formatted in JSON.
|
|
43
|
+
// The strings should be in one byte characters - which is enough for
|
|
44
|
+
// the commands we use here.
|
|
45
|
+
uint64_t DispatchMessage(const char* method,
|
|
46
|
+
const char* params = nullptr,
|
|
47
|
+
bool is_profile_request = false);
|
|
48
|
+
|
|
49
|
+
// Use DispatchMessage() to dispatch necessary inspector messages
|
|
50
|
+
// to start and end the profiling.
|
|
51
|
+
virtual void Start() = 0;
|
|
52
|
+
virtual void End() = 0;
|
|
53
|
+
|
|
54
|
+
// Return a descriptive name of the profile for debugging.
|
|
55
|
+
virtual const char* type() const = 0;
|
|
56
|
+
// Return if the profile is ending and the response can be parsed.
|
|
57
|
+
virtual bool ending() const = 0;
|
|
58
|
+
// Return the directory where the profile should be placed.
|
|
59
|
+
virtual std::string GetDirectory() const = 0;
|
|
60
|
+
// Return the filename the profile should be written as.
|
|
61
|
+
virtual std::string GetFilename() const = 0;
|
|
62
|
+
// Return the profile object parsed from `message.result`,
|
|
63
|
+
// which will be then written as a JSON.
|
|
64
|
+
virtual std::optional<std::string_view> GetProfile(
|
|
65
|
+
simdjson::ondemand::object* result);
|
|
66
|
+
virtual void WriteProfile(simdjson::ondemand::object* result);
|
|
67
|
+
|
|
68
|
+
bool HasProfileId(uint64_t id) const { return profile_ids_.contains(id); }
|
|
69
|
+
|
|
70
|
+
void RemoveProfileId(uint64_t id) { profile_ids_.erase(id); }
|
|
71
|
+
|
|
72
|
+
private:
|
|
73
|
+
uint64_t next_id() { return id_++; }
|
|
74
|
+
std::unique_ptr<inspector::InspectorSession> session_;
|
|
75
|
+
uint64_t id_ = 1;
|
|
76
|
+
std::unordered_set<uint64_t> profile_ids_;
|
|
77
|
+
|
|
78
|
+
protected:
|
|
79
|
+
simdjson::ondemand::parser json_parser_;
|
|
80
|
+
Environment* env_ = nullptr;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
class V8CoverageConnection : public V8ProfilerConnection {
|
|
84
|
+
public:
|
|
85
|
+
explicit V8CoverageConnection(Environment* env) : V8ProfilerConnection(env) {}
|
|
86
|
+
|
|
87
|
+
void Start() override;
|
|
88
|
+
void End() override;
|
|
89
|
+
|
|
90
|
+
const char* type() const override { return "coverage"; }
|
|
91
|
+
bool ending() const override { return ending_; }
|
|
92
|
+
|
|
93
|
+
std::string GetDirectory() const override;
|
|
94
|
+
std::string GetFilename() const override;
|
|
95
|
+
std::optional<std::string_view> GetProfile(
|
|
96
|
+
simdjson::ondemand::object* result) override;
|
|
97
|
+
void WriteProfile(simdjson::ondemand::object* result) override;
|
|
98
|
+
void WriteSourceMapCache();
|
|
99
|
+
void TakeCoverage();
|
|
100
|
+
void StopCoverage();
|
|
101
|
+
|
|
102
|
+
private:
|
|
103
|
+
std::unique_ptr<inspector::InspectorSession> session_;
|
|
104
|
+
bool ending_ = false;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
class V8CpuProfilerConnection : public V8ProfilerConnection {
|
|
108
|
+
public:
|
|
109
|
+
explicit V8CpuProfilerConnection(Environment* env)
|
|
110
|
+
: V8ProfilerConnection(env) {}
|
|
111
|
+
|
|
112
|
+
void Start() override;
|
|
113
|
+
void End() override;
|
|
114
|
+
|
|
115
|
+
const char* type() const override { return "CPU"; }
|
|
116
|
+
bool ending() const override { return ending_; }
|
|
117
|
+
|
|
118
|
+
std::string GetDirectory() const override;
|
|
119
|
+
std::string GetFilename() const override;
|
|
120
|
+
|
|
121
|
+
private:
|
|
122
|
+
std::unique_ptr<inspector::InspectorSession> session_;
|
|
123
|
+
bool ending_ = false;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
class V8HeapProfilerConnection : public V8ProfilerConnection {
|
|
127
|
+
public:
|
|
128
|
+
explicit V8HeapProfilerConnection(Environment* env)
|
|
129
|
+
: V8ProfilerConnection(env) {}
|
|
130
|
+
|
|
131
|
+
void Start() override;
|
|
132
|
+
void End() override;
|
|
133
|
+
|
|
134
|
+
const char* type() const override { return "heap"; }
|
|
135
|
+
bool ending() const override { return ending_; }
|
|
136
|
+
|
|
137
|
+
std::string GetDirectory() const override;
|
|
138
|
+
std::string GetFilename() const override;
|
|
139
|
+
|
|
140
|
+
private:
|
|
141
|
+
std::unique_ptr<inspector::InspectorSession> session_;
|
|
142
|
+
bool ending_ = false;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
} // namespace profiler
|
|
146
|
+
} // namespace node
|
|
147
|
+
|
|
148
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
149
|
+
#endif // SRC_INSPECTOR_PROFILER_H_
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#ifndef SRC_INSPECTOR_SOCKET_H_
|
|
2
|
+
#define SRC_INSPECTOR_SOCKET_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "util.h"
|
|
7
|
+
#include "uv.h"
|
|
8
|
+
|
|
9
|
+
#include <string>
|
|
10
|
+
#include <vector>
|
|
11
|
+
|
|
12
|
+
namespace node {
|
|
13
|
+
namespace inspector {
|
|
14
|
+
|
|
15
|
+
class ProtocolHandler;
|
|
16
|
+
|
|
17
|
+
// HTTP Wrapper around a uv_tcp_t
|
|
18
|
+
class InspectorSocket {
|
|
19
|
+
public:
|
|
20
|
+
class Delegate {
|
|
21
|
+
public:
|
|
22
|
+
virtual void OnHttpGet(const std::string& host,
|
|
23
|
+
const std::string& path) = 0;
|
|
24
|
+
virtual void OnSocketUpgrade(const std::string& host,
|
|
25
|
+
const std::string& path,
|
|
26
|
+
const std::string& accept_key) = 0;
|
|
27
|
+
virtual void OnWsFrame(const std::vector<char>& frame) = 0;
|
|
28
|
+
virtual ~Delegate() = default;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
using DelegatePointer = std::unique_ptr<Delegate>;
|
|
32
|
+
using Pointer = std::unique_ptr<InspectorSocket>;
|
|
33
|
+
|
|
34
|
+
static Pointer Accept(uv_stream_t* server, DelegatePointer delegate);
|
|
35
|
+
|
|
36
|
+
~InspectorSocket();
|
|
37
|
+
|
|
38
|
+
void AcceptUpgrade(const std::string& accept_key);
|
|
39
|
+
void CancelHandshake();
|
|
40
|
+
void Write(const char* data, size_t len);
|
|
41
|
+
void SwitchProtocol(ProtocolHandler* handler);
|
|
42
|
+
std::string GetHost();
|
|
43
|
+
|
|
44
|
+
InspectorSocket(const InspectorSocket&) = delete;
|
|
45
|
+
InspectorSocket& operator=(const InspectorSocket&) = delete;
|
|
46
|
+
|
|
47
|
+
private:
|
|
48
|
+
static void Shutdown(ProtocolHandler*);
|
|
49
|
+
InspectorSocket() = default;
|
|
50
|
+
|
|
51
|
+
DeleteFnPtr<ProtocolHandler, Shutdown> protocol_handler_;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
} // namespace inspector
|
|
56
|
+
} // namespace node
|
|
57
|
+
|
|
58
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
59
|
+
|
|
60
|
+
#endif // SRC_INSPECTOR_SOCKET_H_
|