Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Unified Diff: Source/bindings/v8/custom/V8PromiseCustom.cpp

Issue 177773002: Support Promises instrumentation on backend. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rename PromiseOfficer -> PromiseTracker Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/v8/ScriptObjectTraits.h ('k') | Source/core/core.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..68428c9028ac6e88968248e1f73aab7ef7581c0f 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::isPromiseTrackerEnabled(context)) {
+ 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::isPromiseTrackerEnabled(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)
yhirano 2014/03/13 01:43:00 I don't like the subtle difference of the paramete
yhirano 2014/03/13 01:43:00 Is it possible to delete V8PromiseCustom::setState
Alexandra Mikhaylova 2014/03/13 13:22:51 Thanks, fixed it.
{
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::isPromiseTrackerEnabled(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 {
« no previous file with comments | « Source/bindings/v8/ScriptObjectTraits.h ('k') | Source/core/core.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698