This source file includes following definitions.
- m_callStackOnCreate
- didSettlePromise
- enable
- disable
- clear
- didCreatePromise
- didUpdatePromiseParent
- didUpdatePromiseState
#include "config.h"
#include "bindings/v8/ScriptCallStackFactory.h"
#include "core/inspector/PromiseTracker.h"
#include "wtf/CurrentTime.h"
namespace WebCore {
PromiseTracker::PromiseData::PromiseData(const ScriptObject& promise, const ScriptObject& parentPromise, const ScriptValue& result, V8PromiseCustom::PromiseState state, double timestamp)
: m_promise(promise)
, m_parentPromise(parentPromise)
, m_result(result)
, m_state(state)
, m_timeOnCreate(timestamp)
, m_timeOnSettle(-1)
, m_callStackOnCreate(createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true))
{
}
void PromiseTracker::PromiseData::didSettlePromise(double timestamp)
{
m_timeOnSettle = timestamp;
m_callStackOnSettle = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true);
}
void PromiseTracker::enable()
{
m_isEnabled = true;
}
void PromiseTracker::disable()
{
m_isEnabled = false;
clear();
}
void PromiseTracker::clear()
{
m_promiseDataMap.clear();
}
void PromiseTracker::didCreatePromise(const ScriptObject& promise)
{
ASSERT(isEnabled());
double timestamp = currentTimeMS();
m_promiseDataMap.set(promise, adoptRef(new PromiseData(promise, ScriptObject(), ScriptValue(), V8PromiseCustom::Pending, timestamp)));
}
void PromiseTracker::didUpdatePromiseParent(const ScriptObject& promise, const ScriptObject& parentPromise)
{
ASSERT(isEnabled());
RefPtr<PromiseData> data = m_promiseDataMap.get(promise);
ASSERT(data != NULL && data->m_promise == promise);
data->m_parentPromise = parentPromise;
}
void PromiseTracker::didUpdatePromiseState(const ScriptObject& promise, V8PromiseCustom::PromiseState state, const ScriptValue& result)
{
ASSERT(isEnabled());
double timestamp = currentTimeMS();
RefPtr<PromiseData> data = m_promiseDataMap.get(promise);
ASSERT(data != NULL && data->m_promise == promise);
data->m_state = state;
data->m_result = result;
if (state == V8PromiseCustom::Fulfilled || state == V8PromiseCustom::Rejected)
data->didSettlePromise(timestamp);
}
}