 Chromium Code Reviews
 Chromium Code Reviews Issue 177773002:
  Support Promises instrumentation on backend.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 177773002:
  Support Promises instrumentation on backend.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| 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..ae42c0b1ce1ed085ea55ea1bb901ebdcb03ec6b4 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); | 
| 
yurys
2014/03/05 15:23:35
Internal is still used twice so it would make sens
 
Alexandra Mikhaylova
2014/03/07 11:11:44
Then there would be problems with the release buil
 | 
| + 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); | 
| 
yurys
2014/03/05 15:23:35
ditto
 | 
| + V8PromiseCustom::setState(promise, V8PromiseCustom::Rejected, reason, isolate); | 
| propagateToDerived(promise, isolate); | 
| } | 
| @@ -476,6 +474,7 @@ void PromisePropagator::updateDerivedFromPromise(v8::Handle<v8::Object> derivedP | 
| } else { | 
| addToDerived(internal, derivedPromise, onFulfilled, onRejected, isolate); | 
| } | 
| + InspectorInstrumentation::didUpdatePromiseParent(currentExecutionContext(isolate), derivedPromise, promise); | 
| } | 
| } // namespace | 
| @@ -641,9 +640,11 @@ 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); | 
| + | 
| + InspectorInstrumentation::didCreatePromise(currentExecutionContext(isolate), promise); | 
| + | 
| + setState(promise, Pending, v8::Undefined(isolate), isolate); | 
| return promise; | 
| } | 
| @@ -661,12 +662,14 @@ 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); | 
| + InspectorInstrumentation::didUpdatePromiseState(currentExecutionContext(isolate), promise, state, value); | 
| } | 
| bool V8PromiseCustom::isPromise(v8::Handle<v8::Value> maybePromise, v8::Isolate* isolate) | 
| @@ -705,7 +708,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 +716,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 { |