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

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: Fix style Created 6 years, 10 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 | « no previous file | Source/core/core.gyp » ('j') | Source/core/inspector/InspectorDebuggerAgent.h » ('J')
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..c77b35c08fef8fe1e7228e5e96d0485637a64b2d 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"
@@ -387,7 +387,7 @@ void PromisePropagator::setValue(v8::Handle<v8::Object> promise, v8::Handle<v8::
{
v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
aandrey 2014/02/28 16:08:13 move inside ASSERT: ASSERT(V8PromiseCustom::getSt
Alexandra Mikhaylova 2014/03/03 14:04:25 Done.
ASSERT(V8PromiseCustom::getState(internal) != V8PromiseCustom::Fulfilled && V8PromiseCustom::getState(internal) != V8PromiseCustom::Rejected);
- V8PromiseCustom::setState(internal, V8PromiseCustom::Fulfilled, value, isolate);
+ V8PromiseCustom::setState(promise, V8PromiseCustom::Fulfilled, value, isolate);
propagateToDerived(promise, isolate);
}
@@ -395,7 +395,7 @@ void PromisePropagator::setReason(v8::Handle<v8::Object> promise, v8::Handle<v8:
{
v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
aandrey 2014/02/28 16:08:13 ditto
Alexandra Mikhaylova 2014/03/03 14:04:25 Done.
ASSERT(V8PromiseCustom::getState(internal) != V8PromiseCustom::Fulfilled && V8PromiseCustom::getState(internal) != V8PromiseCustom::Rejected);
- V8PromiseCustom::setState(internal, V8PromiseCustom::Rejected, reason, isolate);
+ V8PromiseCustom::setState(promise, V8PromiseCustom::Rejected, reason, isolate);
propagateToDerived(promise, isolate);
}
@@ -469,6 +469,7 @@ void PromisePropagator::updateDerived(v8::Handle<v8::Object> derivedPromise, v8:
void PromisePropagator::updateDerivedFromPromise(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Handle<v8::Object> promise, v8::Isolate* isolate)
{
+ InspectorInstrumentation::didUpdatePromiseParent(currentExecutionContext(isolate), derivedPromise, promise);
aandrey 2014/02/28 16:08:13 move to the end of this func
Alexandra Mikhaylova 2014/03/03 14:04:25 Done.
v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
V8PromiseCustom::PromiseState state = V8PromiseCustom::getState(internal);
if (state == V8PromiseCustom::Fulfilled || state == V8PromiseCustom::Rejected) {
@@ -641,9 +642,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, v8::Handle<v8::Object>());
aandrey 2014/02/28 16:08:13 remove dummy v8::Handle<v8::Object>() argument
Alexandra Mikhaylova 2014/03/03 14:04:25 Removed promise parent argument in didCreatePromis
+
+ setState(promise, Pending, v8::Undefined(isolate), isolate);
return promise;
}
@@ -661,12 +664,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 +710,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 +718,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 | « no previous file | Source/core/core.gyp » ('j') | Source/core/inspector/InspectorDebuggerAgent.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698