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

Unified Diff: Tools/GardeningServer/scripts/checkout.js

Issue 173133003: Convert garden-o-matic guts over to promises where appropriate (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: update to ToT Created 6 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
Index: Tools/GardeningServer/scripts/checkout.js
diff --git a/Tools/GardeningServer/scripts/checkout.js b/Tools/GardeningServer/scripts/checkout.js
index 5891c23f6dfa391ee0d10218733acc1955290c57..0ccf28db85853e9a06b9d08714bd032c94cb1bdb 100644
--- a/Tools/GardeningServer/scripts/checkout.js
+++ b/Tools/GardeningServer/scripts/checkout.js
@@ -29,52 +29,48 @@ var checkout = checkout || {};
var g_haveSeenCheckoutAvailable = false;
-function callIfCheckoutAvailable(callback, checkoutUnavailable)
+function checkoutAvailable()
{
if (g_haveSeenCheckoutAvailable) {
- callback();
- return;
+ return Promise.resolve();
}
- checkout.isAvailable(function(isAvailable) {
+
+ return checkout.isAvailable().then(function(isAvailable) {
if (isAvailable) {
g_haveSeenCheckoutAvailable = true;
- callback();
return;
}
- if (checkoutUnavailable)
- checkoutUnavailable();
});
-}
+};
-checkout.isAvailable = function(callback)
+checkout.isAvailable = function()
{
- net.ajax({
+ return net.ajax({
url: '/ping',
}).then(function() { return true; },
- function() { return false; })
- .then(callback);
+ function() { return false; });
};
-checkout.lastBlinkRollRevision = function(callback, checkoutUnavailable)
+checkout.lastBlinkRollRevision = function()
{
- callIfCheckoutAvailable(function() {
- net.get('/lastroll').then(callback);
- }, checkoutUnavailable);
-}
+ return checkoutAvailable().then(function() {
+ return net.get('/lastroll');
+ });
+};
-checkout.rollout = function(revision, reason, callback, checkoutUnavailable)
+checkout.rollout = function(revision, reason)
{
- callIfCheckoutAvailable(function() {
- net.post('/rollout?' + $.param({
+ return checkoutAvailable().then(function() {
+ return net.post('/rollout?' + $.param({
'revision': revision,
'reason': reason
- })).then(callback);
- }, checkoutUnavailable);
+ }));
+ });
};
-checkout.rebaseline = function(failureInfoList, callback, progressCallback, checkoutUnavailable, debugBotsCallback)
+checkout.rebaseline = function(failureInfoList, progressCallback, debugBotsCallback)
{
- callIfCheckoutAvailable(function() {
+ return checkoutAvailable().then(function() {
var tests = {};
for (var i = 0; i < failureInfoList.length; i++) {
var failureInfo = failureInfoList[i];
@@ -86,8 +82,8 @@ checkout.rebaseline = function(failureInfoList, callback, progressCallback, chec
tests[failureInfo.testName][failureInfo.builderName] =
base.uniquifyArray(base.flattenArray(failureInfo.failureTypeList.map(results.failureTypeToExtensionList)));
}
- net.post('/rebaselineall', JSON.stringify(tests)).then(callback);
- }, checkoutUnavailable);
+ return net.post('/rebaselineall', JSON.stringify(tests));
+ });
};
})();
« no previous file with comments | « Tools/GardeningServer/scripts/builders_unittests.js ('k') | Tools/GardeningServer/scripts/checkout_unittests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698