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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js

Issue 2122353002: [DevTools] Make resource tree model optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 5 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/sdk/ResourceTreeModel.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js
index ee1740897427e2e60afaa5464df1c447a10e45b1..c1a333726dcb6adad06384233539e826feb62236 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js
@@ -81,6 +81,13 @@ WebInspector.ResourceTreeModel.EventTypes = {
ColorPicked: "ColorPicked"
}
+/**
+ * @param {!WebInspector.Target} target
+ * @return {?WebInspector.ResourceTreeModel}
+ */
+WebInspector.ResourceTreeModel.fromTarget = function(target) {
+ return /** @type {?WebInspector.ResourceTreeModel} */ (target.model(WebInspector.ResourceTreeModel));
+}
/**
* @return {!Array.<!WebInspector.ResourceTreeFrame>}
@@ -88,8 +95,11 @@ WebInspector.ResourceTreeModel.EventTypes = {
WebInspector.ResourceTreeModel.frames = function()
{
var result = [];
- for (var target of WebInspector.targetManager.targets())
- result = result.concat(Object.values(target.resourceTreeModel._frames));
+ for (var target of WebInspector.targetManager.targets()) {
+ var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(target);
+ if (resourceTreeModel)
+ result = result.concat(Object.values(resourceTreeModel._frames));
+ }
return result;
}
@@ -100,7 +110,8 @@ WebInspector.ResourceTreeModel.frames = function()
WebInspector.ResourceTreeModel.resourceForURL = function(url)
{
for (var target of WebInspector.targetManager.targets()) {
- var mainFrame = target.resourceTreeModel.mainFrame;
+ var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(target);
+ var mainFrame = resourceTreeModel && resourceTreeModel.mainFrame;
var result = mainFrame ? mainFrame.resourceForURL(url) : null;
if (result)
return result;
@@ -571,6 +582,20 @@ WebInspector.ResourceTreeFrame = function(model, parentFrame, frameId, payload)
this._parentFrame._childFrames.push(this);
}
+
+/**
+ * @param {!WebInspector.ExecutionContext|!WebInspector.CSSStyleSheetHeader|!WebInspector.Resource} object
+ * @return {?WebInspector.ResourceTreeFrame}
+ */
+WebInspector.ResourceTreeFrame._fromObject = function(object)
+{
+ var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(object.target());
+ var frameId = object.frameId;
+ if (!resourceTreeModel || !frameId)
+ return null;
+ return resourceTreeModel.frameForId(frameId);
+}
+
/**
* @param {!WebInspector.Script} script
* @return {?WebInspector.ResourceTreeFrame}
@@ -578,9 +603,9 @@ WebInspector.ResourceTreeFrame = function(model, parentFrame, frameId, payload)
WebInspector.ResourceTreeFrame.fromScript = function(script)
{
var executionContext = script.executionContext();
- if (!executionContext || !executionContext.frameId)
+ if (!executionContext)
return null;
- return script.target().resourceTreeModel.frameForId(executionContext.frameId);
+ return WebInspector.ResourceTreeFrame._fromObject(executionContext);
}
/**
@@ -589,7 +614,7 @@ WebInspector.ResourceTreeFrame.fromScript = function(script)
*/
WebInspector.ResourceTreeFrame.fromStyleSheet = function(header)
{
- return header.target().resourceTreeModel.frameForId(header.frameId);
+ return WebInspector.ResourceTreeFrame._fromObject(header);
}
/**
@@ -598,7 +623,7 @@ WebInspector.ResourceTreeFrame.fromStyleSheet = function(header)
*/
WebInspector.ResourceTreeFrame.fromResource = function(resource)
{
- return resource.target().resourceTreeModel.frameForId(resource.frameId);
+ return WebInspector.ResourceTreeFrame._fromObject(resource);
}
WebInspector.ResourceTreeFrame.prototype = {

Powered by Google App Engine
This is Rietveld 408576698