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