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_INSPECTOR_V8CONSOLEMESSAGE_H_ | 5 #ifndef V8_INSPECTOR_V8CONSOLEMESSAGE_H_ |
6 #define V8_INSPECTOR_V8CONSOLEMESSAGE_H_ | 6 #define V8_INSPECTOR_V8CONSOLEMESSAGE_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include "include/v8.h" | 9 #include "include/v8.h" |
10 #include "src/inspector/protocol/Console.h" | 10 #include "src/inspector/protocol/Console.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 static std::unique_ptr<V8ConsoleMessage> createForRevokedException( | 58 static std::unique_ptr<V8ConsoleMessage> createForRevokedException( |
59 double timestamp, const String16& message, unsigned revokedExceptionId); | 59 double timestamp, const String16& message, unsigned revokedExceptionId); |
60 | 60 |
61 V8MessageOrigin origin() const; | 61 V8MessageOrigin origin() const; |
62 void reportToFrontend(protocol::Console::Frontend*) const; | 62 void reportToFrontend(protocol::Console::Frontend*) const; |
63 void reportToFrontend(protocol::Runtime::Frontend*, V8InspectorSessionImpl*, | 63 void reportToFrontend(protocol::Runtime::Frontend*, V8InspectorSessionImpl*, |
64 bool generatePreview) const; | 64 bool generatePreview) const; |
65 ConsoleAPIType type() const; | 65 ConsoleAPIType type() const; |
66 void contextDestroyed(int contextId); | 66 void contextDestroyed(int contextId); |
67 | 67 |
| 68 int estimatedSize() const { |
| 69 return m_v8Size + static_cast<int>(m_message.length() * sizeof(UChar)); |
| 70 } |
| 71 |
68 private: | 72 private: |
69 V8ConsoleMessage(V8MessageOrigin, double timestamp, const String16& message); | 73 V8ConsoleMessage(V8MessageOrigin, double timestamp, const String16& message); |
70 | 74 |
71 using Arguments = std::vector<std::unique_ptr<v8::Global<v8::Value>>>; | 75 using Arguments = std::vector<std::unique_ptr<v8::Global<v8::Value>>>; |
72 std::unique_ptr<protocol::Array<protocol::Runtime::RemoteObject>> | 76 std::unique_ptr<protocol::Array<protocol::Runtime::RemoteObject>> |
73 wrapArguments(V8InspectorSessionImpl*, bool generatePreview) const; | 77 wrapArguments(V8InspectorSessionImpl*, bool generatePreview) const; |
74 std::unique_ptr<protocol::Runtime::RemoteObject> wrapException( | 78 std::unique_ptr<protocol::Runtime::RemoteObject> wrapException( |
75 V8InspectorSessionImpl*, bool generatePreview) const; | 79 V8InspectorSessionImpl*, bool generatePreview) const; |
76 void setLocation(const String16& url, unsigned lineNumber, | 80 void setLocation(const String16& url, unsigned lineNumber, |
77 unsigned columnNumber, std::unique_ptr<V8StackTraceImpl>, | 81 unsigned columnNumber, std::unique_ptr<V8StackTraceImpl>, |
78 int scriptId); | 82 int scriptId); |
79 | 83 |
80 V8MessageOrigin m_origin; | 84 V8MessageOrigin m_origin; |
81 double m_timestamp; | 85 double m_timestamp; |
82 String16 m_message; | 86 String16 m_message; |
83 String16 m_url; | 87 String16 m_url; |
84 unsigned m_lineNumber; | 88 unsigned m_lineNumber; |
85 unsigned m_columnNumber; | 89 unsigned m_columnNumber; |
86 std::unique_ptr<V8StackTraceImpl> m_stackTrace; | 90 std::unique_ptr<V8StackTraceImpl> m_stackTrace; |
87 int m_scriptId; | 91 int m_scriptId; |
88 int m_contextId; | 92 int m_contextId; |
89 ConsoleAPIType m_type; | 93 ConsoleAPIType m_type; |
90 unsigned m_exceptionId; | 94 unsigned m_exceptionId; |
91 unsigned m_revokedExceptionId; | 95 unsigned m_revokedExceptionId; |
| 96 int m_v8Size = 0; |
92 Arguments m_arguments; | 97 Arguments m_arguments; |
93 String16 m_detailedMessage; | 98 String16 m_detailedMessage; |
94 }; | 99 }; |
95 | 100 |
96 class V8ConsoleMessageStorage { | 101 class V8ConsoleMessageStorage { |
97 public: | 102 public: |
98 V8ConsoleMessageStorage(V8InspectorImpl*, int contextGroupId); | 103 V8ConsoleMessageStorage(V8InspectorImpl*, int contextGroupId); |
99 ~V8ConsoleMessageStorage(); | 104 ~V8ConsoleMessageStorage(); |
100 | 105 |
101 int contextGroupId() { return m_contextGroupId; } | 106 int contextGroupId() { return m_contextGroupId; } |
102 int expiredCount() { return m_expiredCount; } | |
103 const std::deque<std::unique_ptr<V8ConsoleMessage>>& messages() const { | 107 const std::deque<std::unique_ptr<V8ConsoleMessage>>& messages() const { |
104 return m_messages; | 108 return m_messages; |
105 } | 109 } |
106 | 110 |
107 void addMessage(std::unique_ptr<V8ConsoleMessage>); | 111 void addMessage(std::unique_ptr<V8ConsoleMessage>); |
108 void contextDestroyed(int contextId); | 112 void contextDestroyed(int contextId); |
109 void clear(); | 113 void clear(); |
110 | 114 |
111 private: | 115 private: |
112 V8InspectorImpl* m_inspector; | 116 V8InspectorImpl* m_inspector; |
113 int m_contextGroupId; | 117 int m_contextGroupId; |
114 int m_expiredCount; | 118 int m_estimatedSize = 0; |
115 std::deque<std::unique_ptr<V8ConsoleMessage>> m_messages; | 119 std::deque<std::unique_ptr<V8ConsoleMessage>> m_messages; |
116 }; | 120 }; |
117 | 121 |
118 } // namespace v8_inspector | 122 } // namespace v8_inspector |
119 | 123 |
120 #endif // V8_INSPECTOR_V8CONSOLEMESSAGE_H_ | 124 #endif // V8_INSPECTOR_V8CONSOLEMESSAGE_H_ |
OLD | NEW |