| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @param {!WebInspector.TargetManager} targetManager | 7 * @param {!WebInspector.TargetManager} targetManager |
| 8 * @param {!WebInspector.Workspace} workspace | 8 * @param {!WebInspector.Workspace} workspace |
| 9 * @param {!WebInspector.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding | 9 * @param {!WebInspector.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding |
| 10 * @param {!WebInspector.FileSystemMapping} fileSystemMapping | 10 * @param {!WebInspector.FileSystemMapping} fileSystemMapping |
| 11 */ | 11 */ |
| 12 WebInspector.NetworkMapping = function(targetManager, workspace, fileSystemWorks
paceBinding, fileSystemMapping) | 12 WebInspector.NetworkMapping = function(targetManager, workspace, fileSystemWorks
paceBinding, fileSystemMapping) |
| 13 { | 13 { |
| 14 this._targetManager = targetManager; | 14 this._targetManager = targetManager; |
| 15 this._workspace = workspace; | 15 this._workspace = workspace; |
| 16 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding; | 16 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding; |
| 17 this._fileSystemMapping = fileSystemMapping; | 17 this._fileSystemMapping = fileSystemMapping; |
| 18 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.RevealSourceLine, this._revealSourceLine, this); | 18 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event
s.RevealSourceLine, this._revealSourceLine, this); |
| 19 | 19 |
| 20 var fileSystemManager = fileSystemWorkspaceBinding.fileSystemManager(); | 20 var fileSystemManager = fileSystemWorkspaceBinding.fileSystemManager(); |
| 21 this._eventListeners = [ | 21 this._eventListeners = [ |
| 22 fileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManage
r.Events.FileSystemAdded, this._fileSystemAdded, this), | 22 fileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManage
r.Events.FileSystemAdded, this._fileSystemAdded, this), |
| 23 fileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManage
r.Events.FileSystemRemoved, this._fileSystemRemoved, this), | 23 fileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManage
r.Events.FileSystemRemoved, this._fileSystemRemoved, this), |
| 24 this._fileSystemMapping.addEventListener(WebInspector.FileSystemMapping.
Events.FileMappingAdded, this._fileSystemMappingChanged, this), | |
| 25 this._fileSystemMapping.addEventListener(WebInspector.FileSystemMapping.
Events.FileMappingRemoved, this._fileSystemMappingChanged, this) | |
| 26 ]; | 24 ]; |
| 27 | |
| 28 fileSystemManager.waitForFileSystems() | 25 fileSystemManager.waitForFileSystems() |
| 29 .then(this._fileSystemsLoaded.bind(this)); | 26 .then(this._fileSystemsLoaded.bind(this)); |
| 30 } | 27 } |
| 31 | 28 |
| 32 WebInspector.NetworkMapping.prototype = { | 29 WebInspector.NetworkMapping.prototype = { |
| 33 /** | 30 /** |
| 34 * @param {!Array<!WebInspector.IsolatedFileSystem>} fileSystems | 31 * @param {!Array<!WebInspector.IsolatedFileSystem>} fileSystems |
| 35 */ | 32 */ |
| 36 _fileSystemsLoaded: function(fileSystems) | 33 _fileSystemsLoaded: function(fileSystems) |
| 37 { | 34 { |
| 38 for (var fileSystem of fileSystems) | 35 for (var fileSystem of fileSystems) |
| 39 this._addMappingsForFilesystem(fileSystem); | 36 this._addMappingsForFilesystem(fileSystem); |
| 40 }, | 37 }, |
| 41 | 38 |
| 42 /** | 39 /** |
| 43 * @param {!WebInspector.Event} event | 40 * @param {!WebInspector.Event} event |
| 44 */ | 41 */ |
| 45 _fileSystemAdded: function(event) | 42 _fileSystemAdded: function(event) |
| 46 { | 43 { |
| 47 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event.
data); | 44 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event.
data); |
| 48 this._addMappingsForFilesystem(fileSystem); | 45 this._addMappingsForFilesystem(fileSystem); |
| 49 this._fileSystemMappingChanged(); | |
| 50 }, | 46 }, |
| 51 | 47 |
| 52 /** | 48 /** |
| 53 * @param {!WebInspector.IsolatedFileSystem} fileSystem | 49 * @param {!WebInspector.IsolatedFileSystem} fileSystem |
| 54 */ | 50 */ |
| 55 _addMappingsForFilesystem: function(fileSystem) | 51 _addMappingsForFilesystem: function(fileSystem) |
| 56 { | 52 { |
| 57 this._addingFileSystem = true; | 53 this._addingFileSystem = true; |
| 58 this._fileSystemMapping.addFileSystem(fileSystem.path()); | 54 this._fileSystemMapping.addFileSystem(fileSystem.path()); |
| 59 | 55 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 71 this._addingFileSystem = false; | 67 this._addingFileSystem = false; |
| 72 }, | 68 }, |
| 73 | 69 |
| 74 /** | 70 /** |
| 75 * @param {!WebInspector.Event} event | 71 * @param {!WebInspector.Event} event |
| 76 */ | 72 */ |
| 77 _fileSystemRemoved: function(event) | 73 _fileSystemRemoved: function(event) |
| 78 { | 74 { |
| 79 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event.
data); | 75 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event.
data); |
| 80 this._fileSystemMapping.removeFileSystem(fileSystem.path()); | 76 this._fileSystemMapping.removeFileSystem(fileSystem.path()); |
| 81 this._fileSystemMappingChanged(); | |
| 82 }, | 77 }, |
| 83 | 78 |
| 84 /** | 79 /** |
| 85 * @param {!WebInspector.UISourceCode} uiSourceCode | 80 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 86 * @return {string} | 81 * @return {string} |
| 87 */ | 82 */ |
| 88 networkURL: function(uiSourceCode) | 83 networkURL: function(uiSourceCode) |
| 89 { | 84 { |
| 90 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst
em) { | 85 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst
em) |
| 91 var fileSystemPath = this._fileSystemWorkspaceBinding.fileSystemPath
(uiSourceCode.project().id()); | 86 return ""; |
| 92 return this._networkURLForFileSystemURL(fileSystemPath, uiSourceCode
.url()); | |
| 93 } | |
| 94 return uiSourceCode.url(); | 87 return uiSourceCode.url(); |
| 95 }, | 88 }, |
| 96 | 89 |
| 97 /** | 90 /** |
| 98 * @param {string} url | |
| 99 * @return {boolean} | |
| 100 */ | |
| 101 hasMappingForNetworkURL: function(url) | |
| 102 { | |
| 103 return this._fileSystemMapping.hasMappingForNetworkURL(url); | |
| 104 }, | |
| 105 | |
| 106 /** | |
| 107 * @param {!WebInspector.Target} target | 91 * @param {!WebInspector.Target} target |
| 108 * @param {?WebInspector.ResourceTreeFrame} frame | 92 * @param {?WebInspector.ResourceTreeFrame} frame |
| 109 * @param {string} url | 93 * @param {string} url |
| 110 * @return {?WebInspector.UISourceCode} | 94 * @return {?WebInspector.UISourceCode} |
| 111 */ | 95 */ |
| 112 _networkUISourceCodeForURL: function(target, frame, url) | 96 _networkUISourceCodeForURL: function(target, frame, url) |
| 113 { | 97 { |
| 114 return this._workspace.uiSourceCode(WebInspector.NetworkProject.projectI
d(target, frame, false), url); | 98 return this._workspace.uiSourceCode(WebInspector.NetworkProject.projectI
d(target, frame, false), url); |
| 115 }, | 99 }, |
| 116 | 100 |
| 117 /** | 101 /** |
| 118 * @param {!WebInspector.Target} target | 102 * @param {!WebInspector.Target} target |
| 119 * @param {?WebInspector.ResourceTreeFrame} frame | 103 * @param {?WebInspector.ResourceTreeFrame} frame |
| 120 * @param {string} url | 104 * @param {string} url |
| 121 * @return {?WebInspector.UISourceCode} | 105 * @return {?WebInspector.UISourceCode} |
| 122 */ | 106 */ |
| 123 _contentScriptUISourceCodeForURL: function(target, frame, url) | 107 _contentScriptUISourceCodeForURL: function(target, frame, url) |
| 124 { | 108 { |
| 125 return this._workspace.uiSourceCode(WebInspector.NetworkProject.projectI
d(target, frame, true), url); | 109 return this._workspace.uiSourceCode(WebInspector.NetworkProject.projectI
d(target, frame, true), url); |
| 126 }, | 110 }, |
| 127 | 111 |
| 128 /** | 112 /** |
| 129 * @param {string} url | |
| 130 * @return {?WebInspector.UISourceCode} | |
| 131 */ | |
| 132 _fileSystemUISourceCodeForURL: function(url) | |
| 133 { | |
| 134 var file = this._fileSystemMapping.fileForURL(url); | |
| 135 if (file) { | |
| 136 var projectId = WebInspector.FileSystemWorkspaceBinding.projectId(fi
le.fileSystemPath); | |
| 137 return this._workspace.uiSourceCode(projectId, file.fileURL); | |
| 138 } | |
| 139 return null; | |
| 140 }, | |
| 141 | |
| 142 /** | |
| 143 * @param {!WebInspector.Target} target | 113 * @param {!WebInspector.Target} target |
| 144 * @param {?WebInspector.ResourceTreeFrame} frame | 114 * @param {?WebInspector.ResourceTreeFrame} frame |
| 145 * @param {string} url | 115 * @param {string} url |
| 146 * @return {?WebInspector.UISourceCode} | 116 * @return {?WebInspector.UISourceCode} |
| 147 */ | 117 */ |
| 148 _uiSourceCodeForURL: function(target, frame, url) | 118 _uiSourceCodeForURL: function(target, frame, url) |
| 149 { | 119 { |
| 150 return this._fileSystemUISourceCodeForURL(url) || this._networkUISourceC
odeForURL(target, frame, url) || this._contentScriptUISourceCodeForURL(target, f
rame, url); | 120 return this._networkUISourceCodeForURL(target, frame, url) || this._cont
entScriptUISourceCodeForURL(target, frame, url); |
| 151 }, | 121 }, |
| 152 | 122 |
| 153 /** | 123 /** |
| 154 * @param {string} url | 124 * @param {string} url |
| 155 * @param {!WebInspector.Script} script | 125 * @param {!WebInspector.Script} script |
| 156 * @return {?WebInspector.UISourceCode} | 126 * @return {?WebInspector.UISourceCode} |
| 157 */ | 127 */ |
| 158 uiSourceCodeForScriptURL: function(url, script) | 128 uiSourceCodeForScriptURL: function(url, script) |
| 159 { | 129 { |
| 160 var frame = WebInspector.ResourceTreeFrame.fromScript(script); | 130 var frame = WebInspector.ResourceTreeFrame.fromScript(script); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 171 var frame = WebInspector.ResourceTreeFrame.fromStyleSheet(header); | 141 var frame = WebInspector.ResourceTreeFrame.fromStyleSheet(header); |
| 172 return this._uiSourceCodeForURL(header.target(), frame, url); | 142 return this._uiSourceCodeForURL(header.target(), frame, url); |
| 173 }, | 143 }, |
| 174 | 144 |
| 175 /** | 145 /** |
| 176 * @param {string} url | 146 * @param {string} url |
| 177 * @return {?WebInspector.UISourceCode} | 147 * @return {?WebInspector.UISourceCode} |
| 178 */ | 148 */ |
| 179 uiSourceCodeForURLForAnyTarget: function(url) | 149 uiSourceCodeForURLForAnyTarget: function(url) |
| 180 { | 150 { |
| 181 return this._fileSystemUISourceCodeForURL(url) || WebInspector.workspace
.uiSourceCodeForURL(url); | 151 return WebInspector.workspace.uiSourceCodeForURL(url); |
| 182 }, | 152 }, |
| 183 | 153 |
| 184 /** | 154 /** |
| 185 * @param {string} fileSystemPath | |
| 186 * @param {string} filePath | |
| 187 * @return {string} | |
| 188 */ | |
| 189 _networkURLForFileSystemURL: function(fileSystemPath, filePath) | |
| 190 { | |
| 191 return this._fileSystemMapping.networkURLForFileSystemURL(fileSystemPath
, filePath); | |
| 192 }, | |
| 193 | |
| 194 /** | |
| 195 * @param {!WebInspector.UISourceCode} networkUISourceCode | 155 * @param {!WebInspector.UISourceCode} networkUISourceCode |
| 196 * @param {!WebInspector.UISourceCode} uiSourceCode | 156 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 197 */ | 157 */ |
| 198 addMapping: function(networkUISourceCode, uiSourceCode) | 158 addMapping: function(networkUISourceCode, uiSourceCode) |
| 199 { | 159 { |
| 200 var url = this.networkURL(networkUISourceCode); | 160 var url = this.networkURL(networkUISourceCode); |
| 201 var path = uiSourceCode.url(); | 161 var path = uiSourceCode.url(); |
| 202 var fileSystemPath = this._fileSystemWorkspaceBinding.fileSystemPath(uiS
ourceCode.project().id()); | 162 var fileSystemPath = WebInspector.FileSystemWorkspaceBinding.fileSystemP
ath(uiSourceCode.project().id()); |
| 203 this._fileSystemMapping.addMappingForResource(url, fileSystemPath, path)
; | 163 this._fileSystemMapping.addMappingForResource(url, fileSystemPath, path)
; |
| 204 }, | 164 }, |
| 205 | 165 |
| 206 /** | 166 /** |
| 207 * @param {!WebInspector.UISourceCode} uiSourceCode | 167 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 208 */ | 168 */ |
| 209 removeMapping: function(uiSourceCode) | 169 removeMapping: function(uiSourceCode) |
| 210 { | 170 { |
| 211 var networkURL = this.networkURL(uiSourceCode); | 171 var networkURL = this.networkURL(uiSourceCode); |
| 212 this._fileSystemMapping.removeMappingForURL(networkURL); | 172 this._fileSystemMapping.removeMappingForURL(networkURL); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 236 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.
data); | 196 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.
data); |
| 237 if (this.networkURL(uiSourceCode) === url) { | 197 if (this.networkURL(uiSourceCode) === url) { |
| 238 WebInspector.Revealer.reveal(uiSourceCode.uiLocation(lineNumber,
columnNumber)); | 198 WebInspector.Revealer.reveal(uiSourceCode.uiLocation(lineNumber,
columnNumber)); |
| 239 this._workspace.removeEventListener(WebInspector.Workspace.Event
s.UISourceCodeAdded, listener, this); | 199 this._workspace.removeEventListener(WebInspector.Workspace.Event
s.UISourceCodeAdded, listener, this); |
| 240 } | 200 } |
| 241 } | 201 } |
| 242 | 202 |
| 243 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceC
odeAdded, listener, this); | 203 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceC
odeAdded, listener, this); |
| 244 }, | 204 }, |
| 245 | 205 |
| 246 _fileSystemMappingChanged: function() | |
| 247 { | |
| 248 if (this._addingFileSystem) | |
| 249 return; | |
| 250 this._targetManager.suspendAndResumeAllTargets(); | |
| 251 }, | |
| 252 | |
| 253 dispose: function() | 206 dispose: function() |
| 254 { | 207 { |
| 255 WebInspector.EventTarget.removeEventListeners(this._eventListeners); | 208 WebInspector.EventTarget.removeEventListeners(this._eventListeners); |
| 256 } | 209 } |
| 257 } | 210 } |
| 258 | 211 |
| 259 /** | 212 /** |
| 260 * @type {!WebInspector.NetworkMapping} | 213 * @type {!WebInspector.NetworkMapping} |
| 261 */ | 214 */ |
| 262 WebInspector.networkMapping; | 215 WebInspector.networkMapping; |
| OLD | NEW |