| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.Object} | 33 * @extends {WebInspector.Object} |
| 34 */ | 34 */ |
| 35 WebInspector.IsolatedFileSystemManager = function() | 35 WebInspector.IsolatedFileSystemManager = function() |
| 36 { | 36 { |
| 37 /** @type {!Object.<string, !WebInspector.IsolatedFileSystem>} */ | 37 /** @type {!Object.<string, !WebInspector.IsolatedFileSystem>} */ |
| 38 this._fileSystems = {}; | 38 this._fileSystems = {}; |
| 39 /** @type {!Object.<string, !Array.<function(?DOMFileSystem)>>} */ | |
| 40 this._pendingFileSystemRequests = {}; | |
| 41 this._excludedFolderManager = new WebInspector.ExcludedFolderManager(); | 39 this._excludedFolderManager = new WebInspector.ExcludedFolderManager(); |
| 42 | 40 |
| 43 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.FileSystemsLoaded, this._onFileSystemsLoaded, this); | 41 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.FileSystemsLoaded, this._onFileSystemsLoaded, this); |
| 44 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.FileSystemRemoved, this._onFileSystemRemoved, this); | 42 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.FileSystemRemoved, this._onFileSystemRemoved, this); |
| 45 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.FileSystemAdded, this._onFileSystemAdded, this); | 43 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.FileSystemAdded, this._onFileSystemAdded, this); |
| 46 } | 44 } |
| 47 | 45 |
| 48 /** @typedef {!{fileSystemName: string, rootURL: string, fileSystemPath: string}
} */ | 46 /** @typedef {!{fileSystemName: string, rootURL: string, fileSystemPath: string}
} */ |
| 49 WebInspector.IsolatedFileSystemManager.FileSystem; | 47 WebInspector.IsolatedFileSystemManager.FileSystem; |
| 50 | 48 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 var addedFileSystemPaths = {}; | 92 var addedFileSystemPaths = {}; |
| 95 for (var i = 0; i < fileSystems.length; ++i) { | 93 for (var i = 0; i < fileSystems.length; ++i) { |
| 96 this._innerAddFileSystem(fileSystems[i]); | 94 this._innerAddFileSystem(fileSystems[i]); |
| 97 addedFileSystemPaths[fileSystems[i].fileSystemPath] = true; | 95 addedFileSystemPaths[fileSystems[i].fileSystemPath] = true; |
| 98 } | 96 } |
| 99 | 97 |
| 100 this._loaded = true; | 98 this._loaded = true; |
| 101 | 99 |
| 102 this._initializeCallback(); | 100 this._initializeCallback(); |
| 103 delete this._initializeCallback; | 101 delete this._initializeCallback; |
| 104 this._processPendingFileSystemRequests(); | |
| 105 }, | 102 }, |
| 106 | 103 |
| 107 /** | 104 /** |
| 108 * @param {!WebInspector.IsolatedFileSystemManager.FileSystem} fileSystem | 105 * @param {!WebInspector.IsolatedFileSystemManager.FileSystem} fileSystem |
| 109 */ | 106 */ |
| 110 _innerAddFileSystem: function(fileSystem) | 107 _innerAddFileSystem: function(fileSystem) |
| 111 { | 108 { |
| 112 var fileSystemPath = fileSystem.fileSystemPath; | 109 var fileSystemPath = fileSystem.fileSystemPath; |
| 113 var isolatedFileSystem = new WebInspector.IsolatedFileSystem(this, fileS
ystemPath, fileSystem.fileSystemName, fileSystem.rootURL); | 110 var isolatedFileSystem = new WebInspector.IsolatedFileSystem(this, fileS
ystemPath, fileSystem.fileSystemName, fileSystem.rootURL); |
| 114 this._fileSystems[fileSystemPath] = isolatedFileSystem; | 111 this._fileSystems[fileSystemPath] = isolatedFileSystem; |
| 115 this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager.Eve
nts.FileSystemAdded, isolatedFileSystem); | 112 this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager.Eve
nts.FileSystemAdded, isolatedFileSystem); |
| 116 }, | 113 }, |
| 117 | 114 |
| 118 _processPendingFileSystemRequests: function() | |
| 119 { | |
| 120 for (var fileSystemPath in this._pendingFileSystemRequests) { | |
| 121 var callbacks = this._pendingFileSystemRequests[fileSystemPath]; | |
| 122 for (var i = 0; i < callbacks.length; ++i) | |
| 123 callbacks[i](this._isolatedFileSystem(fileSystemPath)); | |
| 124 } | |
| 125 delete this._pendingFileSystemRequests; | |
| 126 }, | |
| 127 | |
| 128 /** | 115 /** |
| 129 * @param {!WebInspector.Event} event | 116 * @param {!WebInspector.Event} event |
| 130 */ | 117 */ |
| 131 _onFileSystemAdded: function(event) | 118 _onFileSystemAdded: function(event) |
| 132 { | 119 { |
| 133 var errorMessage = /** @type {string} */ (event.data["errorMessage"]); | 120 var errorMessage = /** @type {string} */ (event.data["errorMessage"]); |
| 134 var fileSystem = /** @type {?WebInspector.IsolatedFileSystemManager.File
System} */ (event.data["fileSystem"]); | 121 var fileSystem = /** @type {?WebInspector.IsolatedFileSystemManager.File
System} */ (event.data["fileSystem"]); |
| 135 if (errorMessage) | 122 if (errorMessage) |
| 136 WebInspector.console.error(errorMessage); | 123 WebInspector.console.error(errorMessage); |
| 137 else if (fileSystem) | 124 else if (fileSystem) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 152 _fileSystemRemoved: function(fileSystemPath) | 139 _fileSystemRemoved: function(fileSystemPath) |
| 153 { | 140 { |
| 154 this._excludedFolderManager.removeFileSystem(fileSystemPath); | 141 this._excludedFolderManager.removeFileSystem(fileSystemPath); |
| 155 var isolatedFileSystem = this._fileSystems[fileSystemPath]; | 142 var isolatedFileSystem = this._fileSystems[fileSystemPath]; |
| 156 delete this._fileSystems[fileSystemPath]; | 143 delete this._fileSystems[fileSystemPath]; |
| 157 if (isolatedFileSystem) | 144 if (isolatedFileSystem) |
| 158 this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager
.Events.FileSystemRemoved, isolatedFileSystem); | 145 this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager
.Events.FileSystemRemoved, isolatedFileSystem); |
| 159 }, | 146 }, |
| 160 | 147 |
| 161 /** | 148 /** |
| 162 * @param {string} fileSystemPath | |
| 163 * @return {?DOMFileSystem} | |
| 164 */ | |
| 165 _isolatedFileSystem: function(fileSystemPath) | |
| 166 { | |
| 167 var fileSystem = this._fileSystems[fileSystemPath]; | |
| 168 if (!fileSystem) | |
| 169 return null; | |
| 170 if (!InspectorFrontendHost.isolatedFileSystem) | |
| 171 return null; | |
| 172 return InspectorFrontendHost.isolatedFileSystem(fileSystem.name(), fileS
ystem.rootURL()); | |
| 173 }, | |
| 174 | |
| 175 /** | |
| 176 * @param {string} fileSystemPath | |
| 177 * @param {function(?DOMFileSystem)} callback | |
| 178 */ | |
| 179 requestDOMFileSystem: function(fileSystemPath, callback) | |
| 180 { | |
| 181 if (!this._loaded) { | |
| 182 if (!this._pendingFileSystemRequests[fileSystemPath]) | |
| 183 this._pendingFileSystemRequests[fileSystemPath] = this._pendingF
ileSystemRequests[fileSystemPath] || []; | |
| 184 this._pendingFileSystemRequests[fileSystemPath].push(callback); | |
| 185 return; | |
| 186 } | |
| 187 callback(this._isolatedFileSystem(fileSystemPath)); | |
| 188 }, | |
| 189 | |
| 190 /** | |
| 191 * @return {!Array<string>} | 149 * @return {!Array<string>} |
| 192 */ | 150 */ |
| 193 fileSystemPaths: function() | 151 fileSystemPaths: function() |
| 194 { | 152 { |
| 195 return Object.keys(this._fileSystems); | 153 return Object.keys(this._fileSystems); |
| 196 }, | 154 }, |
| 197 | 155 |
| 198 __proto__: WebInspector.Object.prototype | 156 __proto__: WebInspector.Object.prototype |
| 199 } | 157 } |
| 200 | 158 |
| 201 /** | 159 /** |
| 202 * @type {!WebInspector.IsolatedFileSystemManager} | 160 * @type {!WebInspector.IsolatedFileSystemManager} |
| 203 */ | 161 */ |
| 204 WebInspector.isolatedFileSystemManager; | 162 WebInspector.isolatedFileSystemManager; |
| OLD | NEW |