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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Namespace for utility functions. | 8 * Namespace for utility functions. |
9 */ | 9 */ |
10 var util = {}; | 10 var util = {}; |
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1142 return entries.map(function(entry) { | 1142 return entries.map(function(entry) { |
1143 return entry.toURL(); | 1143 return entry.toURL(); |
1144 }); | 1144 }); |
1145 }; | 1145 }; |
1146 | 1146 |
1147 /** | 1147 /** |
1148 * Converts array of URLs to an array of corresponding Entries. | 1148 * Converts array of URLs to an array of corresponding Entries. |
1149 * | 1149 * |
1150 * @param {Array.<string>} urls Input array of URLs. | 1150 * @param {Array.<string>} urls Input array of URLs. |
1151 * @param {function(Array.<Entry>)} callback Completion callback with array of | 1151 * @param {function(Array.<Entry>)} callback Completion callback with array of |
1152 * Entries. | 1152 * Entries. |
yoshiki
2014/02/14 10:24:11
Please mention that the both errorCallback and cal
hirono
2014/02/14 10:42:37
Let me combine the callbacks!
| |
1153 * @param {function(Array.<Entry>)} opt_errorCallback Error callback with array | |
1154 * of URLs failed to be resolved. | |
1153 */ | 1155 */ |
1154 util.URLsToEntries = function(urls, callback) { | 1156 util.URLsToEntries = function(urls, callback, opt_errorCallback) { |
1155 var result = []; | 1157 var result = []; |
1158 var failureUrl = []; | |
1156 AsyncUtil.forEach( | 1159 AsyncUtil.forEach( |
1157 urls, | 1160 urls, |
1158 function(forEachCallback, url) { | 1161 function(forEachCallback, url) { |
1159 webkitResolveLocalFileSystemURL(url, function(entry) { | 1162 webkitResolveLocalFileSystemURL(url, function(entry) { |
1160 result.push(entry); | 1163 result.push(entry); |
1161 forEachCallback(); | 1164 forEachCallback(); |
1162 }, function() { | 1165 }, function() { |
1163 // Not an error. Possibly, the file is not accessible anymore. | 1166 // Not an error. Possibly, the file is not accessible anymore. |
1164 console.warn('Failed to resolve the file with url: ' + url + '.'); | 1167 console.warn('Failed to resolve the file with url: ' + url + '.'); |
1168 failureUrl.push(url); | |
1165 forEachCallback(); | 1169 forEachCallback(); |
1166 }); | 1170 }); |
1167 }, | 1171 }, |
1168 function() { | 1172 function() { |
1169 callback(result); | 1173 callback(result); |
1174 if (opt_errorCallback) | |
1175 opt_errorCallback(failureUrl); | |
1170 }); | 1176 }); |
1171 }; | 1177 }; |
1172 | 1178 |
1173 /** | 1179 /** |
1174 * Returns whether the window is teleported or not. | 1180 * Returns whether the window is teleported or not. |
1175 * @param {DOMWindow} window Window. | 1181 * @param {DOMWindow} window Window. |
1176 * @return {Promise.<boolean>} Whether the window is teleported or not. | 1182 * @return {Promise.<boolean>} Whether the window is teleported or not. |
1177 */ | 1183 */ |
1178 util.isTeleported = function(window) { | 1184 util.isTeleported = function(window) { |
1179 return new Promise(function(onFulfilled) { | 1185 return new Promise(function(onFulfilled) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1240 * @enum {string} | 1246 * @enum {string} |
1241 * @const | 1247 * @const |
1242 */ | 1248 */ |
1243 util.VolumeType = Object.freeze({ | 1249 util.VolumeType = Object.freeze({ |
1244 DRIVE: 'drive', | 1250 DRIVE: 'drive', |
1245 DOWNLOADS: 'downloads', | 1251 DOWNLOADS: 'downloads', |
1246 REMOVABLE: 'removable', | 1252 REMOVABLE: 'removable', |
1247 ARCHIVE: 'archive', | 1253 ARCHIVE: 'archive', |
1248 CLOUD_DEVICE: 'cloud_device' | 1254 CLOUD_DEVICE: 'cloud_device' |
1249 }); | 1255 }); |
OLD | NEW |