Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 296fd57

Browse filesBrowse files
Eugene Ostroukhovtargos
authored andcommitted
inspector: stop dragging platform pointer
It is now easily accessible from the Environment Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
1 parent df0f7a3 commit 296fd57
Copy full SHA for 296fd57

File tree

Expand file treeCollapse file tree

7 files changed

+26
-37
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

7 files changed

+26
-37
lines changed
Open diff view settings
Collapse file

‎src/inspector_agent.cc‎

Copy file name to clipboardExpand all lines: src/inspector_agent.cc
+9-18Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,7 @@ class InspectorTimerHandle {
328328

329329
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 {
514514

515515
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
};
526525

527-
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) {}
532527

533528
// 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
}
537532

538-
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_);
566557

567558
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
}
Collapse file

‎src/inspector_agent.h‎

Copy file name to clipboardExpand all lines: src/inspector_agent.h
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ class Agent {
5050
~Agent();
5151

5252
// Create client_, may create io_ if option enabled
53-
bool Start(node::NodePlatform* platform, const char* path,
54-
const DebugOptions& options);
53+
bool Start(const char* path, const DebugOptions& options);
5554
// Stop and destroy io_
5655
void Stop();
5756

@@ -108,12 +107,11 @@ class Agent {
108107
node::Environment* parent_env_;
109108
std::shared_ptr<NodeInspectorClient> client_;
110109
std::unique_ptr<InspectorIo> io_;
111-
v8::Platform* platform_;
112110
std::string path_;
113111
DebugOptions debug_options_;
114112

115-
bool pending_enable_async_hook_;
116-
bool pending_disable_async_hook_;
113+
bool pending_enable_async_hook_ = false;
114+
bool pending_disable_async_hook_ = false;
117115
node::Persistent<v8::Function> enable_async_hook_function_;
118116
node::Persistent<v8::Function> disable_async_hook_function_;
119117
};
Collapse file

‎src/inspector_io.cc‎

Copy file name to clipboardExpand all lines: src/inspector_io.cc
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ class DispatchMessagesTask : public v8::Task {
162162
Agent* agent_;
163163
};
164164

165-
InspectorIo::InspectorIo(Environment* env, v8::Platform* platform,
166-
const std::string& path, const DebugOptions& options,
167-
bool wait_for_connect)
165+
InspectorIo::InspectorIo(Environment* env, const std::string& path,
166+
const DebugOptions& options, bool wait_for_connect)
168167
: options_(options), thread_(), state_(State::kNew),
169-
parent_env_(env), thread_req_(), platform_(platform),
168+
parent_env_(env), thread_req_(),
169+
platform_(parent_env_->isolate_data()->platform()),
170170
dispatching_messages_(false), script_name_(path),
171171
wait_for_connect_(wait_for_connect), port_(-1),
172172
id_(GenerateID()) {
Collapse file

‎src/inspector_io.h‎

Copy file name to clipboardExpand all lines: src/inspector_io.h
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ enum class TransportAction {
5353

5454
class InspectorIo {
5555
public:
56-
InspectorIo(node::Environment* env, v8::Platform* platform,
57-
const std::string& path, const DebugOptions& options,
58-
bool wait_for_connect);
56+
InspectorIo(node::Environment* env, const std::string& path,
57+
const DebugOptions& options, bool wait_for_connect);
5958

6059
~InspectorIo();
6160
// Start the inspector agent thread, waiting for it to initialize,
@@ -142,7 +141,8 @@ class InspectorIo {
142141
// Note that this will live while the async is being closed - likely, past
143142
// the parent object lifespan
144143
std::pair<uv_async_t, Agent*>* main_thread_req_;
145-
v8::Platform* platform_;
144+
// Will be used to post tasks from another thread
145+
v8::Platform* const platform_;
146146

147147
// Message queues
148148
ConditionVariable incoming_message_cond_;
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ static struct {
320320
// Inspector agent can't fail to start, but if it was configured to listen
321321
// right away on the websocket port and fails to bind/etc, this will return
322322
// false.
323-
return env->inspector_agent()->Start(platform_, script_path, options);
323+
return env->inspector_agent()->Start(script_path, options);
324324
}
325325

326326
bool InspectorStarted(Environment* env) {
Collapse file

‎src/node.h‎

Copy file name to clipboardExpand all lines: src/node.h
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ class Environment;
225225
class MultiIsolatePlatform : public v8::Platform {
226226
public:
227227
virtual ~MultiIsolatePlatform() { }
228+
// Returns true if work was dispatched or executed. New tasks that are
229+
// posted during flushing of the queue are postponed until the next
230+
// flushing.
231+
virtual bool FlushForegroundTasks(v8::Isolate* isolate) = 0;
228232
virtual void DrainBackgroundTasks(v8::Isolate* isolate) = 0;
229233
virtual void CancelPendingDelayedTasks(v8::Isolate* isolate) = 0;
230234

Collapse file

‎src/node_platform.h‎

Copy file name to clipboardExpand all lines: src/node_platform.h
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,7 @@ class NodePlatform : public MultiIsolatePlatform {
133133
double MonotonicallyIncreasingTime() override;
134134
double CurrentClockTimeMillis() override;
135135
v8::TracingController* GetTracingController() override;
136-
137-
// Returns true if work was dispatched or executed. New tasks that are
138-
// posted during flushing of the queue are postponed until the next
139-
// flushing.
140-
bool FlushForegroundTasks(v8::Isolate* isolate);
136+
bool FlushForegroundTasks(v8::Isolate* isolate) override;
141137

142138
void RegisterIsolate(IsolateData* isolate_data, uv_loop_t* loop) override;
143139
void UnregisterIsolate(IsolateData* isolate_data) override;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.