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

Unified Diff: third_party/WebKit/Source/devtools/front_end/bindings/NetworkProject.js

Issue 2756103002: DevTools: remove SDK.ResourceTreeFrame.fromXXX methods (Closed)
Patch Set: remove unused code Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/bindings/NetworkProject.js
diff --git a/third_party/WebKit/Source/devtools/front_end/bindings/NetworkProject.js b/third_party/WebKit/Source/devtools/front_end/bindings/NetworkProject.js
index 0a58a730f1d9d1dfdd3e5fecc6ad05fe931ad5ab..e2ee4c92806eafaf14bf8c455084afd1b3053422 100644
--- a/third_party/WebKit/Source/devtools/front_end/bindings/NetworkProject.js
+++ b/third_party/WebKit/Source/devtools/front_end/bindings/NetworkProject.js
@@ -106,12 +106,12 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
/**
* @param {!SDK.Target} target
- * @param {?SDK.ResourceTreeFrame} frame
+ * @param {string} frameId
* @param {boolean} isContentScripts
* @return {string}
*/
- static projectId(target, frame, isContentScripts) {
- return target.id() + ':' + (frame ? frame.id : '') + ':' + (isContentScripts ? 'contentscripts' : '');
+ static projectId(target, frameId, isContentScripts) {
+ return target.id() + ':' + frameId + ':' + (isContentScripts ? 'contentscripts' : '');
}
/**
@@ -162,12 +162,12 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
}
/**
- * @param {?SDK.ResourceTreeFrame} frame
+ * @param {string} frameId
* @param {boolean} isContentScripts
* @return {!Bindings.ContentProviderBasedProject}
*/
- _workspaceProject(frame, isContentScripts) {
- var projectId = Bindings.NetworkProject.projectId(this.target(), frame, isContentScripts);
+ _workspaceProject(frameId, isContentScripts) {
+ var projectId = Bindings.NetworkProject.projectId(this.target(), frameId, isContentScripts);
var projectType = isContentScripts ? Workspace.projectTypes.ContentScripts : Workspace.projectTypes.Network;
var project = this._workspaceProjects.get(projectId);
@@ -177,31 +177,32 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
project = new Bindings.ContentProviderBasedProject(
this._workspace, projectId, projectType, '', false /* isServiceProject */);
project[Bindings.NetworkProject._targetSymbol] = this.target();
- project[Bindings.NetworkProject._frameSymbol] = frame;
+ project[Bindings.NetworkProject._frameSymbol] =
+ frameId && this._resourceTreeModel ? this._resourceTreeModel.frameForId(frameId) : null;
this._workspaceProjects.set(projectId, project);
return project;
}
/**
* @param {!Common.ContentProvider} contentProvider
- * @param {?SDK.ResourceTreeFrame} frame
+ * @param {string} frameId
* @param {boolean} isContentScript
* @param {?number} contentSize
* @return {!Workspace.UISourceCode}
*/
- addSourceMapFile(contentProvider, frame, isContentScript, contentSize) {
- var uiSourceCode = this._createFile(contentProvider, frame, isContentScript || false);
+ addSourceMapFile(contentProvider, frameId, isContentScript, contentSize) {
+ var uiSourceCode = this._createFile(contentProvider, frameId, isContentScript || false);
var metadata = typeof contentSize === 'number' ? new Workspace.UISourceCodeMetadata(null, contentSize) : null;
this._addUISourceCodeWithProvider(uiSourceCode, contentProvider, metadata);
return uiSourceCode;
}
/**
- * @param {?SDK.ResourceTreeFrame} frame
+ * @param {string} frameId
* @param {string} url
*/
- _removeFileForURL(frame, url) {
- var project = this._workspaceProjects.get(Bindings.NetworkProject.projectId(this.target(), frame, false));
+ _removeFileForURL(frameId, url) {
+ var project = this._workspaceProjects.get(Bindings.NetworkProject.projectId(this.target(), frameId, false));
if (!project)
return;
project.removeFile(url);
@@ -251,8 +252,9 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
return;
}
var originalContentProvider = script.originalContentProvider();
- var uiSourceCode =
- this._createFile(originalContentProvider, SDK.ResourceTreeFrame.fromScript(script), script.isContentScript());
+ var executionContext = script.executionContext();
+ var frameId = executionContext ? executionContext.frameId || '' : '';
+ var uiSourceCode = this._createFile(originalContentProvider, frameId, script.isContentScript());
uiSourceCode[Bindings.NetworkProject._scriptSymbol] = script;
var resource = SDK.ResourceTreeModel.resourceForURL(uiSourceCode.url());
this._addUISourceCodeWithProvider(uiSourceCode, originalContentProvider, this._resourceMetadata(resource));
@@ -269,7 +271,7 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
return;
var originalContentProvider = header.originalContentProvider();
- var uiSourceCode = this._createFile(originalContentProvider, SDK.ResourceTreeFrame.fromStyleSheet(header), false);
+ var uiSourceCode = this._createFile(originalContentProvider, header.frameId, false);
uiSourceCode[Bindings.NetworkProject._styleSheetSymbol] = header;
var resource = SDK.ResourceTreeModel.resourceForURL(uiSourceCode.url());
this._addUISourceCodeWithProvider(uiSourceCode, originalContentProvider, this._resourceMetadata(resource));
@@ -283,7 +285,7 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
if (header.isInline && !header.hasSourceURL && header.origin !== 'inspector')
return;
- this._removeFileForURL(SDK.ResourceTreeFrame.fromStyleSheet(header), header.resourceURL());
+ this._removeFileForURL(header.frameId, header.resourceURL());
}
/**
@@ -314,14 +316,13 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
resource.contentURL().startsWith('data:'))
return;
- var frame = SDK.ResourceTreeFrame.fromResource(resource);
// Never load document twice.
- var projectId = Bindings.NetworkProject.projectId(this.target(), frame, false);
+ var projectId = Bindings.NetworkProject.projectId(this.target(), resource.frameId, false);
var project = this._workspaceProjects.get(projectId);
if (project && project.uiSourceCodeForURL(resource.url))
return;
- var uiSourceCode = this._createFile(resource, frame, false);
+ var uiSourceCode = this._createFile(resource, resource.frameId, false);
uiSourceCode[Bindings.NetworkProject._resourceSymbol] = resource;
this._addUISourceCodeWithProvider(uiSourceCode, resource, this._resourceMetadata(resource));
}
@@ -330,10 +331,10 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
* @param {!SDK.ResourceTreeFrame} frame
*/
_removeFrameResources(frame) {
- var project = this._workspaceProject(frame, false);
+ var project = this._workspaceProject(frame.id, false);
for (var resource of frame.resources())
project.removeUISourceCode(resource.url);
- project = this._workspaceProject(frame, true);
+ project = this._workspaceProject(frame.id, true);
for (var resource of frame.resources())
project.removeUISourceCode(resource.url);
}
@@ -370,13 +371,13 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
/**
* @param {!Common.ContentProvider} contentProvider
- * @param {?SDK.ResourceTreeFrame} frame
+ * @param {string} frameId
* @param {boolean} isContentScript
* @return {!Workspace.UISourceCode}
*/
- _createFile(contentProvider, frame, isContentScript) {
+ _createFile(contentProvider, frameId, isContentScript) {
var url = contentProvider.contentURL();
- var project = this._workspaceProject(frame, isContentScript);
+ var project = this._workspaceProject(frameId, isContentScript);
var uiSourceCode = project.createUISourceCode(url, contentProvider.contentType());
uiSourceCode[Bindings.NetworkProject._targetSymbol] = this.target();
return uiSourceCode;
@@ -412,9 +413,10 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
*/
static uiSourceCodeForScriptURL(workspace, url, script) {
var target = script.debuggerModel.target();
- var frame = SDK.ResourceTreeFrame.fromScript(script);
- return workspace.uiSourceCode(Bindings.NetworkProject.projectId(target, frame, false), url) ||
- workspace.uiSourceCode(Bindings.NetworkProject.projectId(target, frame, true), url);
+ var executionContext = script.executionContext();
+ var frameId = executionContext ? executionContext.frameId || '' : '';
+ return workspace.uiSourceCode(Bindings.NetworkProject.projectId(target, frameId, false), url) ||
+ workspace.uiSourceCode(Bindings.NetworkProject.projectId(target, frameId, true), url);
}
/**
@@ -424,8 +426,7 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
* @return {?Workspace.UISourceCode}
*/
static uiSourceCodeForStyleURL(workspace, url, header) {
- var frame = SDK.ResourceTreeFrame.fromStyleSheet(header);
- return workspace.uiSourceCode(Bindings.NetworkProject.projectId(header.target(), frame, false), url);
+ return workspace.uiSourceCode(Bindings.NetworkProject.projectId(header.target(), header.frameId, false), url);
}
};

Powered by Google App Engine
This is Rietveld 408576698