OLD | NEW |
| (Empty) |
1 // Copyright 2016 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ | |
6 #define V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ | |
7 | |
8 #include <map> | |
9 #include <vector> | |
10 | |
11 #include "include/v8-inspector.h" | |
12 #include "include/v8.h" | |
13 #include "src/base/macros.h" | |
14 #include "src/base/platform/platform.h" | |
15 | |
16 class TaskRunner; | |
17 | |
18 class InspectorClientImpl : public v8_inspector::V8InspectorClient { | |
19 public: | |
20 class FrontendChannel { | |
21 public: | |
22 virtual ~FrontendChannel() = default; | |
23 virtual void SendMessageToFrontend( | |
24 int session_id, const v8_inspector::StringView& message) = 0; | |
25 }; | |
26 | |
27 InspectorClientImpl(v8::Isolate* isolate, TaskRunner* task_runner, | |
28 FrontendChannel* frontend_channel); | |
29 virtual ~InspectorClientImpl(); | |
30 | |
31 v8_inspector::V8Inspector* inspector() const { return inspector_.get(); } | |
32 int ConnectSession(int context_group_id, | |
33 const v8_inspector::StringView& state); | |
34 std::unique_ptr<v8_inspector::StringBuffer> DisconnectSession(int session_id); | |
35 void SendMessage(int session_id, const v8_inspector::StringView& message); | |
36 void BreakProgram(int context_group_id, | |
37 const v8_inspector::StringView& reason, | |
38 const v8_inspector::StringView& details); | |
39 void SchedulePauseOnNextStatement(int context_group_id, | |
40 const v8_inspector::StringView& reason, | |
41 const v8_inspector::StringView& details); | |
42 void CancelPauseOnNextStatement(int context_group_id); | |
43 void SetCurrentTimeMSForTest(double time); | |
44 void SetMemoryInfoForTest(v8::Local<v8::Value> memory_info); | |
45 void SetLogConsoleApiMessageCalls(bool log); | |
46 void ContextCreated(v8::Local<v8::Context> context, int context_group_id); | |
47 void ContextDestroyed(v8::Local<v8::Context> context); | |
48 | |
49 private: | |
50 // V8InspectorClient implementation. | |
51 bool formatAccessorsAsProperties(v8::Local<v8::Value>) override; | |
52 v8::Local<v8::Context> ensureDefaultContextInGroup( | |
53 int context_group_id) override; | |
54 double currentTimeMS() override; | |
55 v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate* isolate, | |
56 v8::Local<v8::Context>) override; | |
57 void runMessageLoopOnPause(int context_group_id) override; | |
58 void quitMessageLoopOnPause() override; | |
59 void consoleAPIMessage(int contextGroupId, | |
60 v8::Isolate::MessageErrorLevel level, | |
61 const v8_inspector::StringView& message, | |
62 const v8_inspector::StringView& url, | |
63 unsigned lineNumber, unsigned columnNumber, | |
64 v8_inspector::V8StackTrace*) override; | |
65 | |
66 std::vector<int> GetSessionIds(int context_group_id); | |
67 | |
68 std::unique_ptr<v8_inspector::V8Inspector> inspector_; | |
69 int last_session_id_ = 0; | |
70 std::map<int, std::unique_ptr<v8_inspector::V8InspectorSession>> sessions_; | |
71 std::map<v8_inspector::V8InspectorSession*, int> context_group_by_session_; | |
72 std::map<int, std::unique_ptr<v8_inspector::V8Inspector::Channel>> channels_; | |
73 TaskRunner* task_runner_; | |
74 v8::Isolate* isolate_; | |
75 v8::Global<v8::Value> memory_info_; | |
76 FrontendChannel* frontend_channel_; | |
77 bool current_time_set_for_test_ = false; | |
78 double current_time_ = 0.0; | |
79 bool log_console_api_message_calls_ = false; | |
80 | |
81 DISALLOW_COPY_AND_ASSIGN(InspectorClientImpl); | |
82 }; | |
83 | |
84 #endif // V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ | |
OLD | NEW |