Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Unified Diff: test/inspector/inspector-impl.cc

Issue 2885253002: [inspector] Extract IsolateData out of TaskRunner (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/inspector/inspector-impl.h ('k') | test/inspector/inspector-test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/inspector/inspector-impl.cc
diff --git a/test/inspector/inspector-impl.cc b/test/inspector/inspector-impl.cc
index 408f47529227e42eee5af6c5949e1e921eb25046..16048f1f259dfcfe6c47243da06c37c0a61dac31 100644
--- a/test/inspector/inspector-impl.cc
+++ b/test/inspector/inspector-impl.cc
@@ -117,7 +117,7 @@ class ConnectTask : public TaskRunner::Task {
private:
void Run() override {
v8::HandleScope handle_scope(isolate());
- client_->connect(default_context());
+ client_->connect();
if (ready_semaphore_) ready_semaphore_->Signal();
}
@@ -150,7 +150,7 @@ class DisconnectTask : public TaskRunner::Task {
class CreateContextGroupTask : public TaskRunner::Task {
public:
CreateContextGroupTask(InspectorClientImpl* client,
- TaskRunner::SetupGlobalTasks setup_global_tasks,
+ IsolateData::SetupGlobalTasks setup_global_tasks,
v8::base::Semaphore* ready_semaphore,
int* context_group_id)
: client_(client),
@@ -168,7 +168,7 @@ class CreateContextGroupTask : public TaskRunner::Task {
}
InspectorClientImpl* client_;
- TaskRunner::SetupGlobalTasks setup_global_tasks_;
+ IsolateData::SetupGlobalTasks setup_global_tasks_;
v8::base::Semaphore* ready_semaphore_;
int* context_group_id_;
};
@@ -184,40 +184,35 @@ InspectorClientImpl::InspectorClientImpl(TaskRunner* task_runner,
InspectorClientImpl::~InspectorClientImpl() {}
-void InspectorClientImpl::connect(v8::Local<v8::Context> context) {
- isolate_ = context->GetIsolate();
+void InspectorClientImpl::connect() {
+ isolate_ = task_runner_->data()->isolate();
isolate_->AddMessageListener(MessageHandler);
channel_.reset(new ChannelImpl(frontend_channel_));
inspector_ = v8_inspector::V8Inspector::create(isolate_, this);
if (states_.empty()) {
- int context_group_id = TaskRunner::GetContextGroupId(context);
- v8_inspector::StringView state;
- sessions_[context_group_id] =
- inspector_->connect(context_group_id, channel_.get(), state);
- context->SetAlignedPointerInEmbedderData(kInspectorClientIndex, this);
- v8_inspector::V8ContextInfo info(context, context_group_id,
- v8_inspector::StringView());
- info.hasMemoryOnConsole = true;
- inspector_->contextCreated(info);
+ ConnectToContextGroup(task_runner_->default_context_group_id(),
+ v8_inspector::StringView());
} else {
- for (const auto& it : states_) {
- int context_group_id = it.first;
- v8::Local<v8::Context> context =
- task_runner_->GetContext(context_group_id);
- v8_inspector::StringView state = it.second->string();
- sessions_[context_group_id] =
- inspector_->connect(context_group_id, channel_.get(), state);
- context->SetAlignedPointerInEmbedderData(kInspectorClientIndex, this);
- v8_inspector::V8ContextInfo info(context, context_group_id,
- v8_inspector::StringView());
- info.hasMemoryOnConsole = true;
- inspector_->contextCreated(info);
- }
+ for (const auto& it : states_)
+ ConnectToContextGroup(it.first, it.second->string());
}
states_.clear();
}
+void InspectorClientImpl::ConnectToContextGroup(
+ int context_group_id, v8_inspector::StringView state) {
+ v8::Local<v8::Context> context =
+ task_runner_->data()->GetContext(context_group_id);
+ sessions_[context_group_id] =
+ inspector_->connect(context_group_id, channel_.get(), state);
+ context->SetAlignedPointerInEmbedderData(kInspectorClientIndex, this);
+ v8_inspector::V8ContextInfo info(context, context_group_id,
+ v8_inspector::StringView());
+ info.hasMemoryOnConsole = true;
+ inspector_->contextCreated(info);
+}
+
void InspectorClientImpl::scheduleReconnect(
v8::base::Semaphore* ready_semaphore) {
task_runner_->Append(
@@ -240,19 +235,19 @@ void InspectorClientImpl::disconnect(bool reset_inspector) {
}
void InspectorClientImpl::scheduleCreateContextGroup(
- TaskRunner::SetupGlobalTasks setup_global_tasks,
+ IsolateData::SetupGlobalTasks setup_global_tasks,
v8::base::Semaphore* ready_semaphore, int* context_group_id) {
task_runner_->Append(new CreateContextGroupTask(
this, std::move(setup_global_tasks), ready_semaphore, context_group_id));
}
int InspectorClientImpl::createContextGroup(
- const TaskRunner::SetupGlobalTasks& setup_global_tasks) {
+ const IsolateData::SetupGlobalTasks& setup_global_tasks) {
v8::HandleScope handle_scope(isolate_);
+ int context_group_id = task_runner_->data()->CreateContextGroup();
v8::Local<v8::Context> context =
- task_runner_->NewContextGroup(setup_global_tasks);
+ task_runner_->data()->GetContext(context_group_id);
context->SetAlignedPointerInEmbedderData(kInspectorClientIndex, this);
- int context_group_id = TaskRunner::GetContextGroupId(context);
v8_inspector::StringView state;
sessions_[context_group_id] =
inspector_->connect(context_group_id, channel_.get(), state);
@@ -278,7 +273,7 @@ bool InspectorClientImpl::formatAccessorsAsProperties(
v8::Local<v8::Context> InspectorClientImpl::ensureDefaultContextInGroup(
int context_group_id) {
CHECK(isolate_);
- return task_runner_->GetContext(context_group_id);
+ return task_runner_->data()->GetContext(context_group_id);
}
void InspectorClientImpl::setCurrentTimeMSForTest(double time) {
@@ -335,8 +330,12 @@ v8_inspector::V8Inspector* InspectorClientImpl::InspectorFromContext(
v8_inspector::V8InspectorSession* InspectorClientImpl::SessionFromContext(
v8::Local<v8::Context> context) {
- int context_group_id = TaskRunner::GetContextGroupId(context);
- return InspectorClientFromContext(context)->sessions_[context_group_id].get();
+ InspectorClientImpl* client = InspectorClientFromContext(context);
+ for (auto& it : client->sessions_) {
+ if (client->task_runner_->data()->GetContext(it.first) == context)
+ return it.second.get();
+ }
+ return nullptr;
}
v8_inspector::V8InspectorSession* InspectorClientImpl::session(
« no previous file with comments | « test/inspector/inspector-impl.h ('k') | test/inspector/inspector-test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698