Index: test/inspector/isolate-data.h |
diff --git a/test/inspector/isolate-data.h b/test/inspector/isolate-data.h |
index 34f0ae83086f23dafd1710a05fedadde1d1d5173..614a564b91fa80ae57a8a8dbe52a836b9fc94cdd 100644 |
--- a/test/inspector/isolate-data.h |
+++ b/test/inspector/isolate-data.h |
@@ -10,12 +10,13 @@ |
#include "include/v8-inspector.h" |
#include "include/v8-platform.h" |
#include "include/v8.h" |
+#include "src/base/macros.h" |
+#include "src/base/platform/platform.h" |
#include "src/vector.h" |
-#include "test/inspector/inspector-impl.h" |
class TaskRunner; |
-class IsolateData { |
+class IsolateData : public v8_inspector::V8InspectorClient { |
public: |
class SetupGlobalTask { |
public: |
@@ -25,14 +26,22 @@ class IsolateData { |
}; |
using SetupGlobalTasks = std::vector<std::unique_ptr<SetupGlobalTask>>; |
+ class FrontendChannel { |
+ public: |
+ virtual ~FrontendChannel() = default; |
+ virtual void SendMessageToFrontend( |
+ int session_id, const v8_inspector::StringView& message) = 0; |
+ }; |
+ |
IsolateData(TaskRunner* task_runner, SetupGlobalTasks setup_global_tasks, |
- v8::StartupData* startup_data, |
- InspectorClientImpl::FrontendChannel* channel); |
+ v8::StartupData* startup_data, FrontendChannel* channel); |
static IsolateData* FromContext(v8::Local<v8::Context> context); |
v8::Isolate* isolate() const { return isolate_; } |
- InspectorClientImpl* inspector() const { return inspector_.get(); } |
+ v8_inspector::V8Inspector* inspector() const { return inspector_.get(); } |
TaskRunner* task_runner() const { return task_runner_; } |
+ |
+ // Setting things up. |
int CreateContextGroup(); |
v8::Local<v8::Context> GetContext(int context_group_id); |
int GetContextGroupId(v8::Local<v8::Context> context); |
@@ -40,6 +49,26 @@ class IsolateData { |
v8::internal::Vector<uint16_t> name, |
v8::ScriptCompiler::Source* source); |
+ // Working with V8Inspector api. |
+ int ConnectSession(int context_group_id, |
+ const v8_inspector::StringView& state); |
+ std::unique_ptr<v8_inspector::StringBuffer> DisconnectSession(int session_id); |
+ void SendMessage(int session_id, const v8_inspector::StringView& message); |
+ void BreakProgram(int context_group_id, |
+ const v8_inspector::StringView& reason, |
+ const v8_inspector::StringView& details); |
+ void SchedulePauseOnNextStatement(int context_group_id, |
+ const v8_inspector::StringView& reason, |
+ const v8_inspector::StringView& details); |
+ void CancelPauseOnNextStatement(int context_group_id); |
+ |
+ // Test utilities. |
+ void SetCurrentTimeMS(double time); |
+ void SetMemoryInfo(v8::Local<v8::Value> memory_info); |
+ void SetLogConsoleApiMessageCalls(bool log); |
+ void FireContextCreated(v8::Local<v8::Context> context, int context_group_id); |
+ void FireContextDestroyed(v8::Local<v8::Context> context); |
+ |
private: |
struct VectorCompare { |
bool operator()(const v8::internal::Vector<uint16_t>& lhs, |
@@ -53,15 +82,46 @@ class IsolateData { |
static v8::MaybeLocal<v8::Module> ModuleResolveCallback( |
v8::Local<v8::Context> context, v8::Local<v8::String> specifier, |
v8::Local<v8::Module> referrer); |
+ static void MessageHandler(v8::Local<v8::Message> message, |
+ v8::Local<v8::Value> exception); |
+ std::vector<int> GetSessionIds(int context_group_id); |
+ |
+ // V8InspectorClient implementation. |
+ bool formatAccessorsAsProperties(v8::Local<v8::Value>) override; |
+ v8::Local<v8::Context> ensureDefaultContextInGroup( |
+ int context_group_id) override; |
+ double currentTimeMS() override; |
+ v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate* isolate, |
+ v8::Local<v8::Context>) override; |
+ void runMessageLoopOnPause(int context_group_id) override; |
+ void quitMessageLoopOnPause() override; |
+ void consoleAPIMessage(int contextGroupId, |
+ v8::Isolate::MessageErrorLevel level, |
+ const v8_inspector::StringView& message, |
+ const v8_inspector::StringView& url, |
+ unsigned lineNumber, unsigned columnNumber, |
+ v8_inspector::V8StackTrace*) override; |
TaskRunner* task_runner_; |
SetupGlobalTasks setup_global_tasks_; |
v8::Isolate* isolate_; |
- std::unique_ptr<InspectorClientImpl> inspector_; |
+ std::unique_ptr<v8_inspector::V8Inspector> inspector_; |
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_; |
+ int last_session_id_ = 0; |
+ std::map<int, std::unique_ptr<v8_inspector::V8InspectorSession>> sessions_; |
+ std::map<v8_inspector::V8InspectorSession*, int> context_group_by_session_; |
+ std::map<int, std::unique_ptr<v8_inspector::V8Inspector::Channel>> channels_; |
+ v8::Global<v8::Value> memory_info_; |
+ FrontendChannel* frontend_channel_; |
+ bool current_time_set_ = false; |
+ double current_time_ = 0.0; |
+ bool log_console_api_message_calls_ = false; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(IsolateData); |
}; |
+ |
#endif // V8_TEST_INSPECTOR_PROTOCOL_ISOLATE_DATA_H_ |