Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/SourceLocation.h

Issue 2016123002: Remove ScriptCallStack. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2006893004
Patch Set: rebased Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/PassOwnPtr.h" 12 #include "wtf/PassOwnPtr.h"
13 #include "wtf/text/WTFString.h" 13 #include "wtf/text/WTFString.h"
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
21 class CORE_EXPORT SourceLocation { 23 class CORE_EXPORT SourceLocation {
22 public: 24 public:
23 // Zero lineNumber and columnNumber mean unknown. Captures current stack tra ce. 25 // Zero lineNumber and columnNumber mean unknown. Captures current stack tra ce.
24 static PassOwnPtr<SourceLocation> capture(const String& url, unsigned lineNu mber, unsigned columnNumber); 26 static PassOwnPtr<SourceLocation> capture(const String& url, unsigned lineNu mber, unsigned columnNumber);
25 27
26 // Shortcut when location is unknown. Tries to capture call stack or parsing location if available. 28 // Shortcut when location is unknown. Tries to capture call stack or parsing location if available.
27 static PassOwnPtr<SourceLocation> capture(ExecutionContext* = nullptr); 29 static PassOwnPtr<SourceLocation> capture(ExecutionContext* = nullptr);
28 30
29 static PassOwnPtr<SourceLocation> fromMessage(v8::Isolate*, v8::Local<v8::Me ssage>, ExecutionContext*); 31 static PassOwnPtr<SourceLocation> fromMessage(v8::Isolate*, v8::Local<v8::Me ssage>, ExecutionContext*);
30 32
33 static PassOwnPtr<SourceLocation> fromFunction(v8::Local<v8::Function>);
34
35 // Forces full stack trace.
36 static PassOwnPtr<SourceLocation> captureWithFullStackTrace();
37
31 static PassOwnPtr<SourceLocation> create(const String& url, unsigned lineNum ber, unsigned columnNumber, std::unique_ptr<V8StackTrace>, int scriptId = 0); 38 static PassOwnPtr<SourceLocation> create(const String& url, unsigned lineNum ber, unsigned columnNumber, std::unique_ptr<V8StackTrace>, int scriptId = 0);
32 ~SourceLocation(); 39 ~SourceLocation();
33 40
34 bool isEmpty() const { return m_url.isNull(); } 41 bool isUnknown() const { return m_url.isNull() && !m_scriptId && !m_lineNumb er; }
35 const String& url() const { return m_url; } 42 const String& url() const { return m_url; }
36 unsigned lineNumber() const { return m_lineNumber; } 43 unsigned lineNumber() const { return m_lineNumber; }
37 unsigned columnNumber() const { return m_columnNumber; } 44 unsigned columnNumber() const { return m_columnNumber; }
38 std::unique_ptr<V8StackTrace> takeStackTrace() { return std::move(m_stackTra ce); }
39 int scriptId() const { return m_scriptId; } 45 int scriptId() const { return m_scriptId; }
40 void toTracedValue(TracedValue*, const char* name) const; 46
41 PassOwnPtr<SourceLocation> clone() const; 47 PassOwnPtr<SourceLocation> clone() const;
42 PassOwnPtr<SourceLocation> isolatedCopy() const; // Safe to pass between thr eads. 48 PassOwnPtr<SourceLocation> isolatedCopy() const; // Safe to pass between thr eads.
43 49
50 // No-op when stack trace is unknown.
51 void toTracedValue(TracedValue*, const char* name) const;
52
53 // Could be null string when stack trace is unknown.
54 String toString() const;
55
56 // Could be null when stack trace is unknown.
57 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObject() const;
58
44 private: 59 private:
45 SourceLocation(const String& url, unsigned lineNumber, unsigned columnNumber , std::unique_ptr<V8StackTrace>, int scriptId); 60 SourceLocation(const String& url, unsigned lineNumber, unsigned columnNumber , std::unique_ptr<V8StackTrace>, int scriptId);
46 static PassOwnPtr<SourceLocation> createFromNonEmptyV8StackTrace(std::unique _ptr<V8StackTrace>, int scriptId); 61 static PassOwnPtr<SourceLocation> createFromNonEmptyV8StackTrace(std::unique _ptr<V8StackTrace>, int scriptId);
47 62
48 String m_url; 63 String m_url;
49 unsigned m_lineNumber; 64 unsigned m_lineNumber;
50 unsigned m_columnNumber; 65 unsigned m_columnNumber;
51 std::unique_ptr<V8StackTrace> m_stackTrace; 66 std::unique_ptr<V8StackTrace> m_stackTrace;
52 int m_scriptId; 67 int m_scriptId;
53 }; 68 };
54 69
55 template <> 70 template <>
56 struct CrossThreadCopier<PassOwnPtr<SourceLocation>> { 71 struct CrossThreadCopier<PassOwnPtr<SourceLocation>> {
57 using Type = PassOwnPtr<SourceLocation>; 72 using Type = PassOwnPtr<SourceLocation>;
58 static Type copy(PassOwnPtr<SourceLocation> location) 73 static Type copy(PassOwnPtr<SourceLocation> location)
59 { 74 {
60 return location ? location->isolatedCopy() : nullptr; 75 return location ? location->isolatedCopy() : nullptr;
61 } 76 }
62 }; 77 };
63 78
64 } // namespace blink 79 } // namespace blink
65 80
66 #endif // SourceLocation_h 81 #endif // SourceLocation_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698