| 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 #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" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 std::move(stackTrace), scriptId); | 111 std::move(stackTrace), scriptId); |
| 112 } | 112 } |
| 113 | 113 |
| 114 // static | 114 // static |
| 115 std::unique_ptr<SourceLocation> SourceLocation::create( | 115 std::unique_ptr<SourceLocation> SourceLocation::create( |
| 116 const String& url, | 116 const String& url, |
| 117 unsigned lineNumber, | 117 unsigned lineNumber, |
| 118 unsigned columnNumber, | 118 unsigned columnNumber, |
| 119 std::unique_ptr<v8_inspector::V8StackTrace> stackTrace, | 119 std::unique_ptr<v8_inspector::V8StackTrace> stackTrace, |
| 120 int scriptId) { | 120 int scriptId) { |
| 121 return wrapUnique(new SourceLocation(url, lineNumber, columnNumber, | 121 return WTF::wrapUnique(new SourceLocation(url, lineNumber, columnNumber, |
| 122 std::move(stackTrace), scriptId)); | 122 std::move(stackTrace), scriptId)); |
| 123 } | 123 } |
| 124 | 124 |
| 125 // static | 125 // static |
| 126 std::unique_ptr<SourceLocation> SourceLocation::createFromNonEmptyV8StackTrace( | 126 std::unique_ptr<SourceLocation> SourceLocation::createFromNonEmptyV8StackTrace( |
| 127 std::unique_ptr<v8_inspector::V8StackTrace> stackTrace, | 127 std::unique_ptr<v8_inspector::V8StackTrace> stackTrace, |
| 128 int scriptId) { | 128 int scriptId) { |
| 129 // Retrieve the data before passing the ownership to SourceLocation. | 129 // Retrieve the data before passing the ownership to SourceLocation. |
| 130 String url = toCoreString(stackTrace->topSourceURL()); | 130 String url = toCoreString(stackTrace->topSourceURL()); |
| 131 unsigned lineNumber = stackTrace->topLineNumber(); | 131 unsigned lineNumber = stackTrace->topLineNumber(); |
| 132 unsigned columnNumber = stackTrace->topColumnNumber(); | 132 unsigned columnNumber = stackTrace->topColumnNumber(); |
| 133 return wrapUnique(new SourceLocation(url, lineNumber, columnNumber, | 133 return WTF::wrapUnique(new SourceLocation(url, lineNumber, columnNumber, |
| 134 std::move(stackTrace), scriptId)); | 134 std::move(stackTrace), scriptId)); |
| 135 } | 135 } |
| 136 | 136 |
| 137 // static | 137 // static |
| 138 std::unique_ptr<SourceLocation> SourceLocation::fromFunction( | 138 std::unique_ptr<SourceLocation> SourceLocation::fromFunction( |
| 139 v8::Local<v8::Function> function) { | 139 v8::Local<v8::Function> function) { |
| 140 if (!function.IsEmpty()) | 140 if (!function.IsEmpty()) |
| 141 return SourceLocation::create( | 141 return SourceLocation::create( |
| 142 toCoreStringWithUndefinedOrNullCheck( | 142 toCoreStringWithUndefinedOrNullCheck( |
| 143 function->GetScriptOrigin().ResourceName()), | 143 function->GetScriptOrigin().ResourceName()), |
| 144 function->GetScriptLineNumber() + 1, | 144 function->GetScriptLineNumber() + 1, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 toCoreString(m_stackTrace->topFunctionName())); | 179 toCoreString(m_stackTrace->topFunctionName())); |
| 180 value->setString("scriptId", toCoreString(m_stackTrace->topScriptId())); | 180 value->setString("scriptId", toCoreString(m_stackTrace->topScriptId())); |
| 181 value->setString("url", toCoreString(m_stackTrace->topSourceURL())); | 181 value->setString("url", toCoreString(m_stackTrace->topSourceURL())); |
| 182 value->setInteger("lineNumber", m_stackTrace->topLineNumber()); | 182 value->setInteger("lineNumber", m_stackTrace->topLineNumber()); |
| 183 value->setInteger("columnNumber", m_stackTrace->topColumnNumber()); | 183 value->setInteger("columnNumber", m_stackTrace->topColumnNumber()); |
| 184 value->endDictionary(); | 184 value->endDictionary(); |
| 185 value->endArray(); | 185 value->endArray(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 std::unique_ptr<SourceLocation> SourceLocation::clone() const { | 188 std::unique_ptr<SourceLocation> SourceLocation::clone() const { |
| 189 return wrapUnique(new SourceLocation( | 189 return WTF::wrapUnique(new SourceLocation( |
| 190 m_url.isolatedCopy(), m_lineNumber, m_columnNumber, | 190 m_url.isolatedCopy(), m_lineNumber, m_columnNumber, |
| 191 m_stackTrace ? m_stackTrace->clone() : nullptr, m_scriptId)); | 191 m_stackTrace ? m_stackTrace->clone() : nullptr, m_scriptId)); |
| 192 } | 192 } |
| 193 | 193 |
| 194 std::unique_ptr<v8_inspector::protocol::Runtime::API::StackTrace> | 194 std::unique_ptr<v8_inspector::protocol::Runtime::API::StackTrace> |
| 195 SourceLocation::buildInspectorObject() const { | 195 SourceLocation::buildInspectorObject() const { |
| 196 return m_stackTrace ? m_stackTrace->buildInspectorObject() : nullptr; | 196 return m_stackTrace ? m_stackTrace->buildInspectorObject() : nullptr; |
| 197 } | 197 } |
| 198 | 198 |
| 199 String SourceLocation::toString() const { | 199 String SourceLocation::toString() const { |
| 200 if (!m_stackTrace) | 200 if (!m_stackTrace) |
| 201 return String(); | 201 return String(); |
| 202 return toCoreString(m_stackTrace->toString()); | 202 return toCoreString(m_stackTrace->toString()); |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace blink | 205 } // namespace blink |
| OLD | NEW |