Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,19 @@ NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(

NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
Environment* env, ThreadId thread_id, const char* url, const char* name) {
CHECK_NOT_NULL(env);
if (url == nullptr) url = "";
if (name == nullptr) name = "";
std::string_view url_view(url);
std::string_view name_view(name);
return GetInspectorParentHandle(env, thread_id, url_view, name_view);
}

NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
Environment* env,
ThreadId thread_id,
std::string_view url,
std::string_view name) {
CHECK_NOT_NULL(env);
CHECK_NE(thread_id.id, static_cast<uint64_t>(-1));
if (!env->should_create_inspector()) {
return nullptr;
Expand Down
8 changes: 4 additions & 4 deletions src/inspector/worker_inspector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ class WorkerFinishedRequest : public Request {

ParentInspectorHandle::ParentInspectorHandle(
uint64_t id,
const std::string& url,
std::string_view url,
std::shared_ptr<MainThreadHandle> parent_thread,
bool wait_for_connect,
const std::string& name,
std::string_view name,
std::shared_ptr<NetworkResourceManager> network_resource_manager)
: id_(id),
url_(url),
Expand Down Expand Up @@ -104,8 +104,8 @@ void WorkerManager::WorkerStarted(uint64_t session_id,

std::unique_ptr<ParentInspectorHandle> WorkerManager::NewParentHandle(
uint64_t thread_id,
const std::string& url,
const std::string& name,
std::string_view url,
std::string_view name,
std::shared_ptr<NetworkResourceManager> network_resource_manager) {
bool wait = !delegates_waiting_on_start_.empty();
return std::make_unique<ParentInspectorHandle>(
Expand Down
10 changes: 5 additions & 5 deletions src/inspector/worker_inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ class ParentInspectorHandle {
public:
ParentInspectorHandle(
uint64_t id,
const std::string& url,
std::string_view url,
std::shared_ptr<MainThreadHandle> parent_thread,
bool wait_for_connect,
const std::string& name,
std::string_view name,
std::shared_ptr<NetworkResourceManager> network_resource_manager);
~ParentInspectorHandle();
std::unique_ptr<ParentInspectorHandle> NewParentInspectorHandle(
uint64_t thread_id, const std::string& url, const std::string& name) {
uint64_t thread_id, std::string_view url, std::string_view name) {
return std::make_unique<ParentInspectorHandle>(
thread_id, url, parent_thread_, wait_, name, network_resource_manager_);
}
Expand Down Expand Up @@ -97,8 +97,8 @@ class WorkerManager : public std::enable_shared_from_this<WorkerManager> {

std::unique_ptr<ParentInspectorHandle> NewParentHandle(
uint64_t thread_id,
const std::string& url,
const std::string& name,
std::string_view url,
std::string_view name,
std::shared_ptr<NetworkResourceManager> network_resource_manager);
void WorkerStarted(uint64_t session_id, const WorkerInfo& info, bool waiting);
void WorkerFinished(uint64_t session_id);
Expand Down
2 changes: 1 addition & 1 deletion src/inspector_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ void Agent::SetParentHandle(
}

std::unique_ptr<ParentInspectorHandle> Agent::GetParentHandle(
uint64_t thread_id, const std::string& url, const std::string& name) {
uint64_t thread_id, std::string_view url, std::string_view name) {
THROW_IF_INSUFFICIENT_PERMISSIONS(parent_env_,
permission::PermissionScope::kInspector,
"GetParentHandle",
Expand Down
5 changes: 3 additions & 2 deletions src/inspector_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ class Agent {
void DisableAsyncHook();

void SetParentHandle(std::unique_ptr<ParentInspectorHandle> parent_handle);
std::unique_ptr<ParentInspectorHandle> GetParentHandle(
uint64_t thread_id, const std::string& url, const std::string& name);
std::unique_ptr<ParentInspectorHandle> GetParentHandle(uint64_t thread_id,
std::string_view url,
std::string_view name);

// Called to create inspector sessions that can be used from the same thread.
// The inspector responds by using the delegate to send messages back.
Expand Down
6 changes: 6 additions & 0 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,12 @@ NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
const char* child_url,
const char* name);

NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
Environment* parent_env,
ThreadId child_thread_id,
std::string_view child_url,
std::string_view name);

struct StartExecutionCallbackInfo {
v8::Local<v8::Object> process_object;
v8::Local<v8::Function> native_require;
Expand Down
2 changes: 1 addition & 1 deletion src/node_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Worker::Worker(Environment* env,
if (env->permission()->is_granted(
env, node::permission::PermissionScope::kInspector)) {
inspector_parent_handle_ =
GetInspectorParentHandle(env, thread_id_, url.c_str(), name.c_str());
GetInspectorParentHandle(env, thread_id_, url, name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

argv_ = std::vector<std::string>{env->argv()[0]};
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-worker-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (!isMainThread) {
const assert = require('assert');

if (isMainThread) {
const name = 'Hello Thread';
const name = 'Hello\0Thread';
const expectedTitle = `[worker 1] ${name}`;
const worker = new Worker(fixtures.path('worker-name.js'), {
name,
Expand Down
Loading