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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 PageReloadRequested: "PageReloadRequested", 72 PageReloadRequested: "PageReloadRequested",
73 WillReloadPage: "WillReloadPage", 73 WillReloadPage: "WillReloadPage",
74 InspectedURLChanged: "InspectedURLChanged", 74 InspectedURLChanged: "InspectedURLChanged",
75 SecurityOriginAdded: "SecurityOriginAdded", 75 SecurityOriginAdded: "SecurityOriginAdded",
76 SecurityOriginRemoved: "SecurityOriginRemoved", 76 SecurityOriginRemoved: "SecurityOriginRemoved",
77 ScreencastFrame: "ScreencastFrame", 77 ScreencastFrame: "ScreencastFrame",
78 ScreencastVisibilityChanged: "ScreencastVisibilityChanged", 78 ScreencastVisibilityChanged: "ScreencastVisibilityChanged",
79 ColorPicked: "ColorPicked" 79 ColorPicked: "ColorPicked"
80 } 80 }
81 81
82 /**
83 * @param {!WebInspector.Target} target
84 * @return {?WebInspector.ResourceTreeModel}
85 */
86 WebInspector.ResourceTreeModel.fromTarget = function(target) {
87 return /** @type {?WebInspector.ResourceTreeModel} */ (target.model(WebInspe ctor.ResourceTreeModel));
88 }
82 89
83 /** 90 /**
84 * @return {!Array.<!WebInspector.ResourceTreeFrame>} 91 * @return {!Array.<!WebInspector.ResourceTreeFrame>}
85 */ 92 */
86 WebInspector.ResourceTreeModel.frames = function() 93 WebInspector.ResourceTreeModel.frames = function()
87 { 94 {
88 var result = []; 95 var result = [];
89 for (var target of WebInspector.targetManager.targets()) 96 for (var target of WebInspector.targetManager.targets()) {
90 result = result.concat(Object.values(target.resourceTreeModel._frames)); 97 var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(target );
98 if (resourceTreeModel)
99 result = result.concat(Object.values(resourceTreeModel._frames));
100 }
91 return result; 101 return result;
92 } 102 }
93 103
94 /** 104 /**
95 * @param {string} url 105 * @param {string} url
96 * @return {?WebInspector.Resource} 106 * @return {?WebInspector.Resource}
97 */ 107 */
98 WebInspector.ResourceTreeModel.resourceForURL = function(url) 108 WebInspector.ResourceTreeModel.resourceForURL = function(url)
99 { 109 {
100 for (var target of WebInspector.targetManager.targets()) { 110 for (var target of WebInspector.targetManager.targets()) {
101 var mainFrame = target.resourceTreeModel.mainFrame; 111 var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(target );
112 var mainFrame = resourceTreeModel && resourceTreeModel.mainFrame;
102 var result = mainFrame ? mainFrame.resourceForURL(url) : null; 113 var result = mainFrame ? mainFrame.resourceForURL(url) : null;
103 if (result) 114 if (result)
104 return result; 115 return result;
105 } 116 }
106 return null; 117 return null;
107 } 118 }
108 119
109 WebInspector.ResourceTreeModel.prototype = { 120 WebInspector.ResourceTreeModel.prototype = {
110 _fetchResourceTree: function() 121 _fetchResourceTree: function()
111 { 122 {
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 530
520 /** 531 /**
521 * @type {!Object.<string, !WebInspector.Resource>} 532 * @type {!Object.<string, !WebInspector.Resource>}
522 */ 533 */
523 this._resourcesMap = {}; 534 this._resourcesMap = {};
524 535
525 if (this._parentFrame) 536 if (this._parentFrame)
526 this._parentFrame._childFrames.push(this); 537 this._parentFrame._childFrames.push(this);
527 } 538 }
528 539
540
541 /**
542 * @param {!WebInspector.ExecutionContext|!WebInspector.CSSStyleSheetHeader|!Web Inspector.Resource} object
543 * @return {?WebInspector.ResourceTreeFrame}
544 */
545 WebInspector.ResourceTreeFrame._fromObject = function(object)
546 {
547 var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(object.tar get());
548 var frameId = object.frameId;
549 if (!resourceTreeModel || !frameId)
550 return null;
551 return resourceTreeModel.frameForId(frameId);
552 }
553
529 /** 554 /**
530 * @param {!WebInspector.Script} script 555 * @param {!WebInspector.Script} script
531 * @return {?WebInspector.ResourceTreeFrame} 556 * @return {?WebInspector.ResourceTreeFrame}
532 */ 557 */
533 WebInspector.ResourceTreeFrame.fromScript = function(script) 558 WebInspector.ResourceTreeFrame.fromScript = function(script)
534 { 559 {
535 var executionContext = script.executionContext(); 560 var executionContext = script.executionContext();
536 if (!executionContext || !executionContext.frameId) 561 if (!executionContext)
537 return null; 562 return null;
538 return script.target().resourceTreeModel.frameForId(executionContext.frameId ); 563 return WebInspector.ResourceTreeFrame._fromObject(executionContext);
539 } 564 }
540 565
541 /** 566 /**
542 * @param {!WebInspector.CSSStyleSheetHeader} header 567 * @param {!WebInspector.CSSStyleSheetHeader} header
543 * @return {?WebInspector.ResourceTreeFrame} 568 * @return {?WebInspector.ResourceTreeFrame}
544 */ 569 */
545 WebInspector.ResourceTreeFrame.fromStyleSheet = function(header) 570 WebInspector.ResourceTreeFrame.fromStyleSheet = function(header)
546 { 571 {
547 return header.target().resourceTreeModel.frameForId(header.frameId); 572 return WebInspector.ResourceTreeFrame._fromObject(header);
548 } 573 }
549 574
550 /** 575 /**
551 * @param {!WebInspector.Resource} resource 576 * @param {!WebInspector.Resource} resource
552 * @return {?WebInspector.ResourceTreeFrame} 577 * @return {?WebInspector.ResourceTreeFrame}
553 */ 578 */
554 WebInspector.ResourceTreeFrame.fromResource = function(resource) 579 WebInspector.ResourceTreeFrame.fromResource = function(resource)
555 { 580 {
556 return resource.target().resourceTreeModel.frameForId(resource.frameId); 581 return WebInspector.ResourceTreeFrame._fromObject(resource);
557 } 582 }
558 583
559 WebInspector.ResourceTreeFrame.prototype = { 584 WebInspector.ResourceTreeFrame.prototype = {
560 /** 585 /**
561 * @return {!WebInspector.Target} 586 * @return {!WebInspector.Target}
562 */ 587 */
563 target: function() 588 target: function()
564 { 589 {
565 return this._model.target(); 590 return this._model.target();
566 }, 591 },
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 }, 951 },
927 952
928 /** 953 /**
929 * @override 954 * @override
930 */ 955 */
931 interstitialHidden: function() 956 interstitialHidden: function()
932 { 957 {
933 // Frontend is not interested in interstitials. 958 // Frontend is not interested in interstitials.
934 } 959 }
935 } 960 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698