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

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

Issue 2536273003: [DevTools] Remove Workspace.projectTypes enum part1. (Closed)
Patch Set: Created 4 years 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 /** 4 /**
5 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 Persistence.DefaultMapping = class { 7 Persistence.DefaultMapping = class {
8 /** 8 /**
9 * @param {!Workspace.Workspace} workspace 9 * @param {!Workspace.Workspace} workspace
10 * @param {!Workspace.FileSystemMapping} fileSystemMapping 10 * @param {!Workspace.FileSystemMapping} fileSystemMapping
(...skipping 14 matching lines...) Expand all
25 workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved, this ._onProjectRemoved, this), 25 workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved, this ._onProjectRemoved, this),
26 this._fileSystemMapping.addEventListener(Workspace.FileSystemMapping.Event s.FileMappingAdded, this._remap, this), 26 this._fileSystemMapping.addEventListener(Workspace.FileSystemMapping.Event s.FileMappingAdded, this._remap, this),
27 this._fileSystemMapping.addEventListener(Workspace.FileSystemMapping.Event s.FileMappingRemoved, this._remap, this) 27 this._fileSystemMapping.addEventListener(Workspace.FileSystemMapping.Event s.FileMappingRemoved, this._remap, this)
28 ]; 28 ];
29 this._remap(); 29 this._remap();
30 } 30 }
31 31
32 _remap() { 32 _remap() {
33 for (var binding of this._bindings.valuesArray()) 33 for (var binding of this._bindings.valuesArray())
34 this._unbind(binding.network); 34 this._unbind(binding.network);
35 var networkProjects = this._workspace.projectsForType(Workspace.projectTypes .Network); 35 for (var uiSourceCode of Bindings.NetworkProject.uiSourceCodes(this._workspa ce))
36 for (var networkProject of networkProjects) { 36 this._bind(uiSourceCode);
37 for (var uiSourceCode of networkProject.uiSourceCodes())
38 this._bind(uiSourceCode);
39 }
40 } 37 }
41 38
42 /** 39 /**
43 * @param {!Common.Event} event 40 * @param {!Common.Event} event
44 */ 41 */
45 _onUISourceCodeAdded(event) { 42 _onUISourceCodeAdded(event) {
46 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); 43 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data);
47 this._bind(uiSourceCode); 44 this._bind(uiSourceCode);
48 } 45 }
49 46
(...skipping 12 matching lines...) Expand all
62 var project = /** @type {!Workspace.Project} */ (event.data); 59 var project = /** @type {!Workspace.Project} */ (event.data);
63 for (var uiSourceCode of project.uiSourceCodes()) 60 for (var uiSourceCode of project.uiSourceCodes())
64 this._unbind(uiSourceCode); 61 this._unbind(uiSourceCode);
65 } 62 }
66 63
67 /** 64 /**
68 * @param {!Workspace.UISourceCode} uiSourceCode 65 * @param {!Workspace.UISourceCode} uiSourceCode
69 * @return {?Persistence.PersistenceBinding} 66 * @return {?Persistence.PersistenceBinding}
70 */ 67 */
71 _createBinding(uiSourceCode) { 68 _createBinding(uiSourceCode) {
72 if (uiSourceCode.project().type() === Workspace.projectTypes.FileSystem) { 69 if (Persistence.FileSystemWorkspaceBinding.isFileSystemUISourceCode(uiSource Code)) {
73 var fileSystemPath = Persistence.FileSystemWorkspaceBinding.fileSystemPath (uiSourceCode.project().id()); 70 var fileSystemPath = Persistence.FileSystemWorkspaceBinding.fileSystemPath (uiSourceCode.project().id());
74 var networkURL = this._fileSystemMapping.networkURLForFileSystemURL(fileSy stemPath, uiSourceCode.url()); 71 var networkURL = this._fileSystemMapping.networkURLForFileSystemURL(fileSy stemPath, uiSourceCode.url());
75 var networkSourceCode = networkURL ? this._workspace.uiSourceCodeForURL(ne tworkURL) : null; 72 var networkSourceCode = networkURL ? this._workspace.uiSourceCodeForURL(ne tworkURL) : null;
76 return networkSourceCode ? new Persistence.PersistenceBinding(networkSourc eCode, uiSourceCode, false) : null; 73 return networkSourceCode ? new Persistence.PersistenceBinding(networkSourc eCode, uiSourceCode, false) : null;
77 } 74 }
78 if (uiSourceCode.project().type() === Workspace.projectTypes.Network) { 75 if (Bindings.NetworkProject.isNetworkUISourceCode(uiSourceCode)) {
79 var file = this._fileSystemMapping.fileForURL(uiSourceCode.url()); 76 var file = this._fileSystemMapping.fileForURL(uiSourceCode.url());
80 var projectId = file ? Persistence.FileSystemWorkspaceBinding.projectId(fi le.fileSystemPath) : null; 77 var projectId = file ? Persistence.FileSystemWorkspaceBinding.projectId(fi le.fileSystemPath) : null;
81 var fileSourceCode = file && projectId ? this._workspace.uiSourceCode(proj ectId, file.fileURL) : null; 78 var fileSourceCode = file && projectId ? this._workspace.uiSourceCode(proj ectId, file.fileURL) : null;
82 return fileSourceCode ? new Persistence.PersistenceBinding(uiSourceCode, f ileSourceCode, false) : null; 79 return fileSourceCode ? new Persistence.PersistenceBinding(uiSourceCode, f ileSourceCode, false) : null;
83 } 80 }
84 return null; 81 return null;
85 } 82 }
86 83
87 /** 84 /**
88 * @param {!Workspace.UISourceCode} uiSourceCode 85 * @param {!Workspace.UISourceCode} uiSourceCode
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 this._unbind(binding.network); 125 this._unbind(binding.network);
129 this._bind(binding.network); 126 this._bind(binding.network);
130 } 127 }
131 128
132 dispose() { 129 dispose() {
133 Common.EventTarget.removeEventListeners(this._eventListeners); 130 Common.EventTarget.removeEventListeners(this._eventListeners);
134 } 131 }
135 }; 132 };
136 133
137 Persistence.DefaultMapping._binding = Symbol('DefaultMapping.Binding'); 134 Persistence.DefaultMapping._binding = Symbol('DefaultMapping.Binding');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698