Index: third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp |
diff --git a/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp b/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp |
index f7e4197f4b94008753555589c481ea87de5ecacc..032e2b2cb8b275d70b6bb58932fd12315903f878 100644 |
--- a/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp |
+++ b/third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp |
@@ -42,7 +42,7 @@ PassOwnPtr<SourceLocation> SourceLocation::capture(const String& url, unsigned l |
{ |
std::unique_ptr<V8StackTrace> stackTrace = captureStackTrace(); |
if (stackTrace && !stackTrace->isEmpty()) |
- return SourceLocation::create(stackTrace->topSourceURL(), stackTrace->topLineNumber(), stackTrace->topColumnNumber(), std::move(stackTrace), 0); |
+ return SourceLocation::createFromNonEmptyV8StackTrace(std::move(stackTrace), 0); |
return SourceLocation::create(url, lineNumber, columnNumber, std::move(stackTrace)); |
} |
@@ -51,7 +51,7 @@ PassOwnPtr<SourceLocation> SourceLocation::capture(ExecutionContext* executionCo |
{ |
std::unique_ptr<V8StackTrace> stackTrace = captureStackTrace(); |
if (stackTrace && !stackTrace->isEmpty()) |
- return SourceLocation::create(stackTrace->topSourceURL(), stackTrace->topLineNumber(), stackTrace->topColumnNumber(), std::move(stackTrace), 0); |
+ return SourceLocation::createFromNonEmptyV8StackTrace(std::move(stackTrace), 0); |
Document* document = executionContext && executionContext->isDocument() ? toDocument(executionContext) : nullptr; |
if (document) { |
@@ -89,12 +89,12 @@ PassOwnPtr<SourceLocation> SourceLocation::fromMessage(v8::Isolate* isolate, v8: |
++columnNumber; |
if ((!scriptId || !lineNumber) && stackTrace && !stackTrace->isEmpty()) |
- return adoptPtr(new SourceLocation(stackTrace->topSourceURL(), stackTrace->topLineNumber(), stackTrace->topColumnNumber(), std::move(stackTrace), 0)); |
+ return SourceLocation::createFromNonEmptyV8StackTrace(std::move(stackTrace), 0); |
String url = toCoreStringWithUndefinedOrNullCheck(message->GetScriptOrigin().ResourceName()); |
if (url.isNull()) |
url = executionContext->url(); |
- return adoptPtr(new SourceLocation(url, lineNumber, columnNumber, std::move(stackTrace), scriptId)); |
+ return SourceLocation::create(url, lineNumber, columnNumber, std::move(stackTrace), scriptId); |
} |
// static |
@@ -103,6 +103,16 @@ PassOwnPtr<SourceLocation> SourceLocation::create(const String& url, unsigned li |
return adoptPtr(new SourceLocation(url, lineNumber, columnNumber, std::move(stackTrace), scriptId)); |
} |
+// static |
+PassOwnPtr<SourceLocation> SourceLocation::createFromNonEmptyV8StackTrace(std::unique_ptr<V8StackTrace> stackTrace, int scriptId) |
+{ |
+ // Retrieve the data before passing the ownership to SourceLocation. |
+ const String& url = stackTrace->topSourceURL(); |
+ unsigned lineNumber = stackTrace->topLineNumber(); |
+ unsigned columnNumber = stackTrace->topColumnNumber(); |
+ return adoptPtr(new SourceLocation(url, lineNumber, columnNumber, std::move(stackTrace), scriptId)); |
+} |
+ |
SourceLocation::SourceLocation(const String& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr<V8StackTrace> stackTrace, int scriptId) |
: m_url(url) |
, m_lineNumber(lineNumber) |