OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
6 #include "sky/engine/core/inspector/ConsoleMessage.h" | 6 #include "sky/engine/core/inspector/ConsoleMessage.h" |
7 | 7 |
8 #include "sky/engine/bindings/core/v8/ScriptCallStackFactory.h" | |
9 #include "sky/engine/bindings/core/v8/ScriptValue.h" | |
10 #include "sky/engine/core/inspector/ScriptArguments.h" | |
11 #include "sky/engine/wtf/CurrentTime.h" | 8 #include "sky/engine/wtf/CurrentTime.h" |
12 #include "sky/engine/wtf/PassOwnPtr.h" | 9 #include "sky/engine/wtf/PassOwnPtr.h" |
13 | 10 |
14 namespace blink { | 11 namespace blink { |
15 | 12 |
16 ConsoleMessage::ConsoleMessage(MessageSource source, | 13 ConsoleMessage::ConsoleMessage(MessageSource source, |
17 MessageLevel level, | 14 MessageLevel level, |
18 const String& message, | 15 const String& message, |
19 const String& url, | 16 const String& url, |
20 unsigned lineNumber, | 17 unsigned lineNumber, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 unsigned ConsoleMessage::lineNumber() const | 66 unsigned ConsoleMessage::lineNumber() const |
70 { | 67 { |
71 return m_lineNumber; | 68 return m_lineNumber; |
72 } | 69 } |
73 | 70 |
74 void ConsoleMessage::setLineNumber(unsigned lineNumber) | 71 void ConsoleMessage::setLineNumber(unsigned lineNumber) |
75 { | 72 { |
76 m_lineNumber = lineNumber; | 73 m_lineNumber = lineNumber; |
77 } | 74 } |
78 | 75 |
79 PassRefPtr<ScriptCallStack> ConsoleMessage::callStack() const | |
80 { | |
81 return m_callStack; | |
82 } | |
83 | |
84 void ConsoleMessage::setCallStack(PassRefPtr<ScriptCallStack> callStack) | |
85 { | |
86 m_callStack = callStack; | |
87 } | |
88 | |
89 ScriptState* ConsoleMessage::scriptState() const | |
90 { | |
91 if (m_scriptState) | |
92 return m_scriptState->get(); | |
93 return nullptr; | |
94 } | |
95 | |
96 void ConsoleMessage::setScriptState(ScriptState* scriptState) | |
97 { | |
98 if (m_scriptState) | |
99 m_scriptState->clear(); | |
100 | |
101 if (scriptState) | |
102 m_scriptState = adoptPtr(new ScriptStateProtectingContext(scriptState)); | |
103 else | |
104 m_scriptState.clear(); | |
105 } | |
106 | |
107 PassRefPtr<ScriptArguments> ConsoleMessage::scriptArguments() const | |
108 { | |
109 return m_scriptArguments; | |
110 } | |
111 | |
112 void ConsoleMessage::setScriptArguments(PassRefPtr<ScriptArguments> scriptArgume
nts) | |
113 { | |
114 m_scriptArguments = scriptArguments; | |
115 } | |
116 | |
117 unsigned long ConsoleMessage::requestIdentifier() const | 76 unsigned long ConsoleMessage::requestIdentifier() const |
118 { | 77 { |
119 return m_requestIdentifier; | 78 return m_requestIdentifier; |
120 } | 79 } |
121 | 80 |
122 void ConsoleMessage::setRequestIdentifier(unsigned long requestIdentifier) | 81 void ConsoleMessage::setRequestIdentifier(unsigned long requestIdentifier) |
123 { | 82 { |
124 m_requestIdentifier = requestIdentifier; | 83 m_requestIdentifier = requestIdentifier; |
125 } | 84 } |
126 | 85 |
(...skipping 20 matching lines...) Expand all Loading... |
147 const String& ConsoleMessage::message() const | 106 const String& ConsoleMessage::message() const |
148 { | 107 { |
149 return m_message; | 108 return m_message; |
150 } | 109 } |
151 | 110 |
152 unsigned ConsoleMessage::columnNumber() const | 111 unsigned ConsoleMessage::columnNumber() const |
153 { | 112 { |
154 return m_columnNumber; | 113 return m_columnNumber; |
155 } | 114 } |
156 | 115 |
157 void ConsoleMessage::frameWindowDiscarded(LocalDOMWindow* window) | |
158 { | |
159 if (scriptState() && scriptState()->domWindow() == window) | |
160 setScriptState(nullptr); | |
161 | |
162 if (!m_scriptArguments) | |
163 return; | |
164 if (m_scriptArguments->scriptState()->domWindow() != window) | |
165 return; | |
166 if (!m_message) | |
167 m_message = "<message collected>"; | |
168 m_scriptArguments.clear(); | |
169 } | |
170 | |
171 unsigned ConsoleMessage::argumentCount() | |
172 { | |
173 if (m_scriptArguments) | |
174 return m_scriptArguments->argumentCount(); | |
175 return 0; | |
176 } | |
177 | |
178 void ConsoleMessage::collectCallStack() | |
179 { | |
180 if (m_type == EndGroupMessageType) | |
181 return; | |
182 | |
183 if (!m_callStack || m_source == ConsoleAPIMessageSource) | |
184 m_callStack = createScriptCallStackForConsole(ScriptCallStack::maxCallSt
ackSizeToCapture, true); | |
185 | |
186 if (m_callStack && m_callStack->size() && !m_scriptId) { | |
187 const ScriptCallFrame& frame = m_callStack->at(0); | |
188 m_url = frame.sourceURL(); | |
189 m_lineNumber = frame.lineNumber(); | |
190 m_columnNumber = frame.columnNumber(); | |
191 return; | |
192 } | |
193 | |
194 m_callStack.clear(); | |
195 } | |
196 | |
197 } // namespace blink | 116 } // namespace blink |
OLD | NEW |