| 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 <memory> | 7 #include <memory> |
| 8 #include "bindings/core/v8/V8BindingForCore.h" | 8 #include "bindings/core/v8/V8BindingForCore.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 12 matching lines...) Expand all Loading... |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 std::unique_ptr<v8_inspector::V8StackTrace> CaptureStackTrace(bool full) { | 25 std::unique_ptr<v8_inspector::V8StackTrace> CaptureStackTrace(bool full) { |
| 26 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 26 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 27 ThreadDebugger* debugger = ThreadDebugger::From(isolate); | 27 ThreadDebugger* debugger = ThreadDebugger::From(isolate); |
| 28 if (!debugger || !isolate->InContext()) | 28 if (!debugger || !isolate->InContext()) |
| 29 return nullptr; | 29 return nullptr; |
| 30 ScriptForbiddenScope::AllowUserAgentScript allow_scripting; | 30 ScriptForbiddenScope::AllowUserAgentScript allow_scripting; |
| 31 return debugger->GetV8Inspector()->captureStackTrace(full); | 31 return debugger->GetV8Inspector()->captureStackTrace(full); |
| 32 } | 32 } |
| 33 } | 33 } // namespace |
| 34 | 34 |
| 35 // static | 35 // static |
| 36 std::unique_ptr<SourceLocation> SourceLocation::Capture( | 36 std::unique_ptr<SourceLocation> SourceLocation::Capture( |
| 37 const String& url, | 37 const String& url, |
| 38 unsigned line_number, | 38 unsigned line_number, |
| 39 unsigned column_number) { | 39 unsigned column_number) { |
| 40 std::unique_ptr<v8_inspector::V8StackTrace> stack_trace = | 40 std::unique_ptr<v8_inspector::V8StackTrace> stack_trace = |
| 41 CaptureStackTrace(false); | 41 CaptureStackTrace(false); |
| 42 if (stack_trace && !stack_trace->isEmpty()) | 42 if (stack_trace && !stack_trace->isEmpty()) |
| 43 return SourceLocation::CreateFromNonEmptyV8StackTrace( | 43 return SourceLocation::CreateFromNonEmptyV8StackTrace( |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 return stack_trace_ ? stack_trace_->buildInspectorObject() : nullptr; | 196 return stack_trace_ ? stack_trace_->buildInspectorObject() : nullptr; |
| 197 } | 197 } |
| 198 | 198 |
| 199 String SourceLocation::ToString() const { | 199 String SourceLocation::ToString() const { |
| 200 if (!stack_trace_) | 200 if (!stack_trace_) |
| 201 return String(); | 201 return String(); |
| 202 return ToCoreString(stack_trace_->toString()); | 202 return ToCoreString(stack_trace_->toString()); |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace blink | 205 } // namespace blink |
| OLD | NEW |