| 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 SourceLocation_h | 5 #ifndef SourceLocation_h |
| 6 #define SourceLocation_h | 6 #define SourceLocation_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "platform/v8_inspector/public/V8StackTrace.h" | 9 #include "platform/v8_inspector/public/V8StackTrace.h" |
| 10 #include "wtf/Forward.h" | 10 #include "wtf/Forward.h" |
| 11 #include "wtf/PassOwnPtr.h" | 11 #include "wtf/PassOwnPtr.h" |
| 12 #include "wtf/text/WTFString.h" | 12 #include "wtf/text/WTFString.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 class ExecutionContext; | 16 class ExecutionContext; |
| 17 class TracedValue; | 17 class TracedValue; |
| 18 class V8StackTrace; | 18 class V8StackTrace; |
| 19 | 19 |
| 20 namespace protocol { namespace Runtime { class StackTrace; }} |
| 21 |
| 20 class CORE_EXPORT SourceLocation { | 22 class CORE_EXPORT SourceLocation { |
| 21 public: | 23 public: |
| 22 // Zero lineNumber and columnNumber mean unknown. Captures current stack tra
ce. | 24 // Zero lineNumber and columnNumber mean unknown. Captures current stack tra
ce. |
| 23 static PassOwnPtr<SourceLocation> capture(const String& url, unsigned lineNu
mber, unsigned columnNumber); | 25 static PassOwnPtr<SourceLocation> capture(const String& url, unsigned lineNu
mber, unsigned columnNumber); |
| 24 | 26 |
| 25 // Shortcut when location is unknown. Tries to capture call stack or parsing
location if available. | 27 // Shortcut when location is unknown. Tries to capture call stack or parsing
location if available. |
| 26 static PassOwnPtr<SourceLocation> capture(ExecutionContext* = nullptr); | 28 static PassOwnPtr<SourceLocation> capture(ExecutionContext* = nullptr); |
| 27 | 29 |
| 28 static PassOwnPtr<SourceLocation> fromMessage(v8::Isolate*, v8::Local<v8::Me
ssage>, ExecutionContext*); | 30 static PassOwnPtr<SourceLocation> fromMessage(v8::Isolate*, v8::Local<v8::Me
ssage>, ExecutionContext*); |
| 29 | 31 |
| 32 static PassOwnPtr<SourceLocation> fromFunction(v8::Local<v8::Function>); |
| 33 |
| 34 // Forces full stack trace. |
| 35 static PassOwnPtr<SourceLocation> captureWithFullStackTrace(); |
| 36 |
| 30 static PassOwnPtr<SourceLocation> create(const String& url, unsigned lineNum
ber, unsigned columnNumber, std::unique_ptr<V8StackTrace>, int scriptId = 0); | 37 static PassOwnPtr<SourceLocation> create(const String& url, unsigned lineNum
ber, unsigned columnNumber, std::unique_ptr<V8StackTrace>, int scriptId = 0); |
| 31 ~SourceLocation(); | 38 ~SourceLocation(); |
| 32 | 39 |
| 33 bool isEmpty() const { return m_url.isNull(); } | 40 bool isUnknown() const { return m_url.isNull() && !m_scriptId && !m_lineNumb
er; } |
| 34 const String& url() const { return m_url; } | 41 const String& url() const { return m_url; } |
| 35 unsigned lineNumber() const { return m_lineNumber; } | 42 unsigned lineNumber() const { return m_lineNumber; } |
| 36 unsigned columnNumber() const { return m_columnNumber; } | 43 unsigned columnNumber() const { return m_columnNumber; } |
| 37 std::unique_ptr<V8StackTrace> takeStackTrace() { return std::move(m_stackTra
ce); } | |
| 38 int scriptId() const { return m_scriptId; } | 44 int scriptId() const { return m_scriptId; } |
| 45 |
| 46 PassOwnPtr<SourceLocation> clone() const; |
| 47 |
| 48 // No-op when stack trace is unknown. |
| 39 void toTracedValue(TracedValue*, const char* name) const; | 49 void toTracedValue(TracedValue*, const char* name) const; |
| 40 PassOwnPtr<SourceLocation> clone() const; | 50 |
| 51 // Could be null string when stack trace is unknown. |
| 52 String toString() const; |
| 53 |
| 54 // Could be null when stack trace is unknown. |
| 55 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObject() const; |
| 41 | 56 |
| 42 private: | 57 private: |
| 43 SourceLocation(const String& url, unsigned lineNumber, unsigned columnNumber
, std::unique_ptr<V8StackTrace>, int scriptId); | 58 SourceLocation(const String& url, unsigned lineNumber, unsigned columnNumber
, std::unique_ptr<V8StackTrace>, int scriptId); |
| 44 static PassOwnPtr<SourceLocation> createFromNonEmptyV8StackTrace(std::unique
_ptr<V8StackTrace>, int scriptId); | 59 static PassOwnPtr<SourceLocation> createFromNonEmptyV8StackTrace(std::unique
_ptr<V8StackTrace>, int scriptId); |
| 45 | 60 |
| 46 String m_url; | 61 String m_url; |
| 47 unsigned m_lineNumber; | 62 unsigned m_lineNumber; |
| 48 unsigned m_columnNumber; | 63 unsigned m_columnNumber; |
| 49 std::unique_ptr<V8StackTrace> m_stackTrace; | 64 std::unique_ptr<V8StackTrace> m_stackTrace; |
| 50 int m_scriptId; | 65 int m_scriptId; |
| 51 }; | 66 }; |
| 52 | 67 |
| 53 } // namespace blink | 68 } // namespace blink |
| 54 | 69 |
| 55 #endif // SourceLocation_h | 70 #endif // SourceLocation_h |
| OLD | NEW |