OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ | 5 #ifndef V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ |
6 #define V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ | 6 #define V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ |
7 | 7 |
8 #include "include/v8-inspector.h" | 8 #include "include/v8-inspector.h" |
9 #include "include/v8.h" | 9 #include "include/v8.h" |
10 #include "src/base/macros.h" | 10 #include "src/base/macros.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 static v8_inspector::V8Inspector* InspectorFromContext( | 33 static v8_inspector::V8Inspector* InspectorFromContext( |
34 v8::Local<v8::Context> context); | 34 v8::Local<v8::Context> context); |
35 static v8_inspector::V8InspectorSession* SessionFromContext( | 35 static v8_inspector::V8InspectorSession* SessionFromContext( |
36 v8::Local<v8::Context> context); | 36 v8::Local<v8::Context> context); |
37 | 37 |
38 // context_group_id = 0 means default context group. | 38 // context_group_id = 0 means default context group. |
39 v8_inspector::V8InspectorSession* session(int context_group_id = 0); | 39 v8_inspector::V8InspectorSession* session(int context_group_id = 0); |
40 | 40 |
41 void setCurrentTimeMSForTest(double time); | 41 void setCurrentTimeMSForTest(double time); |
42 void setMemoryInfoForTest(v8::Local<v8::Value> memory_info); | 42 void setMemoryInfoForTest(v8::Local<v8::Value> memory_info); |
| 43 void setLogConsoleApiMessageCalls(bool log); |
43 | 44 |
44 private: | 45 private: |
45 // V8InspectorClient implementation. | 46 // V8InspectorClient implementation. |
46 bool formatAccessorsAsProperties(v8::Local<v8::Value>) override; | 47 bool formatAccessorsAsProperties(v8::Local<v8::Value>) override; |
47 v8::Local<v8::Context> ensureDefaultContextInGroup( | 48 v8::Local<v8::Context> ensureDefaultContextInGroup( |
48 int context_group_id) override; | 49 int context_group_id) override; |
49 double currentTimeMS() override; | 50 double currentTimeMS() override; |
50 v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate* isolate, | 51 v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate* isolate, |
51 v8::Local<v8::Context>) override; | 52 v8::Local<v8::Context>) override; |
52 void runMessageLoopOnPause(int context_group_id) override; | 53 void runMessageLoopOnPause(int context_group_id) override; |
53 void quitMessageLoopOnPause() override; | 54 void quitMessageLoopOnPause() override; |
54 | 55 void consoleAPIMessage(int contextGroupId, |
| 56 v8::Isolate::MessageErrorLevel level, |
| 57 const v8_inspector::StringView& message, |
| 58 const v8_inspector::StringView& url, |
| 59 unsigned lineNumber, unsigned columnNumber, |
| 60 v8_inspector::V8StackTrace*) override; |
55 friend class SendMessageToBackendTask; | 61 friend class SendMessageToBackendTask; |
56 | 62 |
57 friend class ConnectTask; | 63 friend class ConnectTask; |
58 void connect(v8::Local<v8::Context> context); | 64 void connect(v8::Local<v8::Context> context); |
59 friend class DisconnectTask; | 65 friend class DisconnectTask; |
60 void disconnect(); | 66 void disconnect(); |
61 friend class CreateContextGroupTask; | 67 friend class CreateContextGroupTask; |
62 int createContextGroup(v8::ExtensionConfiguration* extensions); | 68 int createContextGroup(v8::ExtensionConfiguration* extensions); |
63 | 69 |
64 std::unique_ptr<v8_inspector::V8Inspector> inspector_; | 70 std::unique_ptr<v8_inspector::V8Inspector> inspector_; |
65 std::unique_ptr<v8_inspector::V8Inspector::Channel> channel_; | 71 std::unique_ptr<v8_inspector::V8Inspector::Channel> channel_; |
66 | 72 |
67 std::map<int, std::unique_ptr<v8_inspector::V8InspectorSession>> sessions_; | 73 std::map<int, std::unique_ptr<v8_inspector::V8InspectorSession>> sessions_; |
68 std::map<int, std::unique_ptr<v8_inspector::StringBuffer>> states_; | 74 std::map<int, std::unique_ptr<v8_inspector::StringBuffer>> states_; |
69 | 75 |
70 v8::Isolate* isolate_; | 76 v8::Isolate* isolate_; |
71 v8::Global<v8::Value> memory_info_; | 77 v8::Global<v8::Value> memory_info_; |
72 | 78 |
73 TaskRunner* task_runner_; | 79 TaskRunner* task_runner_; |
74 FrontendChannel* frontend_channel_; | 80 FrontendChannel* frontend_channel_; |
75 | 81 |
76 bool current_time_set_for_test_ = false; | 82 bool current_time_set_for_test_ = false; |
77 double current_time_ = 0.0; | 83 double current_time_ = 0.0; |
| 84 bool log_console_api_message_calls_ = false; |
78 | 85 |
79 DISALLOW_COPY_AND_ASSIGN(InspectorClientImpl); | 86 DISALLOW_COPY_AND_ASSIGN(InspectorClientImpl); |
80 }; | 87 }; |
81 | 88 |
82 class SendMessageToBackendExtension : public v8::Extension { | 89 class SendMessageToBackendExtension : public v8::Extension { |
83 public: | 90 public: |
84 SendMessageToBackendExtension() | 91 SendMessageToBackendExtension() |
85 : v8::Extension("v8_inspector/frontend", | 92 : v8::Extension("v8_inspector/frontend", |
86 "native function sendMessageToBackend();") {} | 93 "native function sendMessageToBackend();") {} |
87 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( | 94 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( |
88 v8::Isolate* isolate, v8::Local<v8::String> name); | 95 v8::Isolate* isolate, v8::Local<v8::String> name); |
89 | 96 |
90 static void set_backend_task_runner(TaskRunner* task_runner) { | 97 static void set_backend_task_runner(TaskRunner* task_runner) { |
91 backend_task_runner_ = task_runner; | 98 backend_task_runner_ = task_runner; |
92 } | 99 } |
93 | 100 |
94 private: | 101 private: |
95 static void SendMessageToBackend( | 102 static void SendMessageToBackend( |
96 const v8::FunctionCallbackInfo<v8::Value>& args); | 103 const v8::FunctionCallbackInfo<v8::Value>& args); |
97 | 104 |
98 static TaskRunner* backend_task_runner_; | 105 static TaskRunner* backend_task_runner_; |
99 }; | 106 }; |
100 | 107 |
101 #endif // V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ | 108 #endif // V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_ |
OLD | NEW |