| 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" |
| 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/V8Inspector.h" |
| 18 #include "wtf/PtrUtil.h" | 18 #include "wtf/PtrUtil.h" |
| 19 #include <memory> | 19 #include <memory> |
| 20 | 20 |
| 21 namespace blink { | 21 namespace blink { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 std::unique_ptr<V8StackTrace> captureStackTrace(bool full) | 25 std::unique_ptr<V8StackTrace> captureStackTrace(bool full) |
| 26 { | 26 { |
| 27 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 27 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 28 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 28 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 29 if (!data->threadDebugger() || !isolate->InContext()) | 29 if (!data->threadDebugger() || !isolate->InContext()) |
| 30 return nullptr; | 30 return nullptr; |
| 31 ScriptForbiddenScope::AllowUserAgentScript allowScripting; | 31 ScriptForbiddenScope::AllowUserAgentScript allowScripting; |
| 32 return data->threadDebugger()->debugger()->captureStackTrace(full); | 32 return data->threadDebugger()->v8Inspector()->captureStackTrace(full); |
| 33 } | 33 } |
| 34 | 34 |
| 35 } | 35 } |
| 36 | 36 |
| 37 // static | 37 // static |
| 38 std::unique_ptr<SourceLocation> SourceLocation::capture(const String& url, unsig
ned lineNumber, unsigned columnNumber) | 38 std::unique_ptr<SourceLocation> SourceLocation::capture(const String& url, unsig
ned lineNumber, unsigned columnNumber) |
| 39 { | 39 { |
| 40 std::unique_ptr<V8StackTrace> stackTrace = captureStackTrace(false); | 40 std::unique_ptr<V8StackTrace> stackTrace = captureStackTrace(false); |
| 41 if (stackTrace && !stackTrace->isEmpty()) | 41 if (stackTrace && !stackTrace->isEmpty()) |
| 42 return SourceLocation::createFromNonEmptyV8StackTrace(std::move(stackTra
ce), 0); | 42 return SourceLocation::createFromNonEmptyV8StackTrace(std::move(stackTra
ce), 0); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 63 return SourceLocation::create(executionContext ? executionContext->url().get
String() : String(), 0, 0, std::move(stackTrace)); | 63 return SourceLocation::create(executionContext ? executionContext->url().get
String() : String(), 0, 0, std::move(stackTrace)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // static | 66 // static |
| 67 std::unique_ptr<SourceLocation> SourceLocation::fromMessage(v8::Isolate* isolate
, v8::Local<v8::Message> message, ExecutionContext* executionContext) | 67 std::unique_ptr<SourceLocation> SourceLocation::fromMessage(v8::Isolate* isolate
, v8::Local<v8::Message> message, ExecutionContext* executionContext) |
| 68 { | 68 { |
| 69 v8::Local<v8::StackTrace> stack = message->GetStackTrace(); | 69 v8::Local<v8::StackTrace> stack = message->GetStackTrace(); |
| 70 std::unique_ptr<V8StackTrace> stackTrace = nullptr; | 70 std::unique_ptr<V8StackTrace> stackTrace = nullptr; |
| 71 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 71 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 72 if (data && data->threadDebugger()) | 72 if (data && data->threadDebugger()) |
| 73 stackTrace = data->threadDebugger()->debugger()->createStackTrace(stack)
; | 73 stackTrace = data->threadDebugger()->v8Inspector()->createStackTrace(sta
ck); |
| 74 | 74 |
| 75 int scriptId = message->GetScriptOrigin().ScriptID()->Value(); | 75 int scriptId = message->GetScriptOrigin().ScriptID()->Value(); |
| 76 if (!stack.IsEmpty() && stack->GetFrameCount() > 0) { | 76 if (!stack.IsEmpty() && stack->GetFrameCount() > 0) { |
| 77 int topScriptId = stack->GetFrame(0)->GetScriptId(); | 77 int topScriptId = stack->GetFrame(0)->GetScriptId(); |
| 78 if (topScriptId == scriptId) | 78 if (topScriptId == scriptId) |
| 79 scriptId = 0; | 79 scriptId = 0; |
| 80 } | 80 } |
| 81 | 81 |
| 82 int lineNumber = 0; | 82 int lineNumber = 0; |
| 83 int columnNumber = 0; | 83 int columnNumber = 0; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 } | 176 } |
| 177 | 177 |
| 178 String SourceLocation::toString() const | 178 String SourceLocation::toString() const |
| 179 { | 179 { |
| 180 if (!m_stackTrace) | 180 if (!m_stackTrace) |
| 181 return String(); | 181 return String(); |
| 182 return m_stackTrace->toString(); | 182 return m_stackTrace->toString(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 } // namespace blink | 185 } // namespace blink |
| OLD | NEW |