Index: include/v8.h |
diff --git a/include/v8.h b/include/v8.h |
index dadd42feb94deda92007655689f48c4f452909a7..12b3b808a18df5fe674a79c48c78e6edc0b6dc2d 100644 |
--- a/include/v8.h |
+++ b/include/v8.h |
@@ -5756,6 +5756,27 @@ typedef void (*BeforeCallEnteredCallback)(Isolate*); |
typedef void (*CallCompletedCallback)(Isolate*); |
typedef void (*DeprecatedCallCompletedCallback)(); |
+/** |
+ * PromiseHook with type kInit is called when a new promise is |
+ * created. When a new promise is created as part of the chain in the |
+ * case of Promise.then or in the intermediate promises created by |
+ * Promise.{race, all}/AsyncFunctionAwait, we pass the parent promise |
+ * otherwise we pass undefined. |
+ * |
+ * PromiseHook with type kResolve is called at the beginning of |
+ * resolve or reject function defined by CreateResolvingFunctions. |
+ * |
+ * PromiseHook with type kBefore is called at the beginning of the |
+ * PromiseReactionJob. |
+ * |
+ * PromiseHook with type kAfter is called right at the end of the |
+ * PromiseReactionJob. |
+ */ |
+enum class PromiseHookType { kInit, kResolve, kBefore, kAfter }; |
+ |
+typedef void (*PromiseHook)(PromiseHookType type, Local<Promise> promise, |
+ Local<Value> parent); |
+ |
// --- Promise Reject Callback --- |
enum PromiseRejectEvent { |
kPromiseRejectWithNoHandler = 0, |
@@ -6867,6 +6888,12 @@ class V8_EXPORT Isolate { |
DeprecatedCallCompletedCallback callback)); |
/** |
+ * Experimental: Set the PromiseHook callback for various promise |
+ * lifecycle events. |
+ */ |
+ void SetPromiseHook(PromiseHook hook); |
+ |
+ /** |
* Set callback to notify about promise reject with no handler, or |
* revocation of such a previous notification once the handler is added. |
*/ |