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

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

Issue 10154006: 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/ensureCallback.js
diff --git a/chrome/test/data/third_party/spaceport/js/util/ensureCallback.js b/chrome/test/data/third_party/spaceport/js/util/ensureCallback.js
new file mode 100644
index 0000000000000000000000000000000000000000..a55a9e7e7958c884f6c93daa846b7ae4896c7b3d
--- /dev/null
+++ b/chrome/test/data/third_party/spaceport/js/util/ensureCallback.js
@@ -0,0 +1,27 @@
+define([ ], function () {
+ return function ensureCallback(callback) {
+ if (typeof callback !== 'function') {
+ return function (err) {
+ if (err) {
+ console.error(err);
+ }
+ };
+ }
+
+ var called = false;
+ return function () {
+ if (called) {
+ // Disallow calling multiple times
+ return;
+ }
+
+ called = true;
+ var args = arguments;
+
+ setTimeout(function () {
+ // Ensure async
+ callback.apply(null, args);
+ }, 0);
+ };
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698