| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium 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 V8ConsoleMessage_h | 5 #ifndef V8ConsoleMessage_h |
| 6 #define V8ConsoleMessage_h | 6 #define V8ConsoleMessage_h |
| 7 | 7 |
| 8 #include "platform/inspector_protocol/Collections.h" | 8 #include "platform/inspector_protocol/Collections.h" |
| 9 #include "platform/inspector_protocol/String16.h" | 9 #include "platform/inspector_protocol/String16.h" |
| 10 #include "platform/v8_inspector/protocol/Console.h" | 10 #include "platform/v8_inspector/protocol/Console.h" |
| 11 #include "platform/v8_inspector/protocol/Runtime.h" | 11 #include "platform/v8_inspector/protocol/Runtime.h" |
| 12 #include "platform/v8_inspector/public/V8ConsoleTypes.h" | 12 #include "platform/v8_inspector/public/V8ConsoleTypes.h" |
| 13 #include "platform/v8_inspector/public/V8StackTrace.h" | 13 #include "platform/v8_inspector/public/V8StackTrace.h" |
| 14 #include <deque> | 14 #include <deque> |
| 15 #include <v8.h> | 15 #include <v8.h> |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 class InspectedContext; | 19 class InspectedContext; |
| 20 class V8DebuggerImpl; | 20 class V8DebuggerImpl; |
| 21 class V8InspectorSessionImpl; | 21 class V8InspectorSessionImpl; |
| 22 class V8StackTrace; | 22 class V8StackTrace; |
| 23 | 23 |
| 24 enum class V8MessageOrigin { kExternalConsole, kConsole, kException, kRevokedExc
eption }; | 24 enum class V8MessageOrigin { kConsole, kException, kRevokedException }; |
| 25 | 25 |
| 26 enum class ConsoleAPIType { kLog, kDebug, kInfo, kError, kWarning, kDir, kDirXML
, kTable, kTrace, kStartGroup, kStartGroupCollapsed, kEndGroup, kClear, kAssert,
kTimeEnd, kCount }; | 26 enum class ConsoleAPIType { kLog, kDebug, kInfo, kError, kWarning, kDir, kDirXML
, kTable, kTrace, kStartGroup, kStartGroupCollapsed, kEndGroup, kClear, kAssert,
kTimeEnd, kCount }; |
| 27 | 27 |
| 28 class V8ConsoleMessage { | 28 class V8ConsoleMessage { |
| 29 public: | 29 public: |
| 30 ~V8ConsoleMessage(); | 30 ~V8ConsoleMessage(); |
| 31 | 31 |
| 32 static std::unique_ptr<V8ConsoleMessage> createForConsoleAPI( | 32 static std::unique_ptr<V8ConsoleMessage> createForConsoleAPI( |
| 33 double timestamp, | 33 double timestamp, |
| 34 ConsoleAPIType, | 34 ConsoleAPIType, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 47 v8::Isolate*, | 47 v8::Isolate*, |
| 48 int contextId, | 48 int contextId, |
| 49 v8::Local<v8::Value> exception, | 49 v8::Local<v8::Value> exception, |
| 50 unsigned exceptionId); | 50 unsigned exceptionId); |
| 51 | 51 |
| 52 static std::unique_ptr<V8ConsoleMessage> createForRevokedException( | 52 static std::unique_ptr<V8ConsoleMessage> createForRevokedException( |
| 53 double timestamp, | 53 double timestamp, |
| 54 const String16& message, | 54 const String16& message, |
| 55 unsigned revokedExceptionId); | 55 unsigned revokedExceptionId); |
| 56 | 56 |
| 57 static std::unique_ptr<V8ConsoleMessage> createExternal( | |
| 58 double timestamp, | |
| 59 MessageSource, | |
| 60 MessageLevel, | |
| 61 const String16& message, | |
| 62 const String16& url, | |
| 63 unsigned lineNumber, | |
| 64 unsigned columnNumber, | |
| 65 std::unique_ptr<V8StackTrace>, | |
| 66 int scriptId, | |
| 67 const String16& requestIdentifier, | |
| 68 const String16& workerId); | |
| 69 | |
| 70 V8MessageOrigin origin() const; | 57 V8MessageOrigin origin() const; |
| 71 void reportToFrontend(protocol::Console::Frontend*, V8InspectorSessionImpl*,
bool generatePreview) const; | 58 void reportToFrontend(protocol::Console::Frontend*) const; |
| 72 void reportToFrontend(protocol::Runtime::Frontend*, V8InspectorSessionImpl*,
bool generatePreview) const; | 59 void reportToFrontend(protocol::Runtime::Frontend*, V8InspectorSessionImpl*,
bool generatePreview) const; |
| 73 ConsoleAPIType type() const; | 60 ConsoleAPIType type() const; |
| 74 void contextDestroyed(int contextId); | 61 void contextDestroyed(int contextId); |
| 75 | 62 |
| 76 private: | 63 private: |
| 77 V8ConsoleMessage(V8MessageOrigin, double timestamp, MessageSource, MessageLe
vel, const String16& message); | 64 V8ConsoleMessage(V8MessageOrigin, double timestamp, const String16& message)
; |
| 78 | 65 |
| 79 using Arguments = std::vector<std::unique_ptr<v8::Global<v8::Value>>>; | 66 using Arguments = std::vector<std::unique_ptr<v8::Global<v8::Value>>>; |
| 80 std::unique_ptr<protocol::Array<protocol::Runtime::RemoteObject>> wrapArgume
nts(V8InspectorSessionImpl*, bool generatePreview) const; | 67 std::unique_ptr<protocol::Array<protocol::Runtime::RemoteObject>> wrapArgume
nts(V8InspectorSessionImpl*, bool generatePreview) const; |
| 81 std::unique_ptr<protocol::Runtime::RemoteObject> wrapException(V8InspectorSe
ssionImpl*, bool generatePreview) const; | 68 std::unique_ptr<protocol::Runtime::RemoteObject> wrapException(V8InspectorSe
ssionImpl*, bool generatePreview) const; |
| 82 void setLocation(const String16& url, unsigned lineNumber, unsigned columnNu
mber, std::unique_ptr<V8StackTrace>, int scriptId); | 69 void setLocation(const String16& url, unsigned lineNumber, unsigned columnNu
mber, std::unique_ptr<V8StackTrace>, int scriptId); |
| 83 | 70 |
| 84 V8MessageOrigin m_origin; | 71 V8MessageOrigin m_origin; |
| 85 double m_timestamp; | 72 double m_timestamp; |
| 86 MessageSource m_source; | |
| 87 MessageLevel m_level; | |
| 88 String16 m_message; | 73 String16 m_message; |
| 89 String16 m_url; | 74 String16 m_url; |
| 90 unsigned m_lineNumber; | 75 unsigned m_lineNumber; |
| 91 unsigned m_columnNumber; | 76 unsigned m_columnNumber; |
| 92 std::unique_ptr<V8StackTrace> m_stackTrace; | 77 std::unique_ptr<V8StackTrace> m_stackTrace; |
| 93 int m_scriptId; | 78 int m_scriptId; |
| 94 String16 m_requestIdentifier; | |
| 95 String16 m_workerId; | |
| 96 int m_contextId; | 79 int m_contextId; |
| 97 ConsoleAPIType m_type; | 80 ConsoleAPIType m_type; |
| 98 unsigned m_exceptionId; | 81 unsigned m_exceptionId; |
| 99 unsigned m_revokedExceptionId; | 82 unsigned m_revokedExceptionId; |
| 100 Arguments m_arguments; | 83 Arguments m_arguments; |
| 101 }; | 84 }; |
| 102 | 85 |
| 103 class V8ConsoleMessageStorage { | 86 class V8ConsoleMessageStorage { |
| 104 public: | 87 public: |
| 105 V8ConsoleMessageStorage(V8DebuggerImpl*, int contextGroupId); | 88 V8ConsoleMessageStorage(V8DebuggerImpl*, int contextGroupId); |
| 106 ~V8ConsoleMessageStorage(); | 89 ~V8ConsoleMessageStorage(); |
| 107 | 90 |
| 108 int contextGroupId() { return m_contextGroupId; } | 91 int contextGroupId() { return m_contextGroupId; } |
| 109 int expiredCount() { return m_expiredCount; } | 92 int expiredCount() { return m_expiredCount; } |
| 110 const std::deque<std::unique_ptr<V8ConsoleMessage>>& messages() const { retu
rn m_messages; } | 93 const std::deque<std::unique_ptr<V8ConsoleMessage>>& messages() const { retu
rn m_messages; } |
| 111 | 94 |
| 112 void addMessage(std::unique_ptr<V8ConsoleMessage>); | 95 void addMessage(std::unique_ptr<V8ConsoleMessage>); |
| 113 void contextDestroyed(int contextId); | 96 void contextDestroyed(int contextId); |
| 114 void clear(); | 97 void clear(); |
| 115 | 98 |
| 116 private: | 99 private: |
| 100 void notifyClear(); |
| 101 |
| 117 V8DebuggerImpl* m_debugger; | 102 V8DebuggerImpl* m_debugger; |
| 118 int m_contextGroupId; | 103 int m_contextGroupId; |
| 119 int m_expiredCount; | 104 int m_expiredCount; |
| 120 std::deque<std::unique_ptr<V8ConsoleMessage>> m_messages; | 105 std::deque<std::unique_ptr<V8ConsoleMessage>> m_messages; |
| 121 }; | 106 }; |
| 122 | 107 |
| 123 } // namespace blink | 108 } // namespace blink |
| 124 | 109 |
| 125 #endif // V8ConsoleMessage_h | 110 #endif // V8ConsoleMessage_h |
| OLD | NEW |