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