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

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

Issue 2035653006: [DevTools] Move Console to v8 inspector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: all tests pass 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 #include "bindings/core/v8/SourceLocation.h" 5 #include "bindings/core/v8/SourceLocation.h"
6 6
7 #include "bindings/core/v8/V8BindingMacros.h" 7 #include "bindings/core/v8/V8BindingMacros.h"
8 #include "bindings/core/v8/V8PerIsolateData.h" 8 #include "bindings/core/v8/V8PerIsolateData.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/ExecutionContext.h" 10 #include "core/dom/ExecutionContext.h"
11 #include "core/dom/ScriptableDocumentParser.h" 11 #include "core/dom/ScriptableDocumentParser.h"
12 #include "core/html/HTMLFrameOwnerElement.h" 12 #include "core/html/HTMLFrameOwnerElement.h"
13 #include "core/inspector/InspectorInstrumentation.h" 13 #include "core/inspector/InspectorInstrumentation.h"
14 #include "core/inspector/ThreadDebugger.h" 14 #include "core/inspector/ThreadDebugger.h"
15 #include "platform/ScriptForbiddenScope.h" 15 #include "platform/ScriptForbiddenScope.h"
16 #include "platform/TracedValue.h" 16 #include "platform/TracedValue.h"
17 #include "platform/v8_inspector/public/V8Debugger.h" 17 #include "platform/v8_inspector/public/V8Debugger.h"
18 18
19 namespace blink { 19 namespace blink {
20 20
21 namespace { 21 namespace {
22 22
23 std::unique_ptr<V8StackTrace> captureStackTrace(bool full) 23 std::unique_ptr<V8StackTrace> captureStackTrace(bool full)
24 { 24 {
25 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 25 v8::Isolate* isolate = v8::Isolate::GetCurrent();
26 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 26 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
27 if (!data->threadDebugger() || !isolate->InContext()) 27 if (!data->threadDebugger() || !isolate->InContext())
28 return nullptr; 28 return nullptr;
29 size_t stackSize = full ? V8StackTrace::maxCallStackSizeToCapture : 1;
30 if (InspectorInstrumentation::hasFrontends()) {
31 if (InspectorInstrumentation::consoleAgentEnabled(currentExecutionContex t(isolate)))
32 stackSize = V8StackTrace::maxCallStackSizeToCapture;
33 }
34 ScriptForbiddenScope::AllowUserAgentScript allowScripting; 29 ScriptForbiddenScope::AllowUserAgentScript allowScripting;
35 return data->threadDebugger()->debugger()->captureStackTrace(stackSize); 30 return data->threadDebugger()->debugger()->captureStackTrace(full);
36 } 31 }
37 32
38 } 33 }
39 34
40 // static 35 // static
41 PassOwnPtr<SourceLocation> SourceLocation::capture(const String& url, unsigned l ineNumber, unsigned columnNumber) 36 PassOwnPtr<SourceLocation> SourceLocation::capture(const String& url, unsigned l ineNumber, unsigned columnNumber)
42 { 37 {
43 std::unique_ptr<V8StackTrace> stackTrace = captureStackTrace(false); 38 std::unique_ptr<V8StackTrace> stackTrace = captureStackTrace(false);
44 if (stackTrace && !stackTrace->isEmpty()) 39 if (stackTrace && !stackTrace->isEmpty())
45 return SourceLocation::createFromNonEmptyV8StackTrace(std::move(stackTra ce), 0); 40 return SourceLocation::createFromNonEmptyV8StackTrace(std::move(stackTra ce), 0);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 value->beginDictionary(); 146 value->beginDictionary();
152 value->setString("functionName", m_stackTrace->topFunctionName()); 147 value->setString("functionName", m_stackTrace->topFunctionName());
153 value->setString("scriptId", m_stackTrace->topScriptId()); 148 value->setString("scriptId", m_stackTrace->topScriptId());
154 value->setString("url", m_stackTrace->topSourceURL()); 149 value->setString("url", m_stackTrace->topSourceURL());
155 value->setInteger("lineNumber", m_stackTrace->topLineNumber()); 150 value->setInteger("lineNumber", m_stackTrace->topLineNumber());
156 value->setInteger("columnNumber", m_stackTrace->topColumnNumber()); 151 value->setInteger("columnNumber", m_stackTrace->topColumnNumber());
157 value->endDictionary(); 152 value->endDictionary();
158 value->endArray(); 153 value->endArray();
159 } 154 }
160 155
156 std::unique_ptr<V8StackTrace> SourceLocation::cloneStackTrace() const
157 {
158 return m_stackTrace ? m_stackTrace->clone() : nullptr;
159 };
160
161 PassOwnPtr<SourceLocation> SourceLocation::clone() const 161 PassOwnPtr<SourceLocation> SourceLocation::clone() const
162 { 162 {
163 return adoptPtr(new SourceLocation(m_url, m_lineNumber, m_columnNumber, m_st ackTrace ? m_stackTrace->clone() : nullptr, m_scriptId)); 163 return adoptPtr(new SourceLocation(m_url, m_lineNumber, m_columnNumber, m_st ackTrace ? m_stackTrace->clone() : nullptr, m_scriptId));
164 } 164 }
165 165
166 PassOwnPtr<SourceLocation> SourceLocation::isolatedCopy() const 166 PassOwnPtr<SourceLocation> SourceLocation::isolatedCopy() const
167 { 167 {
168 return adoptPtr(new SourceLocation(m_url.isolatedCopy(), m_lineNumber, m_col umnNumber, m_stackTrace ? m_stackTrace->isolatedCopy() : nullptr, m_scriptId)); 168 return adoptPtr(new SourceLocation(m_url.isolatedCopy(), m_lineNumber, m_col umnNumber, m_stackTrace ? m_stackTrace->isolatedCopy() : nullptr, m_scriptId));
169 } 169 }
170 170
171 std::unique_ptr<protocol::Runtime::StackTrace> SourceLocation::buildInspectorObj ect() const 171 std::unique_ptr<protocol::Runtime::StackTrace> SourceLocation::buildInspectorObj ect() const
172 { 172 {
173 return m_stackTrace ? m_stackTrace->buildInspectorObject() : nullptr; 173 return m_stackTrace ? m_stackTrace->buildInspectorObject() : nullptr;
174 } 174 }
175 175
176 String SourceLocation::toString() const 176 String SourceLocation::toString() const
177 { 177 {
178 if (!m_stackTrace) 178 if (!m_stackTrace)
179 return String(); 179 return String();
180 return m_stackTrace->toString(); 180 return m_stackTrace->toString();
181 } 181 }
182 182
183 } // namespace blink 183 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698