Chromium Code Reviews| Index: chrome/renderer/resources/extensions/file_system_custom_bindings.js |
| diff --git a/chrome/renderer/resources/extensions/file_system_custom_bindings.js b/chrome/renderer/resources/extensions/file_system_custom_bindings.js |
| index f66c20d45e868a99a511c1030490a8056fa1eff2..62dc3b40574afabb7802739cc9a7123d09eaa935 100644 |
| --- a/chrome/renderer/resources/extensions/file_system_custom_bindings.js |
| +++ b/chrome/renderer/resources/extensions/file_system_custom_bindings.js |
| @@ -30,30 +30,50 @@ if (window == backgroundPage) { |
| var callback = request.callback; |
| request.callback = null; |
| - var fileSystemId = response.fileSystemId; |
| - var baseName = response.baseName; |
| - var id = response.id; |
| - var fs = GetIsolatedFileSystem(fileSystemId); |
| - |
| - try { |
| - // TODO(koz): fs.root.getFile() makes a trip to the browser process, |
| - // but it might be possible avoid that by calling |
| - // WebFrame::createFileEntry(). |
| - fs.root.getFile(baseName, {}, function(fileEntry) { |
| - entryIdManager.registerEntry(id, fileEntry); |
| - callback(fileEntry); |
| - }, function(fileError) { |
| - lastError.run('fileSystem.' + functionName, |
| - 'Error getting fileEntry, code: ' + fileError.code, |
| - request.stack, |
| - callback); |
| - }); |
| - } catch (e) { |
| - lastError.run('fileSystem.' + functionName, |
| - 'Error in event handler for onLaunched: ' + e.stack, |
| - request.stack, |
| - callback); |
| - } |
| + var entries = []; |
| + var hasError = false; |
| + |
| + $Array.forEach(response.entries, function(entry) { |
| + var fileSystemId = entry.fileSystemId; |
| + var baseName = entry.baseName; |
| + var id = entry.id; |
| + var fs = GetIsolatedFileSystem(fileSystemId); |
|
benwells
2013/08/01 07:48:33
Should you check hasError here instead of in the e
Sam McNally
2013/08/02 05:35:31
Added a comment describing what's going on here.
|
| + |
| + try { |
| + // TODO(koz): fs.root.getFile() makes a trip to the browser process, |
| + // but it might be possible avoid that by calling |
| + // WebFrame::createFileEntry(). |
| + fs.root.getFile(baseName, {}, function(fileEntry) { |
| + entryIdManager.registerEntry(id, fileEntry); |
| + entries.push(fileEntry); |
| + // Once all entries are ready, pass them to the callback. |
| + if (entries.length == response.entries.length) { |
| + if (response.multiple) { |
| + callback(entries); |
| + } else { |
| + callback(entries[0]); |
| + } |
| + } |
| + }, function(fileError) { |
| + if (!hasError) { |
| + hasError = true; |
| + lastError.run( |
| + 'fileSystem.' + functionName, |
| + 'Error getting fileEntry, code: ' + fileError.code, |
| + request.stack, |
| + callback); |
| + } |
| + }); |
| + } catch (e) { |
| + if (!hasError) { |
| + hasError = true; |
| + lastError.run('fileSystem.' + functionName, |
| + 'Error getting fileEntry: ' + e.stack, |
| + request.stack, |
| + callback); |
| + } |
| + } |
| + }); |
| } |
| }); |
| }; |