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

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

Issue 2867783003: DevTools: move IsolatedFileSystem/IsolatedFileSystemManager into persistence/ (Closed)
Patch Set: fix order Created 3 years, 7 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
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 15 matching lines...) Expand all
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.FileSystemWorkspaceBinding = class { 34 Persistence.FileSystemWorkspaceBinding = class {
35 /** 35 /**
36 * @param {!Workspace.IsolatedFileSystemManager} isolatedFileSystemManager 36 * @param {!Persistence.IsolatedFileSystemManager} isolatedFileSystemManager
37 * @param {!Workspace.Workspace} workspace 37 * @param {!Workspace.Workspace} workspace
38 */ 38 */
39 constructor(isolatedFileSystemManager, workspace) { 39 constructor(isolatedFileSystemManager, workspace) {
40 this._isolatedFileSystemManager = isolatedFileSystemManager; 40 this._isolatedFileSystemManager = isolatedFileSystemManager;
41 this._workspace = workspace; 41 this._workspace = workspace;
42 this._eventListeners = [ 42 this._eventListeners = [
43 this._isolatedFileSystemManager.addEventListener( 43 this._isolatedFileSystemManager.addEventListener(
44 Workspace.IsolatedFileSystemManager.Events.FileSystemAdded, this._onFi leSystemAdded, this), 44 Persistence.IsolatedFileSystemManager.Events.FileSystemAdded, this._on FileSystemAdded, this),
45 this._isolatedFileSystemManager.addEventListener( 45 this._isolatedFileSystemManager.addEventListener(
46 Workspace.IsolatedFileSystemManager.Events.FileSystemRemoved, this._on FileSystemRemoved, this), 46 Persistence.IsolatedFileSystemManager.Events.FileSystemRemoved, this._ onFileSystemRemoved, this),
47 this._isolatedFileSystemManager.addEventListener( 47 this._isolatedFileSystemManager.addEventListener(
48 Workspace.IsolatedFileSystemManager.Events.FileSystemFilesChanged, thi s._fileSystemFilesChanged, this) 48 Persistence.IsolatedFileSystemManager.Events.FileSystemFilesChanged, t his._fileSystemFilesChanged, this)
49 ]; 49 ];
50 /** @type {!Map.<string, !Persistence.FileSystemWorkspaceBinding.FileSystem> } */ 50 /** @type {!Map.<string, !Persistence.FileSystemWorkspaceBinding.FileSystem> } */
51 this._boundFileSystems = new Map(); 51 this._boundFileSystems = new Map();
52 this._isolatedFileSystemManager.waitForFileSystems().then(this._onFileSystem sLoaded.bind(this)); 52 this._isolatedFileSystemManager.waitForFileSystems().then(this._onFileSystem sLoaded.bind(this));
53 } 53 }
54 54
55 /** 55 /**
56 * @param {string} fileSystemPath 56 * @param {string} fileSystemPath
57 * @return {string} 57 * @return {string}
58 */ 58 */
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 /** 100 /**
101 * @param {string} projectId 101 * @param {string} projectId
102 * @return {string} 102 * @return {string}
103 */ 103 */
104 static fileSystemPath(projectId) { 104 static fileSystemPath(projectId) {
105 return projectId; 105 return projectId;
106 } 106 }
107 107
108 /** 108 /**
109 * @return {!Workspace.IsolatedFileSystemManager} 109 * @return {!Persistence.IsolatedFileSystemManager}
110 */ 110 */
111 fileSystemManager() { 111 fileSystemManager() {
112 return this._isolatedFileSystemManager; 112 return this._isolatedFileSystemManager;
113 } 113 }
114 114
115 /** 115 /**
116 * @param {!Array<!Workspace.IsolatedFileSystem>} fileSystems 116 * @param {!Array<!Persistence.IsolatedFileSystem>} fileSystems
117 */ 117 */
118 _onFileSystemsLoaded(fileSystems) { 118 _onFileSystemsLoaded(fileSystems) {
119 for (var fileSystem of fileSystems) 119 for (var fileSystem of fileSystems)
120 this._addFileSystem(fileSystem); 120 this._addFileSystem(fileSystem);
121 } 121 }
122 122
123 /** 123 /**
124 * @param {!Common.Event} event 124 * @param {!Common.Event} event
125 */ 125 */
126 _onFileSystemAdded(event) { 126 _onFileSystemAdded(event) {
127 var fileSystem = /** @type {!Workspace.IsolatedFileSystem} */ (event.data); 127 var fileSystem = /** @type {!Persistence.IsolatedFileSystem} */ (event.data) ;
128 this._addFileSystem(fileSystem); 128 this._addFileSystem(fileSystem);
129 } 129 }
130 130
131 /** 131 /**
132 * @param {!Workspace.IsolatedFileSystem} fileSystem 132 * @param {!Persistence.IsolatedFileSystem} fileSystem
133 */ 133 */
134 _addFileSystem(fileSystem) { 134 _addFileSystem(fileSystem) {
135 var boundFileSystem = new Persistence.FileSystemWorkspaceBinding.FileSystem( this, fileSystem, this._workspace); 135 var boundFileSystem = new Persistence.FileSystemWorkspaceBinding.FileSystem( this, fileSystem, this._workspace);
136 this._boundFileSystems.set(fileSystem.path(), boundFileSystem); 136 this._boundFileSystems.set(fileSystem.path(), boundFileSystem);
137 } 137 }
138 138
139 /** 139 /**
140 * @param {!Common.Event} event 140 * @param {!Common.Event} event
141 */ 141 */
142 _onFileSystemRemoved(event) { 142 _onFileSystemRemoved(event) {
143 var fileSystem = /** @type {!Workspace.IsolatedFileSystem} */ (event.data); 143 var fileSystem = /** @type {!Persistence.IsolatedFileSystem} */ (event.data) ;
144 var boundFileSystem = this._boundFileSystems.get(fileSystem.path()); 144 var boundFileSystem = this._boundFileSystems.get(fileSystem.path());
145 boundFileSystem.dispose(); 145 boundFileSystem.dispose();
146 this._boundFileSystems.remove(fileSystem.path()); 146 this._boundFileSystems.remove(fileSystem.path());
147 } 147 }
148 148
149 /** 149 /**
150 * @param {!Common.Event} event 150 * @param {!Common.Event} event
151 */ 151 */
152 _fileSystemFilesChanged(event) { 152 _fileSystemFilesChanged(event) {
153 var paths = /** @type {!Workspace.IsolatedFileSystemManager.FilesChangedData } */ (event.data); 153 var paths = /** @type {!Persistence.IsolatedFileSystemManager.FilesChangedDa ta} */ (event.data);
154 forEachFile.call(this, paths.changed, (path, fileSystem) => fileSystem._file Changed(path)); 154 forEachFile.call(this, paths.changed, (path, fileSystem) => fileSystem._file Changed(path));
155 forEachFile.call(this, paths.added, (path, fileSystem) => fileSystem._fileCh anged(path)); 155 forEachFile.call(this, paths.added, (path, fileSystem) => fileSystem._fileCh anged(path));
156 forEachFile.call(this, paths.removed, (path, fileSystem) => fileSystem.remov eUISourceCode(path)); 156 forEachFile.call(this, paths.removed, (path, fileSystem) => fileSystem.remov eUISourceCode(path));
157 157
158 /** 158 /**
159 * @param {!Array<string>} filePaths 159 * @param {!Array<string>} filePaths
160 * @param {function(string, !Persistence.FileSystemWorkspaceBinding.FileSyst em)} callback 160 * @param {function(string, !Persistence.FileSystemWorkspaceBinding.FileSyst em)} callback
161 * @this {Persistence.FileSystemWorkspaceBinding} 161 * @this {Persistence.FileSystemWorkspaceBinding}
162 */ 162 */
163 function forEachFile(filePaths, callback) { 163 function forEachFile(filePaths, callback) {
(...skipping 16 matching lines...) Expand all
180 } 180 }
181 }; 181 };
182 182
183 Persistence.FileSystemWorkspaceBinding._styleSheetExtensions = new Set(['css', ' scss', 'sass', 'less']); 183 Persistence.FileSystemWorkspaceBinding._styleSheetExtensions = new Set(['css', ' scss', 'sass', 'less']);
184 Persistence.FileSystemWorkspaceBinding._documentExtensions = new Set(['htm', 'ht ml', 'asp', 'aspx', 'phtml', 'jsp']); 184 Persistence.FileSystemWorkspaceBinding._documentExtensions = new Set(['htm', 'ht ml', 'asp', 'aspx', 'phtml', 'jsp']);
185 Persistence.FileSystemWorkspaceBinding._scriptExtensions = new Set([ 185 Persistence.FileSystemWorkspaceBinding._scriptExtensions = new Set([
186 'asp', 'aspx', 'c', 'cc', 'cljs', 'coffee', 'cpp', 'cs', 'dart', 'java', 'js', 186 'asp', 'aspx', 'c', 'cc', 'cljs', 'coffee', 'cpp', 'cs', 'dart', 'java', 'js',
187 'jsp', 'jsx', 'h', 'm', 'mm', 'py', 'sh', 'ts', 'tsx', 'ls' 187 'jsp', 'jsx', 'h', 'm', 'mm', 'py', 'sh', 'ts', 'tsx', 'ls'
188 ]); 188 ]);
189 189
190 Persistence.FileSystemWorkspaceBinding._imageExtensions = Workspace.IsolatedFile System.ImageExtensions; 190 Persistence.FileSystemWorkspaceBinding._imageExtensions = Persistence.IsolatedFi leSystem.ImageExtensions;
191 191
192 Persistence.FileSystemWorkspaceBinding._binaryExtensions = new Set([ 192 Persistence.FileSystemWorkspaceBinding._binaryExtensions = new Set([
193 // Executable extensions, roughly taken from https://en.wikipedia.org/wiki/Com parison_of_executable_file_formats 193 // Executable extensions, roughly taken from https://en.wikipedia.org/wiki/Com parison_of_executable_file_formats
194 'cmd', 'com', 'exe', 194 'cmd', 'com', 'exe',
195 // Archive extensions, roughly taken from https://en.wikipedia.org/wiki/List_o f_archive_formats 195 // Archive extensions, roughly taken from https://en.wikipedia.org/wiki/List_o f_archive_formats
196 'a', 'ar', 'iso', 'tar', 'bz2', 'gz', 'lz', 'lzma', 'z', '7z', 'apk', 'arc', ' cab', 'dmg', 'jar', 'pak', 'rar', 'zip', 196 'a', 'ar', 'iso', 'tar', 'bz2', 'gz', 'lz', 'lzma', 'z', '7z', 'apk', 'arc', ' cab', 'dmg', 'jar', 'pak', 'rar', 'zip',
197 // Audio file extensions, roughly taken from https://en.wikipedia.org/wiki/Aud io_file_format#List_of_formats 197 // Audio file extensions, roughly taken from https://en.wikipedia.org/wiki/Aud io_file_format#List_of_formats
198 '3gp', 'aac', 'aiff', 'flac', 'm4a', 'mmf', 'mp3', 'ogg', 'oga', 'raw', 'sln', 'wav', 'wma', 'webm', 198 '3gp', 'aac', 'aiff', 'flac', 'm4a', 'mmf', 'mp3', 'ogg', 'oga', 'raw', 'sln', 'wav', 'wma', 'webm',
199 // Video file extensions, roughly taken from https://en.wikipedia.org/wiki/Vid eo_file_format 199 // Video file extensions, roughly taken from https://en.wikipedia.org/wiki/Vid eo_file_format
200 'mkv', 'flv', 'vob', 'ogv', 'gif', 'gifv', 'avi', 'mov', 'qt', 'mp4', 'm4p', ' m4v', 'mpg', 'mpeg' 200 'mkv', 'flv', 'vob', 'ogv', 'gif', 'gifv', 'avi', 'mov', 'qt', 'mp4', 'm4p', ' m4v', 'mpg', 'mpeg'
201 ]); 201 ]);
202 202
203 203
204 /** 204 /**
205 * @implements {Workspace.Project} 205 * @implements {Workspace.Project}
206 * @unrestricted 206 * @unrestricted
207 */ 207 */
208 Persistence.FileSystemWorkspaceBinding.FileSystem = class extends Workspace.Proj ectStore { 208 Persistence.FileSystemWorkspaceBinding.FileSystem = class extends Workspace.Proj ectStore {
209 /** 209 /**
210 * @param {!Persistence.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding 210 * @param {!Persistence.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding
211 * @param {!Workspace.IsolatedFileSystem} isolatedFileSystem 211 * @param {!Persistence.IsolatedFileSystem} isolatedFileSystem
212 * @param {!Workspace.Workspace} workspace 212 * @param {!Workspace.Workspace} workspace
213 */ 213 */
214 constructor(fileSystemWorkspaceBinding, isolatedFileSystem, workspace) { 214 constructor(fileSystemWorkspaceBinding, isolatedFileSystem, workspace) {
215 var fileSystemPath = isolatedFileSystem.path(); 215 var fileSystemPath = isolatedFileSystem.path();
216 var id = Persistence.FileSystemWorkspaceBinding.projectId(fileSystemPath); 216 var id = Persistence.FileSystemWorkspaceBinding.projectId(fileSystemPath);
217 console.assert(!workspace.project(id)); 217 console.assert(!workspace.project(id));
218 var displayName = fileSystemPath.substr(fileSystemPath.lastIndexOf('/') + 1) ; 218 var displayName = fileSystemPath.substr(fileSystemPath.lastIndexOf('/') + 1) ;
219 219
220 super(workspace, id, Workspace.projectTypes.FileSystem, displayName); 220 super(workspace, id, Workspace.projectTypes.FileSystem, displayName);
221 221
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 uiSourceCode[Persistence.FileSystemWorkspaceBinding._metadata] = null; 583 uiSourceCode[Persistence.FileSystemWorkspaceBinding._metadata] = null;
584 uiSourceCode.checkContentUpdated(); 584 uiSourceCode.checkContentUpdated();
585 } 585 }
586 586
587 dispose() { 587 dispose() {
588 this.removeProject(); 588 this.removeProject();
589 } 589 }
590 }; 590 };
591 591
592 Persistence.FileSystemWorkspaceBinding._metadata = Symbol('FileSystemWorkspaceBi nding.Metadata'); 592 Persistence.FileSystemWorkspaceBinding._metadata = Symbol('FileSystemWorkspaceBi nding.Metadata');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698