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_INSPECTOR_V8CONSOLEMESSAGE_H_ | |
6 #define V8_INSPECTOR_V8CONSOLEMESSAGE_H_ | |
7 | |
8 #include <deque> | |
9 #include "include/v8.h" | |
10 #include "src/inspector/protocol/Console.h" | |
11 #include "src/inspector/protocol/Forward.h" | |
12 #include "src/inspector/protocol/Runtime.h" | |
13 | |
14 namespace v8_inspector { | |
15 | |
16 class InspectedContext; | |
17 class V8InspectorImpl; | |
18 class V8InspectorSessionImpl; | |
19 class V8StackTraceImpl; | |
20 | |
21 enum class V8MessageOrigin { kConsole, kException, kRevokedException }; | |
22 | |
23 enum class ConsoleAPIType { | |
24 kLog, | |
25 kDebug, | |
26 kInfo, | |
27 kError, | |
28 kWarning, | |
29 kDir, | |
30 kDirXML, | |
31 kTable, | |
32 kTrace, | |
33 kStartGroup, | |
34 kStartGroupCollapsed, | |
35 kEndGroup, | |
36 kClear, | |
37 kAssert, | |
38 kTimeEnd, | |
39 kCount | |
40 }; | |
41 | |
42 class V8ConsoleMessage { | |
43 public: | |
44 ~V8ConsoleMessage(); | |
45 | |
46 static std::unique_ptr<V8ConsoleMessage> createForConsoleAPI( | |
47 double timestamp, ConsoleAPIType, | |
48 const std::vector<v8::Local<v8::Value>>& arguments, | |
49 std::unique_ptr<V8StackTraceImpl>, InspectedContext*); | |
50 | |
51 static std::unique_ptr<V8ConsoleMessage> createForException( | |
52 double timestamp, const String16& detailedMessage, const String16& url, | |
53 unsigned lineNumber, unsigned columnNumber, | |
54 std::unique_ptr<V8StackTraceImpl>, int scriptId, v8::Isolate*, | |
55 const String16& message, int contextId, v8::Local<v8::Value> exception, | |
56 unsigned exceptionId); | |
57 | |
58 static std::unique_ptr<V8ConsoleMessage> createForRevokedException( | |
59 double timestamp, const String16& message, unsigned revokedExceptionId); | |
60 | |
61 V8MessageOrigin origin() const; | |
62 void reportToFrontend(protocol::Console::Frontend*) const; | |
63 void reportToFrontend(protocol::Runtime::Frontend*, V8InspectorSessionImpl*, | |
64 bool generatePreview) const; | |
65 ConsoleAPIType type() const; | |
66 void contextDestroyed(int contextId); | |
67 | |
68 private: | |
69 V8ConsoleMessage(V8MessageOrigin, double timestamp, const String16& message); | |
70 | |
71 using Arguments = std::vector<std::unique_ptr<v8::Global<v8::Value>>>; | |
72 std::unique_ptr<protocol::Array<protocol::Runtime::RemoteObject>> | |
73 wrapArguments(V8InspectorSessionImpl*, bool generatePreview) const; | |
74 std::unique_ptr<protocol::Runtime::RemoteObject> wrapException( | |
75 V8InspectorSessionImpl*, bool generatePreview) const; | |
76 void setLocation(const String16& url, unsigned lineNumber, | |
77 unsigned columnNumber, std::unique_ptr<V8StackTraceImpl>, | |
78 int scriptId); | |
79 | |
80 V8MessageOrigin m_origin; | |
81 double m_timestamp; | |
82 String16 m_message; | |
83 String16 m_url; | |
84 unsigned m_lineNumber; | |
85 unsigned m_columnNumber; | |
86 std::unique_ptr<V8StackTraceImpl> m_stackTrace; | |
87 int m_scriptId; | |
88 int m_contextId; | |
89 ConsoleAPIType m_type; | |
90 unsigned m_exceptionId; | |
91 unsigned m_revokedExceptionId; | |
92 Arguments m_arguments; | |
93 String16 m_detailedMessage; | |
94 }; | |
95 | |
96 class V8ConsoleMessageStorage { | |
97 public: | |
98 V8ConsoleMessageStorage(V8InspectorImpl*, int contextGroupId); | |
99 ~V8ConsoleMessageStorage(); | |
100 | |
101 int contextGroupId() { return m_contextGroupId; } | |
102 int expiredCount() { return m_expiredCount; } | |
103 const std::deque<std::unique_ptr<V8ConsoleMessage>>& messages() const { | |
104 return m_messages; | |
105 } | |
106 | |
107 void addMessage(std::unique_ptr<V8ConsoleMessage>); | |
108 void contextDestroyed(int contextId); | |
109 void clear(); | |
110 | |
111 private: | |
112 V8InspectorImpl* m_inspector; | |
113 int m_contextGroupId; | |
114 int m_expiredCount; | |
115 std::deque<std::unique_ptr<V8ConsoleMessage>> m_messages; | |
116 }; | |
117 | |
118 } // namespace v8_inspector | |
119 | |
120 #endif // V8_INSPECTOR_V8CONSOLEMESSAGE_H_ | |
OLD | NEW |