| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Namespace for utility functions. | 6 * Namespace for utility functions. |
| 7 */ | 7 */ |
| 8 var util = {}; | 8 var util = {}; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 /** | 268 /** |
| 269 * Obtains the element that should exist, decorates it with given type, and | 269 * Obtains the element that should exist, decorates it with given type, and |
| 270 * returns it. | 270 * returns it. |
| 271 * @param {string} query Query for the element. | 271 * @param {string} query Query for the element. |
| 272 * @param {function(new: T, ...)} type Type used to decorate. | 272 * @param {function(new: T, ...)} type Type used to decorate. |
| 273 * @private | 273 * @private |
| 274 * @template T | 274 * @template T |
| 275 * @return {!T} Decorated element. | 275 * @return {!T} Decorated element. |
| 276 */ | 276 */ |
| 277 util.queryDecoratedElement = function(query, type) { | 277 util.queryDecoratedElement = function(query, type) { |
| 278 var element = queryRequiredElement(document, query); | 278 var element = queryRequiredElement(query); |
| 279 cr.ui.decorate(element, type); | 279 cr.ui.decorate(element, type); |
| 280 return element; | 280 return element; |
| 281 }; | 281 }; |
| 282 | 282 |
| 283 /** | 283 /** |
| 284 * Updates the app state. | 284 * Updates the app state. |
| 285 * | 285 * |
| 286 * @param {?string} currentDirectoryURL Currently opened directory as an URL. | 286 * @param {?string} currentDirectoryURL Currently opened directory as an URL. |
| 287 * If null the value is left unchanged. | 287 * If null the value is left unchanged. |
| 288 * @param {?string} selectionURL Currently selected entry as an URL. If null the | 288 * @param {?string} selectionURL Currently selected entry as an URL. If null the |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 * @return {!Promise} A promise which can be rejected by timeout. | 1069 * @return {!Promise} A promise which can be rejected by timeout. |
| 1070 */ | 1070 */ |
| 1071 util.timeoutPromise = function(promise, ms, opt_message) { | 1071 util.timeoutPromise = function(promise, ms, opt_message) { |
| 1072 return Promise.race([ | 1072 return Promise.race([ |
| 1073 promise, | 1073 promise, |
| 1074 util.delay(ms).then(function() { | 1074 util.delay(ms).then(function() { |
| 1075 throw new Error(opt_message || 'Operation timed out.'); | 1075 throw new Error(opt_message || 'Operation timed out.'); |
| 1076 }) | 1076 }) |
| 1077 ]); | 1077 ]); |
| 1078 }; | 1078 }; |
| OLD | NEW |