Commit 1ab717db authored by tzik's avatar tzik Committed by Commit Bot

Expose the depth of MicrotasksScope per MicrotaskQueue

Blink used to use v8::MicrotasksScope::GetCurrentDepth() to get the
number of nested MicrotasksScope for the default microtask queue.
However, there was no corresponding one for non-default queues.

Change-Id: I1c2472ba19b1a11cb968f02119d91d92867c6e02
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1567705Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60862}
parent 886c6583
......@@ -6817,6 +6817,12 @@ class V8_EXPORT MicrotaskQueue {
*/
virtual bool IsRunningMicrotasks() const = 0;
/**
* Returns the current depth of nested MicrotasksScope that has
* kRunMicrotasks.
*/
virtual int GetMicrotasksScopeDepth() const = 0;
private:
friend class internal::MicrotaskQueue;
MicrotaskQueue() = default;
......
......@@ -211,6 +211,10 @@ void MicrotaskQueue::IterateMicrotasks(RootVisitor* visitor) {
}
}
int MicrotaskQueue::GetMicrotasksScopeDepth() const {
return microtasks_depth_;
}
void MicrotaskQueue::AddMicrotasksCompletedCallback(
MicrotasksCompletedCallbackWithData callback, void* data) {
CallbackWithData callback_with_data(callback, data);
......
......@@ -62,7 +62,7 @@ class V8_EXPORT_PRIVATE MicrotaskQueue final : public v8::MicrotaskQueue {
// invocation, which happens when depth reaches zero.
void IncrementMicrotasksScopeDepth() { ++microtasks_depth_; }
void DecrementMicrotasksScopeDepth() { --microtasks_depth_; }
int GetMicrotasksScopeDepth() const { return microtasks_depth_; }
int GetMicrotasksScopeDepth() const override;
// Possibly nested microtasks suppression scopes prevent microtasks
// from running.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment