| 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 V8StackTraceImpl_h | 5 #ifndef V8StackTraceImpl_h |
| 6 #define V8StackTraceImpl_h | 6 #define V8StackTraceImpl_h |
| 7 | 7 |
| 8 #include "platform/inspector_protocol/Collections.h" | 8 #include "platform/inspector_protocol/Collections.h" |
| 9 #include "platform/v8_inspector/public/V8StackTrace.h" | 9 #include "platform/v8_inspector/public/V8StackTrace.h" |
| 10 #include "wtf/PassOwnPtr.h" | 10 #include "wtf/PtrUtil.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class TracedValue; | 14 class TracedValue; |
| 15 class V8DebuggerAgentImpl; | 15 class V8DebuggerAgentImpl; |
| 16 | 16 |
| 17 // Note: async stack trace may have empty top stack with non-empty tail to indic
ate | 17 // Note: async stack trace may have empty top stack with non-empty tail to indic
ate |
| 18 // that current native-only state had some async story. | 18 // that current native-only state had some async story. |
| 19 // On the other hand, any non-top async stack is guaranteed to be non-empty. | 19 // On the other hand, any non-top async stack is guaranteed to be non-empty. |
| 20 class V8StackTraceImpl final : public V8StackTrace { | 20 class V8StackTraceImpl final : public V8StackTrace { |
| 21 PROTOCOL_DISALLOW_COPY(V8StackTraceImpl); | 21 PROTOCOL_DISALLOW_COPY(V8StackTraceImpl); |
| 22 public: | 22 public: |
| 23 class Frame { | 23 class Frame { |
| 24 public: | 24 public: |
| 25 Frame(); | 25 Frame(); |
| 26 Frame(const String16& functionName, const String16& scriptId, const Stri
ng16& scriptName, int lineNumber, int column = 0); | 26 Frame(const String16& functionName, const String16& scriptId, const Stri
ng16& scriptName, int lineNumber, int column = 0); |
| 27 ~Frame(); | 27 ~Frame(); |
| 28 | 28 |
| 29 const String16& functionName() const { return m_functionName; } | 29 const String16& functionName() const { return m_functionName; } |
| 30 const String16& scriptId() const { return m_scriptId; } | 30 const String16& scriptId() const { return m_scriptId; } |
| 31 const String16& sourceURL() const { return m_scriptName; } | 31 const String16& sourceURL() const { return m_scriptName; } |
| 32 int lineNumber() const { return m_lineNumber; } | 32 int lineNumber() const { return m_lineNumber; } |
| 33 int columnNumber() const { return m_columnNumber; } | 33 int columnNumber() const { return m_columnNumber; } |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 friend class V8StackTraceImpl; | 36 friend class V8StackTraceImpl; |
| 37 PassOwnPtr<protocol::Runtime::CallFrame> buildInspectorObject() const; | 37 std::unique_ptr<protocol::Runtime::CallFrame> buildInspectorObject() con
st; |
| 38 void toTracedValue(TracedValue*) const; | 38 void toTracedValue(TracedValue*) const; |
| 39 | 39 |
| 40 String16 m_functionName; | 40 String16 m_functionName; |
| 41 String16 m_scriptId; | 41 String16 m_scriptId; |
| 42 String16 m_scriptName; | 42 String16 m_scriptName; |
| 43 int m_lineNumber; | 43 int m_lineNumber; |
| 44 int m_columnNumber; | 44 int m_columnNumber; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 static PassOwnPtr<V8StackTraceImpl> create(V8DebuggerAgentImpl*, v8::Local<v
8::StackTrace>, size_t maxStackSize, const String16& description = String16()); | 47 static std::unique_ptr<V8StackTraceImpl> create(V8DebuggerAgentImpl*, v8::Lo
cal<v8::StackTrace>, size_t maxStackSize, const String16& description = String16
()); |
| 48 static PassOwnPtr<V8StackTraceImpl> capture(V8DebuggerAgentImpl*, size_t max
StackSize, const String16& description = String16()); | 48 static std::unique_ptr<V8StackTraceImpl> capture(V8DebuggerAgentImpl*, size_
t maxStackSize, const String16& description = String16()); |
| 49 | 49 |
| 50 PassOwnPtr<V8StackTrace> clone() override; | 50 std::unique_ptr<V8StackTrace> clone() override; |
| 51 PassOwnPtr<V8StackTraceImpl> cloneImpl(); | 51 std::unique_ptr<V8StackTraceImpl> cloneImpl(); |
| 52 PassOwnPtr<protocol::Runtime::StackTrace> buildInspectorObjectForTail(V8Debu
ggerAgentImpl*) const; | 52 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectForTail(V
8DebuggerAgentImpl*) const; |
| 53 ~V8StackTraceImpl() override; | 53 ~V8StackTraceImpl() override; |
| 54 | 54 |
| 55 // V8StackTrace implementation. | 55 // V8StackTrace implementation. |
| 56 bool isEmpty() const override { return !m_frames.size(); }; | 56 bool isEmpty() const override { return !m_frames.size(); }; |
| 57 String16 topSourceURL() const override; | 57 String16 topSourceURL() const override; |
| 58 int topLineNumber() const override; | 58 int topLineNumber() const override; |
| 59 int topColumnNumber() const override; | 59 int topColumnNumber() const override; |
| 60 String16 topScriptId() const override; | 60 String16 topScriptId() const override; |
| 61 String16 topFunctionName() const override; | 61 String16 topFunctionName() const override; |
| 62 PassOwnPtr<protocol::Runtime::StackTrace> buildInspectorObject() const overr
ide; | 62 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObject() const
override; |
| 63 String16 toString() const override; | 63 String16 toString() const override; |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 V8StackTraceImpl(const String16& description, protocol::Vector<Frame>& frame
s, PassOwnPtr<V8StackTraceImpl> parent); | 66 V8StackTraceImpl(const String16& description, protocol::Vector<Frame>& frame
s, std::unique_ptr<V8StackTraceImpl> parent); |
| 67 | 67 |
| 68 String16 m_description; | 68 String16 m_description; |
| 69 protocol::Vector<Frame> m_frames; | 69 protocol::Vector<Frame> m_frames; |
| 70 OwnPtr<V8StackTraceImpl> m_parent; | 70 std::unique_ptr<V8StackTraceImpl> m_parent; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 } // namespace blink | 73 } // namespace blink |
| 74 | 74 |
| 75 #endif // V8StackTraceImpl_h | 75 #endif // V8StackTraceImpl_h |
| OLD | NEW |