Chromium Code Reviews| 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/CrossThreadCopier.h" | 9 #include "platform/CrossThreadCopier.h" |
| 10 #include "platform/v8_inspector/public/V8StackTrace.h" | 10 #include "platform/v8_inspector/public/V8StackTrace.h" |
| 11 #include "wtf/Forward.h" | 11 #include "wtf/Forward.h" |
| 12 #include "wtf/text/WTFString.h" | 12 #include "wtf/text/WTFString.h" |
| 13 #include <memory> | 13 #include <memory> |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class ExecutionContext; | 17 class ExecutionContext; |
| 18 class TracedValue; | 18 class TracedValue; |
| 19 class V8StackTrace; | 19 class V8StackTrace; |
| 20 | 20 |
| 21 namespace protocol { namespace Runtime { class StackTrace; }} | |
| 22 | |
| 23 class CORE_EXPORT SourceLocation { | 21 class CORE_EXPORT SourceLocation { |
| 24 public: | 22 public: |
| 25 // Zero lineNumber and columnNumber mean unknown. Captures current stack tra ce. | 23 // Zero lineNumber and columnNumber mean unknown. Captures current stack tra ce. |
| 26 static std::unique_ptr<SourceLocation> capture(const String& url, unsigned l ineNumber, unsigned columnNumber); | 24 static std::unique_ptr<SourceLocation> capture(const String& url, unsigned l ineNumber, unsigned columnNumber); |
| 27 | 25 |
| 28 // Shortcut when location is unknown. Tries to capture call stack or parsing location if available. | 26 // Shortcut when location is unknown. Tries to capture call stack or parsing location if available. |
| 29 static std::unique_ptr<SourceLocation> capture(ExecutionContext* = nullptr); | 27 static std::unique_ptr<SourceLocation> capture(ExecutionContext* = nullptr); |
| 30 | 28 |
| 31 static std::unique_ptr<SourceLocation> fromMessage(v8::Isolate*, v8::Local<v 8::Message>, ExecutionContext*); | 29 static std::unique_ptr<SourceLocation> fromMessage(v8::Isolate*, v8::Local<v 8::Message>, ExecutionContext*); |
| 32 | 30 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 48 std::unique_ptr<SourceLocation> clone() const; | 46 std::unique_ptr<SourceLocation> clone() const; |
| 49 std::unique_ptr<SourceLocation> isolatedCopy() const; // Safe to pass betwee n threads. | 47 std::unique_ptr<SourceLocation> isolatedCopy() const; // Safe to pass betwee n threads. |
| 50 | 48 |
| 51 // No-op when stack trace is unknown. | 49 // No-op when stack trace is unknown. |
| 52 void toTracedValue(TracedValue*, const char* name) const; | 50 void toTracedValue(TracedValue*, const char* name) const; |
| 53 | 51 |
| 54 // Could be null string when stack trace is unknown. | 52 // Could be null string when stack trace is unknown. |
| 55 String toString() const; | 53 String toString() const; |
| 56 | 54 |
| 57 // Could be null when stack trace is unknown. | 55 // Could be null when stack trace is unknown. |
| 58 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObject() const; | 56 std::unique_ptr<protocol::Runtime::Exported::StackTrace> buildInspectorObjec t() const; |
|
pfeldman
2016/07/22 18:02:39
Runtime::API::StackTrace
dgozman
2016/07/22 21:21:19
Done.
| |
| 59 | 57 |
| 60 private: | 58 private: |
| 61 SourceLocation(const String& url, unsigned lineNumber, unsigned columnNumber , std::unique_ptr<V8StackTrace>, int scriptId); | 59 SourceLocation(const String& url, unsigned lineNumber, unsigned columnNumber , std::unique_ptr<V8StackTrace>, int scriptId); |
| 62 static std::unique_ptr<SourceLocation> createFromNonEmptyV8StackTrace(std::u nique_ptr<V8StackTrace>, int scriptId); | 60 static std::unique_ptr<SourceLocation> createFromNonEmptyV8StackTrace(std::u nique_ptr<V8StackTrace>, int scriptId); |
| 63 | 61 |
| 64 String m_url; | 62 String m_url; |
| 65 unsigned m_lineNumber; | 63 unsigned m_lineNumber; |
| 66 unsigned m_columnNumber; | 64 unsigned m_columnNumber; |
| 67 std::unique_ptr<V8StackTrace> m_stackTrace; | 65 std::unique_ptr<V8StackTrace> m_stackTrace; |
| 68 int m_scriptId; | 66 int m_scriptId; |
| 69 }; | 67 }; |
| 70 | 68 |
| 71 template <> | 69 template <> |
| 72 struct CrossThreadCopier<std::unique_ptr<SourceLocation>> { | 70 struct CrossThreadCopier<std::unique_ptr<SourceLocation>> { |
| 73 using Type = std::unique_ptr<SourceLocation>; | 71 using Type = std::unique_ptr<SourceLocation>; |
| 74 static Type copy(std::unique_ptr<SourceLocation> location) | 72 static Type copy(std::unique_ptr<SourceLocation> location) |
| 75 { | 73 { |
| 76 return location ? location->isolatedCopy() : nullptr; | 74 return location ? location->isolatedCopy() : nullptr; |
| 77 } | 75 } |
| 78 }; | 76 }; |
| 79 | 77 |
| 80 } // namespace blink | 78 } // namespace blink |
| 81 | 79 |
| 82 #endif // SourceLocation_h | 80 #endif // SourceLocation_h |
| OLD | NEW |