| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 Persistence.FileSystemMapping = class extends Common.Object { | 34 Persistence.FileSystemMapping = class extends Common.Object { |
| 35 /** | 35 /** |
| 36 * @param {!Workspace.IsolatedFileSystemManager} fileSystemManager | 36 * @param {!Persistence.IsolatedFileSystemManager} fileSystemManager |
| 37 */ | 37 */ |
| 38 constructor(fileSystemManager) { | 38 constructor(fileSystemManager) { |
| 39 super(); | 39 super(); |
| 40 this._fileSystemMappingSetting = Common.settings.createLocalSetting('fileSys
temMapping', {}); | 40 this._fileSystemMappingSetting = Common.settings.createLocalSetting('fileSys
temMapping', {}); |
| 41 /** @type {!Object.<string, !Array.<!Persistence.FileSystemMapping.Entry>>}
*/ | 41 /** @type {!Object.<string, !Array.<!Persistence.FileSystemMapping.Entry>>}
*/ |
| 42 this._fileSystemMappings = {}; | 42 this._fileSystemMappings = {}; |
| 43 this._loadFromSettings(); | 43 this._loadFromSettings(); |
| 44 | 44 |
| 45 this._eventListeners = [ | 45 this._eventListeners = [ |
| 46 fileSystemManager.addEventListener( | 46 fileSystemManager.addEventListener( |
| 47 Workspace.IsolatedFileSystemManager.Events.FileSystemAdded, this._file
SystemAdded, this), | 47 Persistence.IsolatedFileSystemManager.Events.FileSystemAdded, this._fi
leSystemAdded, this), |
| 48 fileSystemManager.addEventListener( | 48 fileSystemManager.addEventListener( |
| 49 Workspace.IsolatedFileSystemManager.Events.FileSystemRemoved, this._fi
leSystemRemoved, this), | 49 Persistence.IsolatedFileSystemManager.Events.FileSystemRemoved, this._
fileSystemRemoved, this), |
| 50 ]; | 50 ]; |
| 51 fileSystemManager.waitForFileSystems().then(this._fileSystemsLoaded.bind(thi
s)); | 51 fileSystemManager.waitForFileSystems().then(this._fileSystemsLoaded.bind(thi
s)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * @param {!Array<!Workspace.IsolatedFileSystem>} fileSystems | 55 * @param {!Array<!Persistence.IsolatedFileSystem>} fileSystems |
| 56 */ | 56 */ |
| 57 _fileSystemsLoaded(fileSystems) { | 57 _fileSystemsLoaded(fileSystems) { |
| 58 for (var fileSystem of fileSystems) | 58 for (var fileSystem of fileSystems) |
| 59 this.addFileSystem(fileSystem.path()); | 59 this.addFileSystem(fileSystem.path()); |
| 60 } | 60 } |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * @param {!Common.Event} event | 63 * @param {!Common.Event} event |
| 64 */ | 64 */ |
| 65 _fileSystemAdded(event) { | 65 _fileSystemAdded(event) { |
| 66 var fileSystem = /** @type {!Workspace.IsolatedFileSystem} */ (event.data); | 66 var fileSystem = /** @type {!Persistence.IsolatedFileSystem} */ (event.data)
; |
| 67 this.addFileSystem(fileSystem.path()); | 67 this.addFileSystem(fileSystem.path()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * @param {!Common.Event} event | 71 * @param {!Common.Event} event |
| 72 */ | 72 */ |
| 73 _fileSystemRemoved(event) { | 73 _fileSystemRemoved(event) { |
| 74 var fileSystem = /** @type {!Workspace.IsolatedFileSystem} */ (event.data); | 74 var fileSystem = /** @type {!Persistence.IsolatedFileSystem} */ (event.data)
; |
| 75 this.removeFileSystem(fileSystem.path()); | 75 this.removeFileSystem(fileSystem.path()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 _loadFromSettings() { | 78 _loadFromSettings() { |
| 79 var savedMapping = this._fileSystemMappingSetting.get(); | 79 var savedMapping = this._fileSystemMappingSetting.get(); |
| 80 this._fileSystemMappings = {}; | 80 this._fileSystemMappings = {}; |
| 81 for (var fileSystemPath in savedMapping) { | 81 for (var fileSystemPath in savedMapping) { |
| 82 var savedFileSystemMappings = savedMapping[fileSystemPath]; | 82 var savedFileSystemMappings = savedMapping[fileSystemPath]; |
| 83 fileSystemPath = Common.ParsedURL.platformPathToURL(fileSystemPath); | 83 fileSystemPath = Common.ParsedURL.platformPathToURL(fileSystemPath); |
| 84 this._fileSystemMappings[fileSystemPath] = []; | 84 this._fileSystemMappings[fileSystemPath] = []; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 this.fileSystemPath = fileSystemPath; | 343 this.fileSystemPath = fileSystemPath; |
| 344 this.urlPrefix = urlPrefix; | 344 this.urlPrefix = urlPrefix; |
| 345 this.pathPrefix = pathPrefix; | 345 this.pathPrefix = pathPrefix; |
| 346 } | 346 } |
| 347 }; | 347 }; |
| 348 | 348 |
| 349 /** | 349 /** |
| 350 * @type {!Persistence.FileSystemMapping} | 350 * @type {!Persistence.FileSystemMapping} |
| 351 */ | 351 */ |
| 352 Persistence.fileSystemMapping; | 352 Persistence.fileSystemMapping; |
| OLD | NEW |