| Index: test/inspector/isolate-data.h
|
| diff --git a/test/inspector/isolate-data.h b/test/inspector/isolate-data.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8a5555d0518a2684e179efabd3b99f2a815e855f
|
| --- /dev/null
|
| +++ b/test/inspector/isolate-data.h
|
| @@ -0,0 +1,62 @@
|
| +// Copyright 2017 the V8 project authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef V8_TEST_INSPECTOR_PROTOCOL_ISOLATE_DATA_H_
|
| +#define V8_TEST_INSPECTOR_PROTOCOL_ISOLATE_DATA_H_
|
| +
|
| +#include <map>
|
| +
|
| +#include "include/v8-inspector.h"
|
| +#include "include/v8-platform.h"
|
| +#include "include/v8.h"
|
| +#include "src/vector.h"
|
| +
|
| +class TaskRunner;
|
| +
|
| +class IsolateData {
|
| + public:
|
| + class SetupGlobalTask {
|
| + public:
|
| + virtual ~SetupGlobalTask() = default;
|
| + virtual void Run(v8::Isolate* isolate,
|
| + v8::Local<v8::ObjectTemplate> global) = 0;
|
| + };
|
| + using SetupGlobalTasks = std::vector<std::unique_ptr<SetupGlobalTask>>;
|
| +
|
| + IsolateData(TaskRunner* task_runner, SetupGlobalTasks setup_global_tasks,
|
| + v8::StartupData* startup_data);
|
| + static IsolateData* FromContext(v8::Local<v8::Context> context);
|
| +
|
| + v8::Isolate* isolate() const { return isolate_; }
|
| + TaskRunner* task_runner() const { return task_runner_; }
|
| + int CreateContextGroup();
|
| + v8::Local<v8::Context> GetContext(int context_group_id);
|
| + void RegisterModule(v8::Local<v8::Context> context,
|
| + v8::internal::Vector<uint16_t> name,
|
| + v8::ScriptCompiler::Source* source);
|
| +
|
| + private:
|
| + struct VectorCompare {
|
| + bool operator()(const v8::internal::Vector<uint16_t>& lhs,
|
| + const v8::internal::Vector<uint16_t>& rhs) const {
|
| + for (int i = 0; i < lhs.length() && i < rhs.length(); ++i) {
|
| + if (lhs[i] != rhs[i]) return lhs[i] < rhs[i];
|
| + }
|
| + return false;
|
| + }
|
| + };
|
| + static v8::MaybeLocal<v8::Module> ModuleResolveCallback(
|
| + v8::Local<v8::Context> context, v8::Local<v8::String> specifier,
|
| + v8::Local<v8::Module> referrer);
|
| +
|
| + TaskRunner* task_runner_;
|
| + SetupGlobalTasks setup_global_tasks_;
|
| + v8::Isolate* isolate_;
|
| + int last_context_group_id_ = 0;
|
| + std::map<int, v8::Global<v8::Context>> contexts_;
|
| + std::map<v8::internal::Vector<uint16_t>, v8::Global<v8::Module>,
|
| + VectorCompare>
|
| + modules_;
|
| +};
|
| +#endif // V8_TEST_INSPECTOR_PROTOCOL_ISOLATE_DATA_H_
|
|
|