| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "core/inspector/PromiseTracker.h" | 5 #include "core/inspector/PromiseTracker.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptCallStackFactory.h" | 7 #include "bindings/core/v8/ScriptCallStackFactory.h" |
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
| 10 #include "core/inspector/ScriptAsyncCallStack.h" | 10 #include "core/inspector/ScriptAsyncCallStack.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 if (!parentPromise.IsEmpty() && parentPromise->IsObject()) { | 149 if (!parentPromise.IsEmpty() && parentPromise->IsObject()) { |
| 150 v8::Local<v8::Object> handle = parentPromise->ToObject(scriptState->isol
ate()); | 150 v8::Local<v8::Object> handle = parentPromise->ToObject(scriptState->isol
ate()); |
| 151 bool parentIsNewPromise = false; | 151 bool parentIsNewPromise = false; |
| 152 int parentPromiseId = promiseId(handle, &parentIsNewPromise); | 152 int parentPromiseId = promiseId(handle, &parentIsNewPromise); |
| 153 promiseDetails->setParentId(parentPromiseId); | 153 promiseDetails->setParentId(parentPromiseId); |
| 154 } else { | 154 } else { |
| 155 if (!status) { | 155 if (!status) { |
| 156 if (isNewPromise) { | 156 if (isNewPromise) { |
| 157 promiseDetails->setCreationTime(currentTimeMS()); | 157 promiseDetails->setCreationTime(currentTimeMS()); |
| 158 RefPtrWillBeRawPtr<ScriptCallStack> stack = currentScriptCallSta
ck(m_captureStacks ? ScriptCallStack::maxCallStackSizeToCapture : 1); | 158 RefPtr<ScriptCallStack> stack = currentScriptCallStack(m_capture
Stacks ? ScriptCallStack::maxCallStackSizeToCapture : 1); |
| 159 if (stack) { | 159 if (stack) { |
| 160 if (stack->size()) { | 160 if (stack->size()) { |
| 161 promiseDetails->setCallFrame(stack->at(0).buildInspector
Object()); | 161 promiseDetails->setCallFrame(stack->at(0).buildInspector
Object()); |
| 162 if (m_captureStacks) | 162 if (m_captureStacks) |
| 163 promiseDetails->setCreationStack(stack->buildInspect
orArray()); | 163 promiseDetails->setCreationStack(stack->buildInspect
orArray()); |
| 164 } | 164 } |
| 165 RefPtrWillBeRawPtr<ScriptAsyncCallStack> asyncCallStack = st
ack->asyncCallStack(); | 165 RefPtr<ScriptAsyncCallStack> asyncCallStack = stack->asyncCa
llStack(); |
| 166 if (m_captureStacks && asyncCallStack) | 166 if (m_captureStacks && asyncCallStack) |
| 167 promiseDetails->setAsyncCreationStack(asyncCallStack->bu
ildInspectorObject()); | 167 promiseDetails->setAsyncCreationStack(asyncCallStack->bu
ildInspectorObject()); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 } else { | 170 } else { |
| 171 promiseDetails->setSettlementTime(currentTimeMS()); | 171 promiseDetails->setSettlementTime(currentTimeMS()); |
| 172 if (m_captureStacks) { | 172 if (m_captureStacks) { |
| 173 RefPtrWillBeRawPtr<ScriptCallStack> stack = currentScriptCallSta
ck(ScriptCallStack::maxCallStackSizeToCapture); | 173 RefPtr<ScriptCallStack> stack = currentScriptCallStack(ScriptCal
lStack::maxCallStackSizeToCapture); |
| 174 if (stack) { | 174 if (stack) { |
| 175 if (stack->size()) | 175 if (stack->size()) |
| 176 promiseDetails->setSettlementStack(stack->buildInspector
Array()); | 176 promiseDetails->setSettlementStack(stack->buildInspector
Array()); |
| 177 if (RefPtrWillBeRawPtr<ScriptAsyncCallStack> asyncCallStack
= stack->asyncCallStack()) | 177 if (RefPtr<ScriptAsyncCallStack> asyncCallStack = stack->asy
ncCallStack()) |
| 178 promiseDetails->setAsyncSettlementStack(asyncCallStack->
buildInspectorObject()); | 178 promiseDetails->setAsyncSettlementStack(asyncCallStack->
buildInspectorObject()); |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 m_listener->didUpdatePromise(eventType, promiseDetails.release()); | 184 m_listener->didUpdatePromise(eventType, promiseDetails.release()); |
| 185 } | 185 } |
| 186 | 186 |
| 187 ScriptValue PromiseTracker::promiseById(int promiseId) | 187 ScriptValue PromiseTracker::promiseById(int promiseId) |
| 188 { | 188 { |
| 189 ASSERT(isEnabled()); | 189 ASSERT(isEnabled()); |
| 190 v8::HandleScope scope(m_isolate); | 190 v8::HandleScope scope(m_isolate); |
| 191 v8::Local<v8::Object> value = m_idToPromise.Get(promiseId); | 191 v8::Local<v8::Object> value = m_idToPromise.Get(promiseId); |
| 192 if (value.IsEmpty()) | 192 if (value.IsEmpty()) |
| 193 return ScriptValue(); | 193 return ScriptValue(); |
| 194 return ScriptValue(ScriptState::from(value->CreationContext()) , value); | 194 return ScriptValue(ScriptState::from(value->CreationContext()) , value); |
| 195 } | 195 } |
| 196 | 196 |
| 197 } // namespace blink | 197 } // namespace blink |
| OLD | NEW |