Chromium Code Reviews| Index: Source/bindings/v8/custom/V8PromiseCustom.cpp |
| diff --git a/Source/bindings/v8/custom/V8PromiseCustom.cpp b/Source/bindings/v8/custom/V8PromiseCustom.cpp |
| index 14200e2541949968394eeac583b2fa28360c0c6f..2c2a8e421926e36233e11bf80450d18b30764ce1 100644 |
| --- a/Source/bindings/v8/custom/V8PromiseCustom.cpp |
| +++ b/Source/bindings/v8/custom/V8PromiseCustom.cpp |
| @@ -45,7 +45,7 @@ |
| #include "core/dom/ExecutionContextTask.h" |
| #include "core/frame/DOMWindow.h" |
| #include "core/frame/UseCounter.h" |
| -#include "core/inspector/InspectorInstrumentation.h" |
| +#include "core/inspector/InspectorPromiseInstrumentation.h" |
| #include "core/workers/WorkerGlobalScope.h" |
| #include "platform/Task.h" |
| #include "wtf/Deque.h" |
| @@ -385,17 +385,15 @@ void PromisePropagator::performPropagation(v8::Isolate* isolate) |
| void PromisePropagator::setValue(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> value, v8::Isolate* isolate) |
| { |
| - v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise); |
| - ASSERT(V8PromiseCustom::getState(internal) != V8PromiseCustom::Fulfilled && V8PromiseCustom::getState(internal) != V8PromiseCustom::Rejected); |
| - V8PromiseCustom::setState(internal, V8PromiseCustom::Fulfilled, value, isolate); |
| + ASSERT(V8PromiseCustom::getState(V8PromiseCustom::getInternal(promise)) != V8PromiseCustom::Fulfilled && V8PromiseCustom::getState(V8PromiseCustom::getInternal(promise)) != V8PromiseCustom::Rejected); |
| + V8PromiseCustom::setState(promise, V8PromiseCustom::Fulfilled, value, isolate); |
| propagateToDerived(promise, isolate); |
| } |
| void PromisePropagator::setReason(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> reason, v8::Isolate* isolate) |
| { |
| - v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise); |
| - ASSERT(V8PromiseCustom::getState(internal) != V8PromiseCustom::Fulfilled && V8PromiseCustom::getState(internal) != V8PromiseCustom::Rejected); |
| - V8PromiseCustom::setState(internal, V8PromiseCustom::Rejected, reason, isolate); |
| + ASSERT(V8PromiseCustom::getState(V8PromiseCustom::getInternal(promise)) != V8PromiseCustom::Fulfilled && V8PromiseCustom::getState(V8PromiseCustom::getInternal(promise)) != V8PromiseCustom::Rejected); |
| + V8PromiseCustom::setState(promise, V8PromiseCustom::Rejected, reason, isolate); |
| propagateToDerived(promise, isolate); |
| } |
| @@ -476,6 +474,11 @@ void PromisePropagator::updateDerivedFromPromise(v8::Handle<v8::Object> derivedP |
| } else { |
| addToDerived(internal, derivedPromise, onFulfilled, onRejected, isolate); |
| } |
| + ExecutionContext* context = currentExecutionContext(isolate); |
| + if (InspectorInstrumentation::isPromiseOfficerEnabled(context)) { |
|
yurys
2014/03/12 10:56:53
isPromiseInstrumentationEnabled
Alexandra Mikhaylova
2014/03/12 12:11:51
Done.
aandrey
2014/03/12 12:16:33
The async stacks instrumentation should always be
|
| + ScriptState* scriptState = ScriptState::forContext(isolate->GetCurrentContext()); |
| + InspectorInstrumentation::didUpdatePromiseParent(context, ScriptObject(scriptState, derivedPromise), ScriptObject(scriptState, promise)); |
| + } |
| } |
| } // namespace |
| @@ -641,9 +644,13 @@ v8::Local<v8::Object> V8PromiseCustom::createPromise(v8::Handle<v8::Object> crea |
| v8::Local<v8::Object> promise = V8DOMWrapper::createWrapper(creationContext, &V8Promise::wrapperTypeInfo, 0, isolate); |
| clearDerived(internal, isolate); |
| - setState(internal, Pending, v8::Undefined(isolate), isolate); |
| - |
| promise->SetInternalField(v8DOMWrapperObjectIndex, internal); |
| + |
| + ExecutionContext* context = currentExecutionContext(isolate); |
| + if (InspectorInstrumentation::isPromiseOfficerEnabled(context)) |
| + InspectorInstrumentation::didCreatePromise(context, ScriptObject(ScriptState::forContext(isolate->GetCurrentContext()), promise)); |
| + |
| + setState(promise, Pending, v8::Undefined(isolate), isolate); |
| return promise; |
| } |
| @@ -661,12 +668,16 @@ V8PromiseCustom::PromiseState V8PromiseCustom::getState(v8::Handle<v8::Object> i |
| return static_cast<PromiseState>(number); |
| } |
| -void V8PromiseCustom::setState(v8::Handle<v8::Object> internal, PromiseState state, v8::Handle<v8::Value> value, v8::Isolate* isolate) |
| +void V8PromiseCustom::setState(v8::Handle<v8::Object> promise, PromiseState state, v8::Handle<v8::Value> value, v8::Isolate* isolate) |
| { |
| ASSERT(!value.IsEmpty()); |
| ASSERT(state == Pending || state == Fulfilled || state == Rejected || state == Following); |
| + v8::Local<v8::Object> internal = getInternal(promise); |
| internal->SetInternalField(InternalStateIndex, v8::Integer::New(isolate, state)); |
| internal->SetInternalField(InternalResultIndex, value); |
| + ExecutionContext* context = currentExecutionContext(isolate); |
| + if (InspectorInstrumentation::isPromiseOfficerEnabled(context)) |
| + InspectorInstrumentation::didUpdatePromiseState(context, ScriptObject(ScriptState::forContext(isolate->GetCurrentContext()), promise), state, ScriptValue(value, isolate)); |
| } |
| bool V8PromiseCustom::isPromise(v8::Handle<v8::Value> maybePromise, v8::Isolate* isolate) |
| @@ -705,7 +716,7 @@ void V8PromiseCustom::resolve(v8::Handle<v8::Object> promise, v8::Handle<v8::Val |
| setReason(promise, reason, isolate); |
| } else if (valueState == Following) { |
| v8::Local<v8::Object> valuePromiseFollowing = valueInternal->GetInternalField(InternalResultIndex).As<v8::Object>(); |
| - setState(internal, Following, valuePromiseFollowing, isolate); |
| + setState(promise, Following, valuePromiseFollowing, isolate); |
| addToDerived(getInternal(valuePromiseFollowing), promise, v8::Handle<v8::Function>(), v8::Handle<v8::Function>(), isolate); |
| } else if (valueState == Fulfilled) { |
| setValue(promise, valueInternal->GetInternalField(InternalResultIndex), isolate); |
| @@ -713,7 +724,7 @@ void V8PromiseCustom::resolve(v8::Handle<v8::Object> promise, v8::Handle<v8::Val |
| setReason(promise, valueInternal->GetInternalField(InternalResultIndex), isolate); |
| } else { |
| ASSERT(valueState == Pending); |
| - setState(internal, Following, valuePromise, isolate); |
| + setState(promise, Following, valuePromise, isolate); |
| addToDerived(valueInternal, promise, v8::Handle<v8::Function>(), v8::Handle<v8::Function>(), isolate); |
| } |
| } else { |