OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 12 matching lines...) Expand all Loading... |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "core/inspector/ScriptCallStack.h" | 31 #include "core/inspector/ScriptCallStack.h" |
32 | 32 |
33 #include "core/inspector/ScriptAsyncCallStack.h" | |
34 #include "platform/TracedValue.h" | 33 #include "platform/TracedValue.h" |
35 | 34 |
36 namespace blink { | 35 namespace blink { |
37 | 36 |
38 PassRefPtr<ScriptCallStack> ScriptCallStack::create(Vector<ScriptCallFrame>& fra
mes) | 37 PassRefPtr<ScriptCallStack> ScriptCallStack::create(Vector<ScriptCallFrame>& fra
mes) |
39 { | 38 { |
40 return adoptRef(new ScriptCallStack(frames)); | 39 return adoptRef(new ScriptCallStack(String(), frames, nullptr)); |
41 } | 40 } |
42 | 41 |
43 ScriptCallStack::ScriptCallStack(Vector<ScriptCallFrame>& frames) | 42 PassRefPtr<ScriptCallStack> ScriptCallStack::create(const String& description, V
ector<ScriptCallFrame>& frames, PassRefPtr<ScriptCallStack> parent) |
| 43 { |
| 44 return adoptRef(new ScriptCallStack(description, frames, parent)); |
| 45 } |
| 46 |
| 47 ScriptCallStack::ScriptCallStack(const String& description, Vector<ScriptCallFra
me>& frames, PassRefPtr<ScriptCallStack> parent) |
| 48 : m_description(description) |
| 49 , m_parent(parent) |
44 { | 50 { |
45 m_frames.swap(frames); | 51 m_frames.swap(frames); |
46 } | 52 } |
47 | 53 |
48 ScriptCallStack::~ScriptCallStack() | 54 ScriptCallStack::~ScriptCallStack() |
49 { | 55 { |
50 } | 56 } |
51 | 57 |
52 const ScriptCallFrame &ScriptCallStack::at(size_t index) const | 58 const ScriptCallFrame &ScriptCallStack::at(size_t index) const |
53 { | 59 { |
54 ASSERT(m_frames.size() > index); | 60 ASSERT(m_frames.size() > index); |
55 return m_frames[index]; | 61 return m_frames[index]; |
56 } | 62 } |
57 | 63 |
| 64 void ScriptCallStack::setParent(PassRefPtr<ScriptCallStack> parent) |
| 65 { |
| 66 m_parent = parent; |
| 67 } |
| 68 |
58 size_t ScriptCallStack::size() const | 69 size_t ScriptCallStack::size() const |
59 { | 70 { |
60 return m_frames.size(); | 71 return m_frames.size(); |
61 } | 72 } |
62 | 73 |
63 PassRefPtr<ScriptAsyncCallStack> ScriptCallStack::asyncCallStack() const | 74 PassRefPtr<TypeBuilder::Runtime::StackTrace> ScriptCallStack::buildInspectorObje
ct() const |
64 { | 75 { |
65 return m_asyncCallStack; | 76 RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::CallFrame>> frames = TypeBui
lder::Array<TypeBuilder::Runtime::CallFrame>::create(); |
66 } | |
67 | |
68 void ScriptCallStack::setAsyncCallStack(PassRefPtr<ScriptAsyncCallStack> asyncCa
llStack) | |
69 { | |
70 m_asyncCallStack = asyncCallStack; | |
71 } | |
72 | |
73 PassRefPtr<TypeBuilder::Array<TypeBuilder::Console::CallFrame> > ScriptCallStack
::buildInspectorArray() const | |
74 { | |
75 RefPtr<TypeBuilder::Array<TypeBuilder::Console::CallFrame> > frames = TypeBu
ilder::Array<TypeBuilder::Console::CallFrame>::create(); | |
76 for (size_t i = 0; i < m_frames.size(); i++) | 77 for (size_t i = 0; i < m_frames.size(); i++) |
77 frames->addItem(m_frames.at(i).buildInspectorObject()); | 78 frames->addItem(m_frames.at(i).buildInspectorObject()); |
78 return frames; | 79 |
| 80 RefPtr<TypeBuilder::Runtime::StackTrace> stackTrace = TypeBuilder::Runtime::
StackTrace::create() |
| 81 .setCallFrames(frames.release()); |
| 82 if (!m_description.isEmpty()) |
| 83 stackTrace->setDescription(m_description); |
| 84 if (m_parent) |
| 85 stackTrace->setParent(m_parent->buildInspectorObject()); |
| 86 return stackTrace; |
79 } | 87 } |
80 | 88 |
81 void ScriptCallStack::toTracedValue(TracedValue* value, const char* name) const | 89 void ScriptCallStack::toTracedValue(TracedValue* value, const char* name) const |
82 { | 90 { |
83 value->beginArray(name); | 91 value->beginArray(name); |
84 for (size_t i = 0; i < m_frames.size(); i++) | 92 for (size_t i = 0; i < m_frames.size(); i++) |
85 m_frames.at(i).toTracedValue(value); | 93 m_frames.at(i).toTracedValue(value); |
86 value->endArray(); | 94 value->endArray(); |
87 } | 95 } |
88 | 96 |
89 } // namespace blink | 97 } // namespace blink |
OLD | NEW |