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

Unified Diff: sky/engine/core/dom/Microtask.cpp

Issue 922893002: Merge the Sky Engine changes from the SkyDart branch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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 | « sky/engine/core/dom/ExecutionContext.cpp ('k') | sky/engine/core/dom/MutationObserver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/dom/Microtask.cpp
diff --git a/sky/engine/core/dom/Microtask.cpp b/sky/engine/core/dom/Microtask.cpp
index 4b01acef2fe15b9efdc5019e590c8442f9798d28..04c27dcf9b1151320ae180e9329d54f754caa12a 100644
--- a/sky/engine/core/dom/Microtask.cpp
+++ b/sky/engine/core/dom/Microtask.cpp
@@ -32,10 +32,10 @@
#include "sky/engine/core/dom/Microtask.h"
#include "base/bind.h"
-#include "sky/engine/bindings/core/v8/V8PerIsolateData.h"
#include "sky/engine/platform/TraceEvent.h"
#include "sky/engine/public/platform/WebThread.h"
-#include "v8/include/v8.h"
+#include "sky/engine/wtf/OwnPtr.h"
+#include "sky/engine/wtf/Vector.h"
namespace blink {
@@ -59,29 +59,34 @@ private:
}
-void Microtask::performCheckpoint()
+// TODO(dart): Integrate this microtask queue with darts.
+typedef Vector<OwnPtr<WebThread::Task> > MicrotaskQueue;
+static MicrotaskQueue& microtaskQueue()
{
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- V8PerIsolateData* isolateData = V8PerIsolateData::from(isolate);
- ASSERT(isolateData);
- if (isolateData->recursionLevel() || isolateData->performingMicrotaskCheckpoint())
- return;
- TRACE_EVENT0("v8", "v8.runMicrotasks");
- isolateData->setPerformingMicrotaskCheckpoint(true);
- isolate->RunMicrotasks();
- isolateData->setPerformingMicrotaskCheckpoint(false);
+ DEFINE_STATIC_LOCAL(OwnPtr<MicrotaskQueue>, queue, (adoptPtr(new MicrotaskQueue())));
+ return *queue;
}
-static void microtaskFunctionCallback(void* data)
+void Microtask::performCheckpoint()
{
- OwnPtr<WebThread::Task> task = adoptPtr(static_cast<WebThread::Task*>(data));
- task->run();
+ MicrotaskQueue& queue = microtaskQueue();
+ while(!queue.isEmpty()) {
+ MicrotaskQueue local;
+ swap(queue, local);
+ for (const auto& task : local)
+ task->run();
+ }
}
+// static void microtaskFunctionCallback(void* data)
+// {
+// OwnPtr<WebThread::Task> task = adoptPtr(static_cast<WebThread::Task*>(data));
+// task->run();
+// }
+
void Microtask::enqueueMicrotask(PassOwnPtr<WebThread::Task> callback)
{
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- isolate->EnqueueMicrotask(&microtaskFunctionCallback, callback.leakPtr());
+ microtaskQueue().append(callback);
}
void Microtask::enqueueMicrotask(const base::Closure& callback)
« no previous file with comments | « sky/engine/core/dom/ExecutionContext.cpp ('k') | sky/engine/core/dom/MutationObserver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698