| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 * @implements {SDK.TargetManager.Observer} | 31 * @implements {SDK.TargetManager.Observer} |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 Bindings.NetworkProjectManager = class { | 34 Bindings.NetworkProjectManager = class extends Common.Object { |
| 35 /** | 35 /** |
| 36 * @param {!SDK.TargetManager} targetManager | 36 * @param {!SDK.TargetManager} targetManager |
| 37 * @param {!Workspace.Workspace} workspace | 37 * @param {!Workspace.Workspace} workspace |
| 38 */ | 38 */ |
| 39 constructor(targetManager, workspace) { | 39 constructor(targetManager, workspace) { |
| 40 super(); |
| 40 this._workspace = workspace; | 41 this._workspace = workspace; |
| 41 targetManager.observeTargets(this); | 42 targetManager.observeTargets(this); |
| 42 } | 43 } |
| 43 | 44 |
| 44 /** | 45 /** |
| 45 * @override | 46 * @override |
| 46 * @param {!SDK.Target} target | 47 * @param {!SDK.Target} target |
| 47 */ | 48 */ |
| 48 targetAdded(target) { | 49 targetAdded(target) { |
| 49 new Bindings.NetworkProject(target, this._workspace, target.model(SDK.Resour
ceTreeModel)); | 50 new Bindings.NetworkProject(target, this._workspace, target.model(SDK.Resour
ceTreeModel)); |
| 50 } | 51 } |
| 51 | 52 |
| 52 /** | 53 /** |
| 53 * @override | 54 * @override |
| 54 * @param {!SDK.Target} target | 55 * @param {!SDK.Target} target |
| 55 */ | 56 */ |
| 56 targetRemoved(target) { | 57 targetRemoved(target) { |
| 57 Bindings.NetworkProject.forTarget(target)._dispose(); | 58 Bindings.NetworkProject.forTarget(target)._dispose(); |
| 58 } | 59 } |
| 59 }; | 60 }; |
| 60 | 61 |
| 62 Bindings.NetworkProjectManager.Events = { |
| 63 FrameAttributionChanged: Symbol('FrameAttributionChanged') |
| 64 }; |
| 65 |
| 61 /** | 66 /** |
| 62 * @unrestricted | 67 * @unrestricted |
| 63 */ | 68 */ |
| 64 Bindings.NetworkProject = class { | 69 Bindings.NetworkProject = class { |
| 65 /** | 70 /** |
| 66 * @param {!SDK.Target} target | 71 * @param {!SDK.Target} target |
| 67 * @param {!Workspace.Workspace} workspace | 72 * @param {!Workspace.Workspace} workspace |
| 68 * @param {?SDK.ResourceTreeModel} resourceTreeModel | 73 * @param {?SDK.ResourceTreeModel} resourceTreeModel |
| 69 */ | 74 */ |
| 70 constructor(target, workspace, resourceTreeModel) { | 75 constructor(target, workspace, resourceTreeModel) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 */ | 129 */ |
| 125 static forTarget(target) { | 130 static forTarget(target) { |
| 126 return target[Bindings.NetworkProject._networkProjectSymbol]; | 131 return target[Bindings.NetworkProject._networkProjectSymbol]; |
| 127 } | 132 } |
| 128 | 133 |
| 129 /** | 134 /** |
| 130 * @param {!Workspace.UISourceCode} uiSourceCode | 135 * @param {!Workspace.UISourceCode} uiSourceCode |
| 131 * @return {?Set<string>} | 136 * @return {?Set<string>} |
| 132 */ | 137 */ |
| 133 static frameAttribution(uiSourceCode) { | 138 static frameAttribution(uiSourceCode) { |
| 134 var frameId = uiSourceCode[Bindings.NetworkProject._frameAttributionSymbol]; | 139 var frameIds = uiSourceCode[Bindings.NetworkProject._frameAttributionSymbol]
; |
| 135 return frameId ? new Set([frameId]) : null; | 140 return frameIds ? new Set(frameIds) : null; |
| 136 } | 141 } |
| 137 | 142 |
| 138 /** | 143 /** |
| 144 * @param {!Workspace.UISourceCode} uiSourceCode |
| 145 * @param {?Set<string>} frameIds |
| 146 */ |
| 147 static setInitialFrameAttribution(uiSourceCode, frameIds) { |
| 148 uiSourceCode[Bindings.NetworkProject._frameAttributionSymbol] = frameIds; |
| 149 } |
| 150 |
| 151 /** |
| 152 * @param {!Workspace.UISourceCode} uiSourceCode |
| 153 * @param {?Set<string>} frameIds |
| 154 */ |
| 155 static changeFrameAttribution(uiSourceCode, frameIds) { |
| 156 var frameAttribution = uiSourceCode[Bindings.NetworkProject._frameAttributio
nSymbol]; |
| 157 if (!frameAttribution && !frameIds) |
| 158 return; |
| 159 if (frameAttribution && frameIds && frameIds.size === frameAttribution.size
&& |
| 160 frameAttribution.containsAll(frameIds)) |
| 161 return; |
| 162 uiSourceCode[Bindings.NetworkProject._frameAttributionSymbol] = frameIds; |
| 163 Bindings.networkProjectManager.dispatchEventToListeners( |
| 164 Bindings.NetworkProjectManager.Events.FrameAttributionChanged, uiSourceC
ode); |
| 165 } |
| 166 |
| 167 /** |
| 139 * @param {!Workspace.UISourceCode} uiSourceCode | 168 * @param {!Workspace.UISourceCode} uiSourceCode |
| 140 * @return {?SDK.Target} target | 169 * @return {?SDK.Target} target |
| 141 */ | 170 */ |
| 142 static targetForUISourceCode(uiSourceCode) { | 171 static targetForUISourceCode(uiSourceCode) { |
| 143 return uiSourceCode.project()[Bindings.NetworkProject._targetSymbol] || null
; | 172 return uiSourceCode.project()[Bindings.NetworkProject._targetSymbol] || null
; |
| 144 } | 173 } |
| 145 | 174 |
| 146 /** | 175 /** |
| 176 * @param {!Workspace.Project} project |
| 177 * @param {!SDK.Target} target |
| 178 */ |
| 179 static setTargetForProject(project, target) { |
| 180 project[Bindings.NetworkProject._targetSymbol] = target; |
| 181 } |
| 182 |
| 183 /** |
| 147 * @param {!Workspace.UISourceCode} uiSourceCode | 184 * @param {!Workspace.UISourceCode} uiSourceCode |
| 148 * @return {!Array<!SDK.ResourceTreeFrame>} | 185 * @return {!Array<!SDK.ResourceTreeFrame>} |
| 149 */ | 186 */ |
| 150 static framesForUISourceCode(uiSourceCode) { | 187 static framesForUISourceCode(uiSourceCode) { |
| 151 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); | 188 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); |
| 152 var resourceTreeModel = target && target.model(SDK.ResourceTreeModel); | 189 var resourceTreeModel = target && target.model(SDK.ResourceTreeModel); |
| 153 var frameIds = Bindings.NetworkProject.frameAttribution(uiSourceCode); | 190 var frameIds = Bindings.NetworkProject.frameAttribution(uiSourceCode); |
| 154 if (!resourceTreeModel || !frameIds) | 191 if (!resourceTreeModel || !frameIds) |
| 155 return []; | 192 return []; |
| 156 var frames = Array.from(frameIds).map(frameId => resourceTreeModel.frameForI
d(frameId)); | 193 var frames = Array.from(frameIds).map(frameId => resourceTreeModel.frameForI
d(frameId)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 186 return project; | 223 return project; |
| 187 | 224 |
| 188 project = new Bindings.ContentProviderBasedProject( | 225 project = new Bindings.ContentProviderBasedProject( |
| 189 this._workspace, projectId, projectType, '', false /* isServiceProject *
/); | 226 this._workspace, projectId, projectType, '', false /* isServiceProject *
/); |
| 190 project[Bindings.NetworkProject._targetSymbol] = this._target; | 227 project[Bindings.NetworkProject._targetSymbol] = this._target; |
| 191 this._workspaceProjects.set(projectId, project); | 228 this._workspaceProjects.set(projectId, project); |
| 192 return project; | 229 return project; |
| 193 } | 230 } |
| 194 | 231 |
| 195 /** | 232 /** |
| 196 * @param {!Common.ContentProvider} contentProvider | |
| 197 * @param {string} frameId | |
| 198 * @param {boolean} isContentScript | |
| 199 * @param {?number} contentSize | |
| 200 * @return {!Workspace.UISourceCode} | |
| 201 */ | |
| 202 addSourceMapFile(contentProvider, frameId, isContentScript, contentSize) { | |
| 203 var uiSourceCode = this._createFile(contentProvider, frameId, isContentScrip
t || false); | |
| 204 var metadata = typeof contentSize === 'number' ? new Workspace.UISourceCodeM
etadata(null, contentSize) : null; | |
| 205 this._addUISourceCodeWithProvider(uiSourceCode, contentProvider, metadata); | |
| 206 return uiSourceCode; | |
| 207 } | |
| 208 | |
| 209 /** | |
| 210 * @param {string} url | |
| 211 * @param {string} frameId | |
| 212 * @param {boolean} isContentScript | |
| 213 */ | |
| 214 removeSourceMapFile(url, frameId, isContentScript) { | |
| 215 this._removeFileForURL(url, frameId, isContentScript); | |
| 216 } | |
| 217 | |
| 218 /** | |
| 219 * @param {string} frameId | 233 * @param {string} frameId |
| 220 * @param {string} url | 234 * @param {string} url |
| 221 * @param {boolean} isContentScript | 235 * @param {boolean} isContentScript |
| 222 */ | 236 */ |
| 223 _removeFileForURL(url, frameId, isContentScript) { | 237 _removeFileForURL(url, frameId, isContentScript) { |
| 224 var project = | 238 var project = |
| 225 this._workspaceProjects.get(Bindings.NetworkProject.projectId(this._targ
et, frameId, isContentScript)); | 239 this._workspaceProjects.get(Bindings.NetworkProject.projectId(this._targ
et, frameId, isContentScript)); |
| 226 if (!project) | 240 if (!project) |
| 227 return; | 241 return; |
| 228 project.removeFile(url); | 242 project.removeFile(url); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 /** | 424 /** |
| 411 * @param {!Common.ContentProvider} contentProvider | 425 * @param {!Common.ContentProvider} contentProvider |
| 412 * @param {string} frameId | 426 * @param {string} frameId |
| 413 * @param {boolean} isContentScript | 427 * @param {boolean} isContentScript |
| 414 * @return {!Workspace.UISourceCode} | 428 * @return {!Workspace.UISourceCode} |
| 415 */ | 429 */ |
| 416 _createFile(contentProvider, frameId, isContentScript) { | 430 _createFile(contentProvider, frameId, isContentScript) { |
| 417 var url = contentProvider.contentURL(); | 431 var url = contentProvider.contentURL(); |
| 418 var project = this._workspaceProject(frameId, isContentScript); | 432 var project = this._workspaceProject(frameId, isContentScript); |
| 419 var uiSourceCode = project.createUISourceCode(url, contentProvider.contentTy
pe()); | 433 var uiSourceCode = project.createUISourceCode(url, contentProvider.contentTy
pe()); |
| 420 uiSourceCode[Bindings.NetworkProject._frameAttributionSymbol] = frameId; | 434 if (frameId) |
| 435 Bindings.NetworkProject.setInitialFrameAttribution(uiSourceCode, new Set([
frameId])); |
| 421 return uiSourceCode; | 436 return uiSourceCode; |
| 422 } | 437 } |
| 423 | 438 |
| 424 /** | 439 /** |
| 425 * @param {string} frameId | 440 * @param {string} frameId |
| 426 * @param {string} url | 441 * @param {string} url |
| 427 * @return {?Workspace.UISourceCodeMetadata} | 442 * @return {?Workspace.UISourceCodeMetadata} |
| 428 */ | 443 */ |
| 429 _fetchMetadata(frameId, url) { | 444 _fetchMetadata(frameId, url) { |
| 430 if (!this._resourceTreeModel) | 445 if (!this._resourceTreeModel) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 }; | 497 }; |
| 483 | 498 |
| 484 Bindings.NetworkProject._networkProjectSymbol = Symbol('networkProject'); | 499 Bindings.NetworkProject._networkProjectSymbol = Symbol('networkProject'); |
| 485 Bindings.NetworkProject._resourceSymbol = Symbol('resource'); | 500 Bindings.NetworkProject._resourceSymbol = Symbol('resource'); |
| 486 Bindings.NetworkProject._scriptSymbol = Symbol('script'); | 501 Bindings.NetworkProject._scriptSymbol = Symbol('script'); |
| 487 Bindings.NetworkProject._styleSheetSymbol = Symbol('styleSheet'); | 502 Bindings.NetworkProject._styleSheetSymbol = Symbol('styleSheet'); |
| 488 Bindings.NetworkProject._targetSymbol = Symbol('target'); | 503 Bindings.NetworkProject._targetSymbol = Symbol('target'); |
| 489 Bindings.NetworkProject._frameIdSymbol = Symbol('frameid'); | 504 Bindings.NetworkProject._frameIdSymbol = Symbol('frameid'); |
| 490 | 505 |
| 491 Bindings.NetworkProject._frameAttributionSymbol = Symbol('Bindings.NetworkProjec
t._frameAttributionSymbol'); | 506 Bindings.NetworkProject._frameAttributionSymbol = Symbol('Bindings.NetworkProjec
t._frameAttributionSymbol'); |
| OLD | NEW |