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

Unified Diff: Source/core/workers/WorkerGlobalScope.cpp

Issue 491053004: Expose Web Animations API to Web Workers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Exposing the Web Animations API to Web Workers Created 6 years, 4 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: Source/core/workers/WorkerGlobalScope.cpp
diff --git a/Source/core/workers/WorkerGlobalScope.cpp b/Source/core/workers/WorkerGlobalScope.cpp
index 62529dfb043ba36301adffc8ef54fa7e93ef0fda..da890afc213186bf865db94d931b72075c35e083 100644
--- a/Source/core/workers/WorkerGlobalScope.cpp
+++ b/Source/core/workers/WorkerGlobalScope.cpp
@@ -35,6 +35,7 @@
#include "core/dom/ActiveDOMObject.h"
#include "core/dom/AddConsoleMessageTask.h"
#include "core/dom/ContextLifecycleNotifier.h"
+#include "core/dom/CrossThreadTask.h"
#include "core/dom/DOMURL.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/MessagePort.h"
@@ -99,6 +100,29 @@ WorkerGlobalScope::~WorkerGlobalScope()
{
}
+void WorkerGlobalScope::requestAnimationFrame(PassOwnPtr<RequestAnimationFrameCallback> insert)
+{
+ if (!rAFPendingList) {
+ rAFPendingList = adoptPtr(new Vector<OwnPtr<RequestAnimationFrameCallback> >());
+ }
+ rAFPendingList->append(insert);
+}
+
+void WorkerGlobalScope::processRAF(double monotonicAnimationStartTime)
+{
+ postTask(createCrossThreadTask(&WorkerGlobalScope::processRAFOnWorkerThread, this, monotonicAnimationStartTime));
+}
+
+void WorkerGlobalScope::processRAFOnWorkerThread(double monotonicAnimationStartTime)
+{
+ if (!rAFPendingList)
+ return;
+ OwnPtr<Vector<OwnPtr<RequestAnimationFrameCallback> > > oldRAFList = rAFPendingList.release();
+ for (unsigned i = 0; i < oldRAFList->size(); i++) {
+ oldRAFList->at(i)->handleEvent(monotonicAnimationStartTime);
+ }
+}
+
void WorkerGlobalScope::applyContentSecurityPolicyFromString(const String& policy, ContentSecurityPolicyHeaderType contentSecurityPolicyType)
{
setContentSecurityPolicy(ContentSecurityPolicy::create(this));

Powered by Google App Engine
This is Rietveld 408576698