| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * @fileoverview | 6 * @fileoverview |
| 7 * A module that contains basic utility components and methods for the | 7 * A module that contains basic utility components and methods for the |
| 8 * chromoting project | 8 * chromoting project |
| 9 * | 9 * |
| 10 */ | 10 */ |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 * @return {Array} | 105 * @return {Array} |
| 106 */ | 106 */ |
| 107 base.values = function(dict) { | 107 base.values = function(dict) { |
| 108 return Object.keys(dict).map( | 108 return Object.keys(dict).map( |
| 109 /** @param {string} key */ | 109 /** @param {string} key */ |
| 110 function(key) { | 110 function(key) { |
| 111 return dict[key]; | 111 return dict[key]; |
| 112 }); | 112 }); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 |
| 116 /** |
| 117 * Joins the |url| with optional query parameters defined in |opt_params| |
| 118 * See unit test for usage. |
| 119 * @param {string} url |
| 120 * @param {Object.<string>=} opt_params |
| 121 * @return {string} |
| 122 */ |
| 123 base.urlJoin = function(url, opt_params) { |
| 124 if (!opt_params) { |
| 125 return url; |
| 126 } |
| 127 var queryParameters = []; |
| 128 for (var key in opt_params) { |
| 129 queryParameters.push(encodeURIComponent(key) + "=" + |
| 130 encodeURIComponent(opt_params[key])); |
| 131 } |
| 132 return url + '?' + queryParameters.join('&'); |
| 133 }; |
| 134 |
| 115 base.Promise = function() {}; | 135 base.Promise = function() {}; |
| 116 | 136 |
| 117 /** | 137 /** |
| 118 * @param {number} delay | 138 * @param {number} delay |
| 119 * @return {Promise} a Promise that will be fulfilled after |delay| ms. | 139 * @return {Promise} a Promise that will be fulfilled after |delay| ms. |
| 120 */ | 140 */ |
| 121 base.Promise.sleep = function(delay) { | 141 base.Promise.sleep = function(delay) { |
| 122 return new Promise( | 142 return new Promise( |
| 123 /** @param {function():void} fulfill */ | 143 /** @param {function():void} fulfill */ |
| 124 function(fulfill) { | 144 function(fulfill) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 284 |
| 265 listeners.forEach( | 285 listeners.forEach( |
| 266 /** @param {function(*=):void} listener */ | 286 /** @param {function(*=):void} listener */ |
| 267 function(listener){ | 287 function(listener){ |
| 268 if (listener) { | 288 if (listener) { |
| 269 listener(opt_details); | 289 listener(opt_details); |
| 270 } | 290 } |
| 271 }); | 291 }); |
| 272 } | 292 } |
| 273 }; | 293 }; |
| OLD | NEW |