5 #ifndef V8_INSPECTOR_V8_CONSOLE_MESSAGE_H_ 6 #define V8_INSPECTOR_V8_CONSOLE_MESSAGE_H_ 11 #include "include/v8.h" 12 #include "src/inspector/protocol/Console.h" 13 #include "src/inspector/protocol/Forward.h" 14 #include "src/inspector/protocol/Runtime.h" 18 class InspectedContext;
19 class V8InspectorImpl;
20 class V8InspectorSessionImpl;
21 class V8StackTraceImpl;
23 enum class V8MessageOrigin { kConsole, kException, kRevokedException };
25 enum class ConsoleAPIType {
48 static std::unique_ptr<V8ConsoleMessage> createForConsoleAPI(
52 const String16& consoleContext, std::unique_ptr<V8StackTraceImpl>);
54 static std::unique_ptr<V8ConsoleMessage> createForException(
56 unsigned lineNumber,
unsigned columnNumber,
57 std::unique_ptr<V8StackTraceImpl>,
int scriptId, v8::Isolate*,
59 unsigned exceptionId);
61 static std::unique_ptr<V8ConsoleMessage> createForRevokedException(
62 double timestamp,
const String16& message,
unsigned revokedExceptionId);
64 V8MessageOrigin origin()
const;
65 void reportToFrontend(protocol::Console::Frontend*)
const;
67 bool generatePreview)
const;
68 ConsoleAPIType
type()
const;
69 void contextDestroyed(
int contextId);
71 int estimatedSize()
const {
72 return m_v8Size +
static_cast<int>(m_message.length() *
sizeof(UChar));
78 using Arguments = std::vector<std::unique_ptr<v8::Global<v8::Value>>>;
79 std::unique_ptr<protocol::Array<protocol::Runtime::RemoteObject>>
81 std::unique_ptr<protocol::Runtime::RemoteObject> wrapException(
83 void setLocation(
const String16& url,
unsigned lineNumber,
84 unsigned columnNumber, std::unique_ptr<V8StackTraceImpl>,
87 V8MessageOrigin m_origin;
91 unsigned m_lineNumber;
92 unsigned m_columnNumber;
93 std::unique_ptr<V8StackTraceImpl> m_stackTrace;
96 ConsoleAPIType m_type;
97 unsigned m_exceptionId;
98 unsigned m_revokedExceptionId;
100 Arguments m_arguments;
110 int contextGroupId() {
return m_contextGroupId; }
111 const std::deque<std::unique_ptr<V8ConsoleMessage>>& messages()
const {
115 void addMessage(std::unique_ptr<V8ConsoleMessage>);
116 void contextDestroyed(
int contextId);
119 bool shouldReportDeprecationMessage(
int contextId,
const String16& method);
120 int count(
int contextId,
const String16&
id);
121 bool countReset(
int contextId,
const String16&
id);
122 void time(
int contextId,
const String16&
id);
123 double timeLog(
int contextId,
const String16&
id);
124 double timeEnd(
int contextId,
const String16&
id);
125 bool hasTimer(
int contextId,
const String16&
id);
129 int m_contextGroupId;
130 int m_estimatedSize = 0;
131 std::deque<std::unique_ptr<V8ConsoleMessage>> m_messages;
133 struct PerContextData {
134 std::set<String16> m_reportedDeprecationMessages;
136 std::map<String16, int> m_count;
138 std::map<String16, double> m_time;
140 std::map<int, PerContextData> m_data;
145 #endif // V8_INSPECTOR_V8_CONSOLE_MESSAGE_H_