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

Unified Diff: test/inspector/task-runner.cc

Issue 2887013002: [inspector] Move IsolateData to a separate file (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/task-runner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/inspector/task-runner.cc
diff --git a/test/inspector/task-runner.cc b/test/inspector/task-runner.cc
index 5f21b9cab29d7576d59401f79b681e0d89e90f0d..b26680fdf646199bc0211f98121925644a8476f4 100644
--- a/test/inspector/task-runner.cc
+++ b/test/inspector/task-runner.cc
@@ -12,8 +12,6 @@
namespace {
-const int kIsolateDataIndex = 2;
-
void ReportUncaughtException(v8::Isolate* isolate,
const v8::TryCatch& try_catch) {
CHECK(try_catch.HasCaught());
@@ -31,64 +29,6 @@ v8::internal::Vector<uint16_t> ToVector(v8::Local<v8::String> str) {
} // namespace
-IsolateData::IsolateData(TaskRunner* task_runner,
- IsolateData::SetupGlobalTasks setup_global_tasks,
- v8::StartupData* startup_data)
- : task_runner_(task_runner),
- setup_global_tasks_(std::move(setup_global_tasks)) {
- v8::Isolate::CreateParams params;
- params.array_buffer_allocator =
- v8::ArrayBuffer::Allocator::NewDefaultAllocator();
- params.snapshot_blob = startup_data;
- isolate_ = v8::Isolate::New(params);
- isolate_->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped);
-}
-
-IsolateData* IsolateData::FromContext(v8::Local<v8::Context> context) {
- return static_cast<IsolateData*>(
- context->GetAlignedPointerFromEmbedderData(kIsolateDataIndex));
-}
-
-int IsolateData::CreateContextGroup() {
- v8::Local<v8::ObjectTemplate> global_template =
- v8::ObjectTemplate::New(isolate_);
- for (auto it = setup_global_tasks_.begin(); it != setup_global_tasks_.end();
- ++it) {
- (*it)->Run(isolate_, global_template);
- }
- v8::Local<v8::Context> context =
- v8::Context::New(isolate_, nullptr, global_template);
- context->SetAlignedPointerInEmbedderData(kIsolateDataIndex, this);
- int context_group_id = ++last_context_group_id_;
- contexts_[context_group_id].Reset(isolate_, context);
- return context_group_id;
-}
-
-v8::Local<v8::Context> IsolateData::GetContext(int context_group_id) {
- return contexts_[context_group_id].Get(isolate_);
-}
-
-void IsolateData::RegisterModule(v8::Local<v8::Context> context,
- v8::internal::Vector<uint16_t> name,
- v8::ScriptCompiler::Source* source) {
- v8::Local<v8::Module> module;
- if (!v8::ScriptCompiler::CompileModule(isolate(), source).ToLocal(&module))
- return;
- if (!module->Instantiate(context, &IsolateData::ModuleResolveCallback))
- return;
- v8::Local<v8::Value> result;
- if (!module->Evaluate(context).ToLocal(&result)) return;
- modules_[name] = v8::Global<v8::Module>(isolate_, module);
-}
-
-v8::MaybeLocal<v8::Module> IsolateData::ModuleResolveCallback(
- v8::Local<v8::Context> context, v8::Local<v8::String> specifier,
- v8::Local<v8::Module> referrer) {
- std::string str = *v8::String::Utf8Value(specifier);
- IsolateData* data = IsolateData::FromContext(context);
- return data->modules_[ToVector(specifier)].Get(data->isolate_);
-}
-
TaskRunner::TaskRunner(IsolateData::SetupGlobalTasks setup_global_tasks,
bool catch_exceptions,
v8::base::Semaphore* ready_semaphore,
« no previous file with comments | « test/inspector/task-runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698