| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 /** | 102 /** |
| 103 * @param {function(?DOMFileSystem)} callback | 103 * @param {function(?DOMFileSystem)} callback |
| 104 */ | 104 */ |
| 105 _requestFileSystem: function(callback) | 105 _requestFileSystem: function(callback) |
| 106 { | 106 { |
| 107 this._manager.requestDOMFileSystem(this._path, callback); | 107 this._manager.requestDOMFileSystem(this._path, callback); |
| 108 }, | 108 }, |
| 109 | 109 |
| 110 /** | 110 /** |
| 111 * @param {string} path | 111 * @param {string} path |
| 112 * @param {function(string)} callback | 112 * @param {function(string)} fileCallback |
| 113 * @param {function()=} finishedCallback |
| 113 */ | 114 */ |
| 114 requestFilesRecursive: function(path, callback) | 115 requestFilesRecursive: function(path, fileCallback, finishedCallback) |
| 115 { | 116 { |
| 116 this._requestFileSystem(fileSystemLoaded.bind(this)); | 117 this._requestFileSystem(fileSystemLoaded.bind(this)); |
| 117 | 118 |
| 118 var domFileSystem; | 119 var domFileSystem; |
| 120 var pendingRequests = 0; |
| 119 /** | 121 /** |
| 120 * @param {?DOMFileSystem} fs | 122 * @param {?DOMFileSystem} fs |
| 121 * @this {WebInspector.IsolatedFileSystem} | 123 * @this {WebInspector.IsolatedFileSystem} |
| 122 */ | 124 */ |
| 123 function fileSystemLoaded(fs) | 125 function fileSystemLoaded(fs) |
| 124 { | 126 { |
| 125 domFileSystem = /** @type {!DOMFileSystem} */ (fs); | 127 domFileSystem = /** @type {!DOMFileSystem} */ (fs); |
| 126 console.assert(domFileSystem); | 128 console.assert(domFileSystem); |
| 129 ++pendingRequests; |
| 127 this._requestEntries(domFileSystem, path, innerCallback.bind(this)); | 130 this._requestEntries(domFileSystem, path, innerCallback.bind(this)); |
| 128 } | 131 } |
| 129 | 132 |
| 130 /** | 133 /** |
| 131 * @param {!Array.<!FileEntry>} entries | 134 * @param {!Array.<!FileEntry>} entries |
| 132 * @this {WebInspector.IsolatedFileSystem} | 135 * @this {WebInspector.IsolatedFileSystem} |
| 133 */ | 136 */ |
| 134 function innerCallback(entries) | 137 function innerCallback(entries) |
| 135 { | 138 { |
| 136 for (var i = 0; i < entries.length; ++i) { | 139 for (var i = 0; i < entries.length; ++i) { |
| 137 var entry = entries[i]; | 140 var entry = entries[i]; |
| 138 if (!entry.isDirectory) { | 141 if (!entry.isDirectory) { |
| 139 if (this._manager.mapping().isFileExcluded(this._path, entry
.fullPath)) | 142 if (this._manager.mapping().isFileExcluded(this._path, entry
.fullPath)) |
| 140 continue; | 143 continue; |
| 141 callback(entry.fullPath.substr(1)); | 144 fileCallback(entry.fullPath.substr(1)); |
| 142 } | 145 } |
| 143 else { | 146 else { |
| 144 if (this._manager.mapping().isFileExcluded(this._path, entry
.fullPath + "/")) | 147 if (this._manager.mapping().isFileExcluded(this._path, entry
.fullPath + "/")) |
| 145 continue; | 148 continue; |
| 149 ++pendingRequests; |
| 146 this._requestEntries(domFileSystem, entry.fullPath, innerCal
lback.bind(this)); | 150 this._requestEntries(domFileSystem, entry.fullPath, innerCal
lback.bind(this)); |
| 147 } | 151 } |
| 148 } | 152 } |
| 153 if (finishedCallback && (--pendingRequests === 0)) |
| 154 finishedCallback(); |
| 149 } | 155 } |
| 150 }, | 156 }, |
| 151 | 157 |
| 152 /** | 158 /** |
| 153 * @param {string} path | 159 * @param {string} path |
| 154 * @param {?string} name | 160 * @param {?string} name |
| 155 * @param {function(?string)} callback | 161 * @param {function(?string)} callback |
| 156 */ | 162 */ |
| 157 createFile: function(path, name, callback) | 163 createFile: function(path, name, callback) |
| 158 { | 164 { |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 } | 581 } |
| 576 | 582 |
| 577 function errorHandler(error) | 583 function errorHandler(error) |
| 578 { | 584 { |
| 579 var errorMessage = WebInspector.IsolatedFileSystem.errorMessage(erro
r); | 585 var errorMessage = WebInspector.IsolatedFileSystem.errorMessage(erro
r); |
| 580 console.error(errorMessage + " when requesting entry '" + path + "'"
); | 586 console.error(errorMessage + " when requesting entry '" + path + "'"
); |
| 581 callback([]); | 587 callback([]); |
| 582 } | 588 } |
| 583 } | 589 } |
| 584 } | 590 } |
| OLD | NEW |