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

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

Issue 2736393002: DevTools: split network project into buckets (Closed)
Patch Set: fix tests 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
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/sources/debugger/navigator-view.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 19a97cfbe7ff2d1d72afca49e3875ac2078e7612..ca6f7c57a9c8d1dfee85c86b9ffab389777b579a 100644
--- a/third_party/WebKit/Source/devtools/front_end/bindings/NetworkProject.js
+++ b/third_party/WebKit/Source/devtools/front_end/bindings/NetworkProject.js
@@ -107,11 +107,11 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
/**
* @param {!SDK.Target} target
* @param {?SDK.ResourceTreeFrame} frame
- * @param {boolean} isContentScripts
+ * @param {string} bucketType
* @return {string}
*/
- static projectId(target, frame, isContentScripts) {
- return target.id() + ':' + (frame ? frame.id : '') + ':' + (isContentScripts ? 'contentscripts' : '');
+ static projectId(target, frame, bucketType) {
+ return target.id() + ':' + (frame ? frame.id : '') + ':' + bucketType;
}
/**
@@ -163,12 +163,14 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
/**
* @param {?SDK.ResourceTreeFrame} frame
- * @param {boolean} isContentScripts
+ * @param {string} bucketType
* @return {!Bindings.ContentProviderBasedProject}
*/
- _workspaceProject(frame, isContentScripts) {
- var projectId = Bindings.NetworkProject.projectId(this.target(), frame, isContentScripts);
- var projectType = isContentScripts ? Workspace.projectTypes.ContentScripts : Workspace.projectTypes.Network;
+ _workspaceProject(frame, bucketType) {
+ var projectId = Bindings.NetworkProject.projectId(this.target(), frame, bucketType);
+ var isContentScriptBucket = bucketType === Bindings.ProjectBuckets.ContentScriptsBucket ||
+ bucketType === Bindings.ProjectBuckets.SourceMapContentScriptsBucket;
+ var projectType = isContentScriptBucket ? Workspace.projectTypes.ContentScripts : Workspace.projectTypes.Network;
var project = this._workspaceProjects.get(projectId);
if (project)
@@ -178,6 +180,7 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
this._workspace, projectId, projectType, '', false /* isServiceProject */);
project[Bindings.NetworkProject._targetSymbol] = this.target();
project[Bindings.NetworkProject._frameSymbol] = frame;
+ project[Bindings.NetworkProject._bucketSymbol] = bucketType;
this._workspaceProjects.set(projectId, project);
return project;
}
@@ -190,7 +193,9 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
* @return {!Workspace.UISourceCode}
*/
addFile(contentProvider, frame, isContentScript, contentSize) {
- var uiSourceCode = this._createFile(contentProvider, frame, isContentScript || false);
+ var bucketType = isContentScript ? Bindings.ProjectBuckets.SourceMapContentScriptsBucket :
+ Bindings.ProjectBuckets.SourceMapBucket;
+ var uiSourceCode = this._createFile(contentProvider, frame, bucketType);
var metadata = typeof contentSize === 'number' ? new Workspace.UISourceCodeMetadata(null, contentSize) : null;
this._addUISourceCodeWithProvider(uiSourceCode, contentProvider, metadata);
return uiSourceCode;
@@ -199,15 +204,16 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
/**
* @param {?SDK.ResourceTreeFrame} frame
* @param {string} url
+ * @param {string} bucketType
*/
- _removeFileForURL(frame, url) {
- var project = this._workspaceProjects.get(Bindings.NetworkProject.projectId(this.target(), frame, false));
+ _removeFileForURL(frame, url, bucketType) {
+ var project = this._workspaceProjects.get(Bindings.NetworkProject.projectId(this.target(), frame, bucketType));
if (!project)
return;
project.removeFile(url);
}
- _populate() {
+ _populateResources() {
/**
* @param {!SDK.ResourceTreeFrame} frame
* @this {Bindings.NetworkProject}
@@ -251,8 +257,9 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
return;
}
var originalContentProvider = script.originalContentProvider();
- var uiSourceCode =
- this._createFile(originalContentProvider, SDK.ResourceTreeFrame.fromScript(script), script.isContentScript());
+ var bucketType = script.isContentScript() ? Bindings.ProjectBuckets.ContentScriptsBucket :
+ Bindings.ProjectBuckets.RegularScriptsBucket;
+ var uiSourceCode = this._createFile(originalContentProvider, SDK.ResourceTreeFrame.fromScript(script), bucketType);
uiSourceCode[Bindings.NetworkProject._scriptSymbol] = script;
var resource = SDK.ResourceTreeModel.resourceForURL(uiSourceCode.url());
this._addUISourceCodeWithProvider(uiSourceCode, originalContentProvider, this._resourceMetadata(resource));
@@ -269,7 +276,9 @@ 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, SDK.ResourceTreeFrame.fromStyleSheet(header),
+ Bindings.ProjectBuckets.StyleSheetsBucket);
uiSourceCode[Bindings.NetworkProject._styleSheetSymbol] = header;
var resource = SDK.ResourceTreeModel.resourceForURL(uiSourceCode.url());
this._addUISourceCodeWithProvider(uiSourceCode, originalContentProvider, this._resourceMetadata(resource));
@@ -283,7 +292,8 @@ 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(
+ SDK.ResourceTreeFrame.fromStyleSheet(header), header.resourceURL(), Bindings.ProjectBuckets.StyleSheetsBucket);
}
/**
@@ -316,12 +326,12 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
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(), frame, Bindings.ProjectBuckets.ResourcesBucket);
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, frame, Bindings.ProjectBuckets.ResourcesBucket);
uiSourceCode[Bindings.NetworkProject._resourceSymbol] = resource;
this._addUISourceCodeWithProvider(uiSourceCode, resource, this._resourceMetadata(resource));
}
@@ -330,12 +340,17 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
* @param {!SDK.ResourceTreeFrame} frame
*/
_removeFrameResources(frame) {
- var project = this._workspaceProject(frame, false);
- for (var resource of frame.resources())
- project.removeUISourceCode(resource.url);
- project = this._workspaceProject(frame, true);
- for (var resource of frame.resources())
- project.removeUISourceCode(resource.url);
+ // TODO(lushnikov): this method should clean up only ResourcesBucket.
+ var projects = [
+ this._workspaceProject(frame, Bindings.ProjectBuckets.ResourcesBucket),
+ this._workspaceProject(frame, Bindings.ProjectBuckets.ContentScriptsBucket),
+ this._workspaceProject(frame, Bindings.ProjectBuckets.RegularScriptsBucket),
+ this._workspaceProject(frame, Bindings.ProjectBuckets.StyleSheetsBucket),
+ ];
+ for (var resource of frame.resources()) {
+ for (var project of projects)
+ project.removeUISourceCode(resource.url);
+ }
}
/**
@@ -358,25 +373,25 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
* @param {!Common.Event} event
*/
_mainFrameNavigated(event) {
- this._reset();
+ this._resetResources();
}
_suspendStateChanged() {
if (this.target().targetManager().allTargetsSuspended())
- this._reset();
+ this._resetResources();
else
- this._populate();
+ this._populateResources();
}
/**
* @param {!Common.ContentProvider} contentProvider
* @param {?SDK.ResourceTreeFrame} frame
- * @param {boolean} isContentScript
+ * @param {string} bucketType
* @return {!Workspace.UISourceCode}
*/
- _createFile(contentProvider, frame, isContentScript) {
+ _createFile(contentProvider, frame, bucketType) {
var url = contentProvider.contentURL();
- var project = this._workspaceProject(frame, isContentScript);
+ var project = this._workspaceProject(frame, bucketType);
var uiSourceCode = project.createUISourceCode(url, contentProvider.contentType());
uiSourceCode[Bindings.NetworkProject._targetSymbol] = this.target();
return uiSourceCode;
@@ -393,15 +408,28 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
}
_dispose() {
- this._reset();
+ for (var project of this._workspaceProjects.values())
+ project.removeProject();
Common.EventTarget.removeEventListeners(this._eventListeners);
delete this.target()[Bindings.NetworkProject._networkProjectSymbol];
}
- _reset() {
- for (var project of this._workspaceProjects.values())
- project.removeProject();
- this._workspaceProjects.clear();
+ _resetResources() {
+ // TODO(lushnikov): this method should clean up only ResourcesBucket.
+ for (var projectId of this._workspaceProjects.keys()) {
+ var project = this._workspaceProjects.get(projectId);
+ switch (project[Bindings.NetworkProject._bucketSymbol]) {
+ case Bindings.ProjectBuckets.ResourcesBucket:
+ case Bindings.ProjectBuckets.ContentScriptsBucket:
+ case Bindings.ProjectBuckets.RegularScriptsBucket:
+ case Bindings.ProjectBuckets.StyleSheetsBucket:
+ case Bindings.ProjectBuckets.SourceMapBucket:
+ case Bindings.ProjectBuckets.SourceMapContentScriptsBucket:
+ project.removeProject();
+ this._workspaceProjects.delete(projectId);
+ break;
+ }
+ }
}
/**
@@ -411,10 +439,24 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
* @return {?Workspace.UISourceCode}
*/
static uiSourceCodeForScriptURL(workspace, url, script) {
+ var buckets = [];
+ if (script.isContentScript()) {
+ buckets = [Bindings.ProjectBuckets.SourceMapContentScriptsBucket, Bindings.ProjectBuckets.ContentScriptsBucket];
+ } else {
+ buckets = [
+ Bindings.ProjectBuckets.SourceMapBucket, Bindings.ProjectBuckets.RegularScriptsBucket,
+ Bindings.ProjectBuckets.ResourcesBucket
+ ];
+ }
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 projectIds = buckets.map(bucket => Bindings.NetworkProject.projectId(target, frame, bucket));
+ for (var projectId of projectIds) {
+ var uiSourceCode = workspace.uiSourceCode(projectId, url);
+ if (uiSourceCode)
+ return uiSourceCode;
+ }
+ return null;
}
/**
@@ -424,14 +466,36 @@ Bindings.NetworkProject = class extends SDK.SDKObject {
* @return {?Workspace.UISourceCode}
*/
static uiSourceCodeForStyleURL(workspace, url, header) {
+ var buckets = [
+ Bindings.ProjectBuckets.SourceMapBucket, Bindings.ProjectBuckets.StyleSheetsBucket,
+ Bindings.ProjectBuckets.ResourcesBucket
+ ];
var frame = SDK.ResourceTreeFrame.fromStyleSheet(header);
- return workspace.uiSourceCode(Bindings.NetworkProject.projectId(header.target(), frame, false), url);
+ var target = header.target();
+ var projectIds = buckets.map(bucket => Bindings.NetworkProject.projectId(target, frame, bucket));
+ for (var projectId of projectIds) {
+ var uiSourceCode = workspace.uiSourceCode(projectId, url);
+ if (uiSourceCode)
+ return uiSourceCode;
+ }
+ return null;
}
};
+/** @enum {string} */
+Bindings.ProjectBuckets = {
+ ResourcesBucket: 'ResourcesBucket',
+ ContentScriptsBucket: 'ContentScriptsBucket',
+ RegularScriptsBucket: 'RegularScriptsBucket',
+ StyleSheetsBucket: 'StyleSheetsBucket',
+ SourceMapBucket: 'SourceMapBucket',
+ SourceMapContentScriptsBucket: 'SourceMapContentScriptsBucket',
+};
+
Bindings.NetworkProject._networkProjectSymbol = Symbol('networkProject');
Bindings.NetworkProject._resourceSymbol = Symbol('resource');
Bindings.NetworkProject._scriptSymbol = Symbol('script');
Bindings.NetworkProject._styleSheetSymbol = Symbol('styleSheet');
Bindings.NetworkProject._targetSymbol = Symbol('target');
Bindings.NetworkProject._frameSymbol = Symbol('frame');
+Bindings.NetworkProject._bucketSymbol = Symbol('bucket');
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/sources/debugger/navigator-view.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698