◐ Shell
clean mode source ↗

inspector: stop dragging platform pointer · nodejs/node@296fd57

@@ -328,8 +328,7 @@ class InspectorTimerHandle {

328328329329

class NodeInspectorClient : public V8InspectorClient {

330330

public:

331-

NodeInspectorClient(node::Environment* env, node::NodePlatform* platform)

332-

: env_(env), platform_(platform) {

331+

explicit NodeInspectorClient(node::Environment* env) : env_(env) {

333332

client_ = V8Inspector::create(env->isolate(), this);

334333

// TODO(bnoordhuis) Make name configurable from src/node.cc.

335334

ContextInfo info(GetHumanReadableProcessName());

@@ -346,8 +345,9 @@ class NodeInspectorClient : public V8InspectorClient {

346345

return;

347346

terminated_ = false;

348347

running_nested_loop_ = true;

348+

MultiIsolatePlatform* platform = env_->isolate_data()->platform();

349349

while ((ignore_terminated || !terminated_) && waitForFrontendEvent()) {

350-

while (platform_->FlushForegroundTasks(env_->isolate())) {}

350+

while (platform->FlushForegroundTasks(env_->isolate())) {}

351351

}

352352

terminated_ = false;

353353

running_nested_loop_ = false;

@@ -514,7 +514,6 @@ class NodeInspectorClient : public V8InspectorClient {

514514515515

private:

516516

node::Environment* env_;

517-

node::NodePlatform* platform_;

518517

bool terminated_ = false;

519518

bool running_nested_loop_ = false;

520519

std::unique_ptr<V8Inspector> client_;

@@ -524,25 +523,17 @@ class NodeInspectorClient : public V8InspectorClient {

524523

bool events_dispatched_ = false;

525524

};

526525527-

Agent::Agent(Environment* env) : parent_env_(env),

528-

client_(nullptr),

529-

platform_(nullptr),

530-

pending_enable_async_hook_(false),

531-

pending_disable_async_hook_(false) {}

526+

Agent::Agent(Environment* env) : parent_env_(env) {}

532527533528

// Destructor needs to be defined here in implementation file as the header

534529

// does not have full definition of some classes.

535530

Agent::~Agent() {

536531

}

537532538-

bool Agent::Start(node::NodePlatform* platform, const char* path,

539-

const DebugOptions& options) {

533+

bool Agent::Start(const char* path, const DebugOptions& options) {

540534

path_ = path == nullptr ? "" : path;

541535

debug_options_ = options;

542-

client_ =

543-

std::shared_ptr<NodeInspectorClient>(

544-

new NodeInspectorClient(parent_env_, platform));

545-

platform_ = platform;

536+

client_ = std::make_shared<NodeInspectorClient>(parent_env_);

546537

CHECK_EQ(0, uv_async_init(uv_default_loop(),

547538

&start_io_thread_async,

548539

StartIoThreadAsyncCallback));

@@ -565,8 +556,7 @@ bool Agent::StartIoThread(bool wait_for_connect) {

565556

CHECK_NOT_NULL(client_);

566557567558

io_ = std::unique_ptr<InspectorIo>(

568-

new InspectorIo(parent_env_, platform_, path_, debug_options_,

569-

wait_for_connect));

559+

new InspectorIo(parent_env_, path_, debug_options_, wait_for_connect));

570560

if (!io_->Start()) {

571561

client_.reset();

572562

return false;

@@ -716,7 +706,8 @@ void Agent::RequestIoThreadStart() {

716706

// for IO events)

717707

uv_async_send(&start_io_thread_async);

718708

v8::Isolate* isolate = parent_env_->isolate();

719-

platform_->CallOnForegroundThread(isolate, new StartIoTask(this));

709+

v8::Platform* platform = parent_env_->isolate_data()->platform();

710+

platform->CallOnForegroundThread(isolate, new StartIoTask(this));

720711

isolate->RequestInterrupt(StartIoInterrupt, this);

721712

uv_async_send(&start_io_thread_async);

722713

}