OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 11 matching lines...) Expand all Loading... |
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 var checkout = checkout || {}; | 26 var checkout = checkout || {}; |
27 | 27 |
28 (function() { | 28 (function() { |
29 | 29 |
30 var g_haveSeenCheckoutAvailable = false; | 30 var g_haveSeenCheckoutAvailable = false; |
31 | 31 |
32 function callIfCheckoutAvailable(callback, checkoutUnavailable) | 32 function checkoutAvailable() |
33 { | 33 { |
34 if (g_haveSeenCheckoutAvailable) { | 34 if (g_haveSeenCheckoutAvailable) { |
35 callback(); | 35 return Promise.resolve(); |
36 return; | |
37 } | 36 } |
38 checkout.isAvailable(function(isAvailable) { | 37 |
| 38 return checkout.isAvailable().then(function(isAvailable) { |
39 if (isAvailable) { | 39 if (isAvailable) { |
40 g_haveSeenCheckoutAvailable = true; | 40 g_haveSeenCheckoutAvailable = true; |
41 callback(); | |
42 return; | 41 return; |
43 } | 42 } |
44 if (checkoutUnavailable) | |
45 checkoutUnavailable(); | |
46 }); | 43 }); |
47 } | 44 }; |
48 | 45 |
49 checkout.isAvailable = function(callback) | 46 checkout.isAvailable = function() |
50 { | 47 { |
51 net.ajax({ | 48 return net.ajax({ |
52 url: '/ping', | 49 url: '/ping', |
53 }).then(function() { return true; }, | 50 }).then(function() { return true; }, |
54 function() { return false; }) | 51 function() { return false; }); |
55 .then(callback); | |
56 }; | 52 }; |
57 | 53 |
58 checkout.lastBlinkRollRevision = function(callback, checkoutUnavailable) | 54 checkout.lastBlinkRollRevision = function() |
59 { | 55 { |
60 callIfCheckoutAvailable(function() { | 56 return checkoutAvailable().then(function() { |
61 net.get('/lastroll').then(callback); | 57 return net.get('/lastroll'); |
62 }, checkoutUnavailable); | 58 }); |
63 } | 59 }; |
64 | 60 |
65 checkout.rollout = function(revision, reason, callback, checkoutUnavailable) | 61 checkout.rollout = function(revision, reason) |
66 { | 62 { |
67 callIfCheckoutAvailable(function() { | 63 return checkoutAvailable().then(function() { |
68 net.post('/rollout?' + $.param({ | 64 return net.post('/rollout?' + $.param({ |
69 'revision': revision, | 65 'revision': revision, |
70 'reason': reason | 66 'reason': reason |
71 })).then(callback); | 67 })); |
72 }, checkoutUnavailable); | 68 }); |
73 }; | 69 }; |
74 | 70 |
75 checkout.rebaseline = function(failureInfoList, callback, progressCallback, chec
koutUnavailable, debugBotsCallback) | 71 checkout.rebaseline = function(failureInfoList, progressCallback, debugBotsCallb
ack) |
76 { | 72 { |
77 callIfCheckoutAvailable(function() { | 73 return checkoutAvailable().then(function() { |
78 var tests = {}; | 74 var tests = {}; |
79 for (var i = 0; i < failureInfoList.length; i++) { | 75 for (var i = 0; i < failureInfoList.length; i++) { |
80 var failureInfo = failureInfoList[i]; | 76 var failureInfo = failureInfoList[i]; |
81 if (failureInfo.builderName.indexOf('dbg') != -1) { | 77 if (failureInfo.builderName.indexOf('dbg') != -1) { |
82 debugBotsCallback(failureInfo); | 78 debugBotsCallback(failureInfo); |
83 continue; | 79 continue; |
84 } | 80 } |
85 tests[failureInfo.testName] = tests[failureInfo.testName] || {}; | 81 tests[failureInfo.testName] = tests[failureInfo.testName] || {}; |
86 tests[failureInfo.testName][failureInfo.builderName] = | 82 tests[failureInfo.testName][failureInfo.builderName] = |
87 base.uniquifyArray(base.flattenArray(failureInfo.failureTypeList
.map(results.failureTypeToExtensionList))); | 83 base.uniquifyArray(base.flattenArray(failureInfo.failureTypeList
.map(results.failureTypeToExtensionList))); |
88 } | 84 } |
89 net.post('/rebaselineall', JSON.stringify(tests)).then(callback); | 85 return net.post('/rebaselineall', JSON.stringify(tests)); |
90 }, checkoutUnavailable); | 86 }); |
91 }; | 87 }; |
92 | 88 |
93 })(); | 89 })(); |
OLD | NEW |