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

Unified Diff: src/promise.js

Issue 393283007: Introduce more debug events for promises. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 6 years, 5 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
Index: src/promise.js
diff --git a/src/promise.js b/src/promise.js
index 2797d79acbc83941058bc7f189dc228957fc82c9..acc705a3f17a0b1ddd6200eeb210b199dab0c334 100644
--- a/src/promise.js
+++ b/src/promise.js
@@ -40,7 +40,7 @@ var lastMicrotaskId = 0;
throw MakeTypeError('resolver_not_a_function', [resolver]);
var promise = PromiseInit(this);
if (DEBUG_IS_ACTIVE) {
- %DebugPromiseEvent({ type : "new Promise",
+ %DebugPromiseEvent({ type : "new",
promise: this,
resolver: resolver });
}
@@ -74,6 +74,12 @@ var lastMicrotaskId = 0;
if (GET_PRIVATE(promise, promiseStatus) === 0) {
PromiseEnqueue(value, GET_PRIVATE(promise, promiseQueue), status);
PromiseSet(promise, status, value);
+ if (DEBUG_IS_ACTIVE) {
+ %DebugPromiseEvent({ type: "update",
+ promise: promise,
+ status: status,
+ value: value });
+ }
}
}
@@ -192,21 +198,37 @@ var lastMicrotaskId = 0;
}
function PromiseResolved(x) {
+ var promise;
if (this === $Promise) {
// Optimized case, avoid extra closure.
- return PromiseSet(new $Promise(promiseRaw), +1, x);
+ promise = PromiseSet(new $Promise(promiseRaw), +1, x);
} else {
- return new this(function(resolve, reject) { resolve(x) });
+ promise = new this(function(resolve, reject) { resolve(x) });
+ }
+ if (DEBUG_IS_ACTIVE) {
+ %DebugPromiseEvent({ type: "update",
+ promise: promise,
+ status: 1,
+ value: x });
}
+ return promise;
}
function PromiseRejected(r) {
+ var promise;
if (this === $Promise) {
// Optimized case, avoid extra closure.
- return PromiseSet(new $Promise(promiseRaw), -1, r);
+ promise = PromiseSet(new $Promise(promiseRaw), -1, r);
} else {
- return new this(function(resolve, reject) { reject(r) });
+ promise = new this(function(resolve, reject) { reject(r) });
}
+ if (DEBUG_IS_ACTIVE) {
+ %DebugPromiseEvent({ type: "update",
aandrey 2014/07/22 11:58:49 now 3 update event calls instead of one doesn't lo
Alexandra Mikhaylova 2014/07/22 12:47:22 Done.
+ promise: promise,
+ status: -1,
+ value: r });
+ }
+ return promise;
}
// Simple chaining.
@@ -234,6 +256,11 @@ var lastMicrotaskId = 0;
-1);
break;
}
+ if (DEBUG_IS_ACTIVE) {
+ %DebugPromiseEvent({ type: "chain",
+ promise: deferred.promise,
+ parentPromise: this });
+ }
return deferred.promise;
}

Powered by Google App Engine
This is Rietveld 408576698