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

Unified Diff: chrome/test/data/third_party/spaceport/js/util/quickPromise.js

Issue 10134041: Add test data for spaceport benchmark. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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: chrome/test/data/third_party/spaceport/js/util/quickPromise.js
diff --git a/chrome/test/data/third_party/spaceport/js/util/quickPromise.js b/chrome/test/data/third_party/spaceport/js/util/quickPromise.js
new file mode 100644
index 0000000000000000000000000000000000000000..0872247dba183e6fab6e00e1bb746994e1466e24
--- /dev/null
+++ b/chrome/test/data/third_party/spaceport/js/util/quickPromise.js
@@ -0,0 +1,34 @@
+define([ 'util/ensureCallback' ], function (ensureCallback) {
+ function quickPromise() {
+ var thens = [ ];
+ var resolved = false;
+
+ function resolve() {
+ if (resolved) {
+ throw new Error("Already resolved");
+ }
+ resolved = true;
+
+ while (thens.length) {
+ var fn = thens.pop();
+ fn();
+ }
+ }
+
+ function then(fn) {
+ fn = ensureCallback(fn);
+ if (resolved) {
+ fn();
+ } else {
+ thens.push(fn);
+ }
+ }
+
+ return {
+ resolve: resolve,
+ then: then
+ };
+ }
+
+ return quickPromise;
+});

Powered by Google App Engine
This is Rietveld 408576698