Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1031)

Unified Diff: third_party/WebKit/Source/devtools/front_end/workspace/FileSystemMapping.js

Issue 2506463002: DevTools: remove Bindings.NetworkMapping.addMapping/removeMapping methods (Closed)
Patch Set: rebaseline Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sources/SourcesPanel.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/workspace/FileSystemMapping.js
diff --git a/third_party/WebKit/Source/devtools/front_end/workspace/FileSystemMapping.js b/third_party/WebKit/Source/devtools/front_end/workspace/FileSystemMapping.js
index bdfcb03181e8643ccb8948cae1bea7677117ecaa..e2224779f4c573445f176d7a8f1c48ca571d5b48 100644
--- a/third_party/WebKit/Source/devtools/front_end/workspace/FileSystemMapping.js
+++ b/third_party/WebKit/Source/devtools/front_end/workspace/FileSystemMapping.js
@@ -32,12 +32,66 @@
* @unrestricted
*/
Workspace.FileSystemMapping = class extends Common.Object {
- constructor() {
+ /**
+ * @param {!Workspace.IsolatedFileSystemManager} fileSystemManager
+ */
+ constructor(fileSystemManager) {
super();
this._fileSystemMappingSetting = Common.settings.createLocalSetting('fileSystemMapping', {});
/** @type {!Object.<string, !Array.<!Workspace.FileSystemMapping.Entry>>} */
this._fileSystemMappings = {};
this._loadFromSettings();
+
+ this._eventListeners = [
+ fileSystemManager.addEventListener(
+ Workspace.IsolatedFileSystemManager.Events.FileSystemAdded, this._fileSystemAdded, this),
+ fileSystemManager.addEventListener(
+ Workspace.IsolatedFileSystemManager.Events.FileSystemRemoved, this._fileSystemRemoved, this),
+ ];
+ fileSystemManager.waitForFileSystems().then(this._fileSystemsLoaded.bind(this));
+ }
+
+ /**
+ * @param {!Array<!Workspace.IsolatedFileSystem>} fileSystems
+ */
+ _fileSystemsLoaded(fileSystems) {
+ for (var fileSystem of fileSystems)
+ this._addMappingsForFilesystem(fileSystem);
+ }
+
+ /**
+ * @param {!Common.Event} event
+ */
+ _fileSystemAdded(event) {
+ var fileSystem = /** @type {!Workspace.IsolatedFileSystem} */ (event.data);
+ this._addMappingsForFilesystem(fileSystem);
+ }
+
+ /**
+ * @param {!Workspace.IsolatedFileSystem} fileSystem
+ */
+ _addMappingsForFilesystem(fileSystem) {
+ this.addFileSystem(fileSystem.path());
+
+ var mappings = fileSystem.projectProperty('mappings');
+ for (var i = 0; Array.isArray(mappings) && i < mappings.length; ++i) {
+ var mapping = mappings[i];
+ if (!mapping || typeof mapping !== 'object')
+ continue;
+ var folder = mapping['folder'];
+ var url = mapping['url'];
+ if (typeof folder !== 'string' || typeof url !== 'string')
+ continue;
+ this.addNonConfigurableFileMapping(fileSystem.path(), url, folder);
+ }
+ }
+
+ /**
+ * @param {!Common.Event} event
+ */
+ _fileSystemRemoved(event) {
+ var fileSystem = /** @type {!Workspace.IsolatedFileSystem} */ (event.data);
+ this.removeFileSystem(fileSystem.path());
}
_loadFromSettings() {
@@ -300,6 +354,10 @@ Workspace.FileSystemMapping = class extends Common.Object {
resetForTesting() {
this._fileSystemMappings = {};
}
+
+ dispose() {
+ Common.EventTarget.removeEventListeners(this._eventListeners);
+ }
};
/** @enum {symbol} */
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sources/SourcesPanel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698