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

Unified Diff: test/inspector/isolate-data.cc

Issue 2890463004: [inspector] Refactor inspector test (Closed)
Patch Set: better crash fix 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/isolate-data.h ('k') | test/inspector/json-parse.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/inspector/isolate-data.cc
diff --git a/test/inspector/isolate-data.cc b/test/inspector/isolate-data.cc
index 06ba710b3ed164a8ac2b63ab9239fde533860244..927bd31ef43e326c594d02488d97833baac3edf4 100644
--- a/test/inspector/isolate-data.cc
+++ b/test/inspector/isolate-data.cc
@@ -10,6 +10,7 @@
namespace {
const int kIsolateDataIndex = 2;
+const int kContextGroupIdIndex = 3;
v8::internal::Vector<uint16_t> ToVector(v8::Local<v8::String> str) {
v8::internal::Vector<uint16_t> buffer =
@@ -22,7 +23,8 @@ v8::internal::Vector<uint16_t> ToVector(v8::Local<v8::String> str) {
IsolateData::IsolateData(TaskRunner* task_runner,
IsolateData::SetupGlobalTasks setup_global_tasks,
- v8::StartupData* startup_data)
+ v8::StartupData* startup_data,
+ InspectorClientImpl::FrontendChannel* channel)
: task_runner_(task_runner),
setup_global_tasks_(std::move(setup_global_tasks)) {
v8::Isolate::CreateParams params;
@@ -31,6 +33,8 @@ IsolateData::IsolateData(TaskRunner* task_runner,
params.snapshot_blob = startup_data;
isolate_ = v8::Isolate::New(params);
isolate_->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped);
+ if (channel)
+ inspector_.reset(new InspectorClientImpl(isolate_, task_runner, channel));
}
IsolateData* IsolateData::FromContext(v8::Local<v8::Context> context) {
@@ -39,6 +43,7 @@ IsolateData* IsolateData::FromContext(v8::Local<v8::Context> context) {
}
int IsolateData::CreateContextGroup() {
+ v8::HandleScope handle_scope(isolate_);
v8::Local<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(isolate_);
for (auto it = setup_global_tasks_.begin(); it != setup_global_tasks_.end();
@@ -49,7 +54,11 @@ int IsolateData::CreateContextGroup() {
v8::Context::New(isolate_, nullptr, global_template);
context->SetAlignedPointerInEmbedderData(kIsolateDataIndex, this);
int context_group_id = ++last_context_group_id_;
+ // Should be 2-byte aligned.
+ context->SetAlignedPointerInEmbedderData(
+ kContextGroupIdIndex, reinterpret_cast<void*>(context_group_id * 2));
contexts_[context_group_id].Reset(isolate_, context);
+ if (inspector_) inspector_->ContextCreated(context, context_group_id);
return context_group_id;
}
@@ -57,6 +66,13 @@ v8::Local<v8::Context> IsolateData::GetContext(int context_group_id) {
return contexts_[context_group_id].Get(isolate_);
}
+int IsolateData::GetContextGroupId(v8::Local<v8::Context> context) {
+ return static_cast<int>(
+ reinterpret_cast<intptr_t>(
+ context->GetAlignedPointerFromEmbedderData(kContextGroupIdIndex)) /
+ 2);
+}
+
void IsolateData::RegisterModule(v8::Local<v8::Context> context,
v8::internal::Vector<uint16_t> name,
v8::ScriptCompiler::Source* source) {
« no previous file with comments | « test/inspector/isolate-data.h ('k') | test/inspector/json-parse.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698