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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/FileSystemWorkspaceBinding.js

Issue 2290323003: DevTools: use eventListener arrays to avoid memory leaks in dispose methods (Closed)
Patch Set: Created 4 years, 3 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/bindings/NetworkMapping.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 19 matching lines...) Expand all
30 30
31 /** 31 /**
32 * @constructor 32 * @constructor
33 * @param {!WebInspector.IsolatedFileSystemManager} isolatedFileSystemManager 33 * @param {!WebInspector.IsolatedFileSystemManager} isolatedFileSystemManager
34 * @param {!WebInspector.Workspace} workspace 34 * @param {!WebInspector.Workspace} workspace
35 */ 35 */
36 WebInspector.FileSystemWorkspaceBinding = function(isolatedFileSystemManager, wo rkspace) 36 WebInspector.FileSystemWorkspaceBinding = function(isolatedFileSystemManager, wo rkspace)
37 { 37 {
38 this._isolatedFileSystemManager = isolatedFileSystemManager; 38 this._isolatedFileSystemManager = isolatedFileSystemManager;
39 this._workspace = workspace; 39 this._workspace = workspace;
40 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemAdded, this._fileSystemAdded, this); 40 this._eventListeners = [
41 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemRemoved, this._fileSystemRemoved, this); 41 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFi leSystemManager.Events.FileSystemAdded, this._fileSystemAdded, this),
42 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemFilesChanged, this._fileSystemFilesChanged, this); 42 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFi leSystemManager.Events.FileSystemRemoved, this._fileSystemRemoved, this),
43 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFi leSystemManager.Events.FileSystemFilesChanged, this._fileSystemFilesChanged, thi s)
44 ];
43 /** @type {!Map.<string, !WebInspector.FileSystemWorkspaceBinding.FileSystem >} */ 45 /** @type {!Map.<string, !WebInspector.FileSystemWorkspaceBinding.FileSystem >} */
44 this._boundFileSystems = new Map(); 46 this._boundFileSystems = new Map();
45 } 47 }
46 48
47 WebInspector.FileSystemWorkspaceBinding._styleSheetExtensions = new Set(["css", "scss", "sass", "less"]); 49 WebInspector.FileSystemWorkspaceBinding._styleSheetExtensions = new Set(["css", "scss", "sass", "less"]);
48 WebInspector.FileSystemWorkspaceBinding._documentExtensions = new Set(["htm", "h tml", "asp", "aspx", "phtml", "jsp"]); 50 WebInspector.FileSystemWorkspaceBinding._documentExtensions = new Set(["htm", "h tml", "asp", "aspx", "phtml", "jsp"]);
49 WebInspector.FileSystemWorkspaceBinding._scriptExtensions = new Set(["asp", "asp x", "c", "cc", "cljs", "coffee", "cpp", "cs", "dart", "java", "js", "jsp", "jsx" , "h", "m", "mm", "py", "sh", "ts", "tsx", "ls"]); 51 WebInspector.FileSystemWorkspaceBinding._scriptExtensions = new Set(["asp", "asp x", "c", "cc", "cljs", "coffee", "cpp", "cs", "dart", "java", "js", "jsp", "jsx" , "h", "m", "mm", "py", "sh", "ts", "tsx", "ls"]);
50 52
51 WebInspector.FileSystemWorkspaceBinding._imageExtensions = WebInspector.Isolated FileSystem.ImageExtensions; 53 WebInspector.FileSystemWorkspaceBinding._imageExtensions = WebInspector.Isolated FileSystem.ImageExtensions;
52 54
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 * @param {string} projectId 148 * @param {string} projectId
147 * @return {string} 149 * @return {string}
148 */ 150 */
149 fileSystemPath: function(projectId) 151 fileSystemPath: function(projectId)
150 { 152 {
151 return projectId; 153 return projectId;
152 }, 154 },
153 155
154 dispose: function() 156 dispose: function()
155 { 157 {
156 this._isolatedFileSystemManager.removeEventListener(WebInspector.Isolate dFileSystemManager.Events.FileSystemAdded, this._fileSystemAdded, this); 158 WebInspector.EventTarget.removeEventListeners(this._eventListeners);
157 this._isolatedFileSystemManager.removeEventListener(WebInspector.Isolate dFileSystemManager.Events.FileSystemRemoved, this._fileSystemRemoved, this);
158 this._isolatedFileSystemManager.dispose();
159 for (var fileSystem of this._boundFileSystems.values()) { 159 for (var fileSystem of this._boundFileSystems.values()) {
160 fileSystem.dispose(); 160 fileSystem.dispose();
161 this._boundFileSystems.remove(fileSystem._fileSystem.path()); 161 this._boundFileSystems.remove(fileSystem._fileSystem.path());
162 } 162 }
163 } 163 }
164 } 164 }
165 165
166 /** 166 /**
167 * @constructor 167 * @constructor
168 * @extends {WebInspector.ProjectStore} 168 * @extends {WebInspector.ProjectStore}
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 uiSourceCode.checkContentUpdated(); 515 uiSourceCode.checkContentUpdated();
516 }, 516 },
517 517
518 dispose: function() 518 dispose: function()
519 { 519 {
520 this.removeProject(); 520 this.removeProject();
521 }, 521 },
522 522
523 __proto__: WebInspector.ProjectStore.prototype 523 __proto__: WebInspector.ProjectStore.prototype
524 } 524 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/bindings/NetworkMapping.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698