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

Unified Diff: Source/core/dom/Microtask.cpp

Issue 142193004: Create & use microtask work queue (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: sync Created 6 years, 11 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/core/dom/Microtask.h ('k') | Source/core/dom/MutationObserver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Microtask.cpp
diff --git a/Source/core/dom/Microtask.cpp b/Source/core/dom/Microtask.cpp
index 67e71a79ecea31afa62e1c1b9a51f7d5f6360278..86281b30b7941387c478c48fef40bd51edf02b3d 100644
--- a/Source/core/dom/Microtask.cpp
+++ b/Source/core/dom/Microtask.cpp
@@ -31,26 +31,46 @@
#include "config.h"
#include "core/dom/Microtask.h"
+#include "bindings/v8/V8PerIsolateData.h"
#include "core/dom/MutationObserver.h"
#include "core/dom/custom/CustomElementScheduler.h"
#include "wtf/Vector.h"
namespace WebCore {
+typedef Vector<MicrotaskCallback> MicrotaskQueue;
+
+static MicrotaskQueue& microtaskQueue()
+{
+ DEFINE_STATIC_LOCAL(MicrotaskQueue, microtaskQueue, ());
+ return microtaskQueue;
+}
+
void Microtask::performCheckpoint()
{
- static bool performingCheckpoint = false;
- if (performingCheckpoint)
+ V8PerIsolateData* isolateData = V8PerIsolateData::current();
+ ASSERT(isolateData);
+ if (isolateData->performingMicrotaskCheckpoint())
return;
- performingCheckpoint = true;
+ isolateData->setPerformingMicrotaskCheckpoint(true);
- bool anyWorkDone;
- do {
- MutationObserver::deliverAllMutations();
- anyWorkDone = CustomElementScheduler::dispatchMicrotaskProcessingSteps();
- } while (anyWorkDone);
+ // FIXME: Custom element's callbacks need to be refactored to enqueueMicrotask()
+ while (CustomElementScheduler::dispatchMicrotaskProcessingSteps() || !microtaskQueue().isEmpty()) {
+ if (microtaskQueue().isEmpty())
+ continue;
+ Vector<MicrotaskCallback> microtasks;
+ microtasks.swap(microtaskQueue());
+ for (size_t i = 0; i < microtasks.size(); ++i) {
+ microtasks[i]();
+ }
+ }
- performingCheckpoint = false;
+ isolateData->setPerformingMicrotaskCheckpoint(false);
+}
+
+void Microtask::enqueueMicrotask(MicrotaskCallback callback)
+{
+ microtaskQueue().append(callback);
}
} // namespace WebCore
« no previous file with comments | « Source/core/dom/Microtask.h ('k') | Source/core/dom/MutationObserver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698