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

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

Issue 2833583003: DevTools: proper management of ResourceTreeModel in NetworkProject (Closed)
Patch Set: address comments Created 3 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/bindings/NetworkProject.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
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 /**
32 * @unrestricted
33 */
34 SDK.ResourceTreeModel = class extends SDK.SDKModel { 31 SDK.ResourceTreeModel = class extends SDK.SDKModel {
35 /** 32 /**
36 * @param {!SDK.Target} target 33 * @param {!SDK.Target} target
37 */ 34 */
38 constructor(target) { 35 constructor(target) {
39 super(target); 36 super(target);
40 37
41 var networkManager = target.model(SDK.NetworkManager); 38 var networkManager = target.model(SDK.NetworkManager);
42 if (networkManager) { 39 if (networkManager) {
43 networkManager.addEventListener(SDK.NetworkManager.Events.RequestFinished, this._onRequestFinished, this); 40 networkManager.addEventListener(SDK.NetworkManager.Events.RequestFinished, this._onRequestFinished, this);
44 networkManager.addEventListener( 41 networkManager.addEventListener(
45 SDK.NetworkManager.Events.RequestUpdateDropped, this._onRequestUpdateD ropped, this); 42 SDK.NetworkManager.Events.RequestUpdateDropped, this._onRequestUpdateD ropped, this);
46 } 43 }
47
48 this._agent = target.pageAgent(); 44 this._agent = target.pageAgent();
49 this._agent.enable(); 45 this._agent.enable();
50 this._securityOriginManager = target.model(SDK.SecurityOriginManager); 46 this._securityOriginManager = target.model(SDK.SecurityOriginManager);
51 47
52 this._fetchResourceTree();
53
54 target.registerPageDispatcher(new SDK.PageDispatcher(this)); 48 target.registerPageDispatcher(new SDK.PageDispatcher(this));
55 49
50 /** @type {!Map<string, !SDK.ResourceTreeFrame>} */
51 this._frames = new Map();
52 this._cachedResourcesProcessed = false;
56 this._pendingReloadOptions = null; 53 this._pendingReloadOptions = null;
57 this._reloadSuspensionCount = 0; 54 this._reloadSuspensionCount = 0;
58 this._isInterstitialShowing = false; 55 this._isInterstitialShowing = false;
56 /** @type {?SDK.ResourceTreeFrame} */
57 this.mainFrame = null;
58
59 this._agent.getResourceTree(this._processCachedResources.bind(this));
59 } 60 }
60 61
61 /** 62 /**
62 * @return {!Array.<!SDK.ResourceTreeFrame>} 63 * @return {!Array.<!SDK.ResourceTreeFrame>}
63 */ 64 */
64 static frames() { 65 static frames() {
65 var result = []; 66 var result = [];
66 for (var resourceTreeModel of SDK.targetManager.models(SDK.ResourceTreeModel )) 67 for (var resourceTreeModel of SDK.targetManager.models(SDK.ResourceTreeModel ))
67 result = result.concat(resourceTreeModel._frames.valuesArray()); 68 result = result.concat(resourceTreeModel._frames.valuesArray());
68 return result; 69 return result;
(...skipping 24 matching lines...) Expand all
93 } 94 }
94 } 95 }
95 96
96 /** 97 /**
97 * @return {!SDK.DOMModel} 98 * @return {!SDK.DOMModel}
98 */ 99 */
99 domModel() { 100 domModel() {
100 return /** @type {!SDK.DOMModel} */ (this.target().model(SDK.DOMModel)); 101 return /** @type {!SDK.DOMModel} */ (this.target().model(SDK.DOMModel));
101 } 102 }
102 103
103 _fetchResourceTree() {
104 /** @type {!Map<string, !SDK.ResourceTreeFrame>} */
105 this._frames = new Map();
106 this._cachedResourcesProcessed = false;
107 this._agent.getResourceTree(this._processCachedResources.bind(this));
108 }
109
110 _processCachedResources(error, mainFramePayload) { 104 _processCachedResources(error, mainFramePayload) {
111 if (!error) { 105 if (!error) {
112 this.dispatchEventToListeners(SDK.ResourceTreeModel.Events.WillLoadCachedR esources); 106 this.dispatchEventToListeners(SDK.ResourceTreeModel.Events.WillLoadCachedR esources);
113 this._addFramesRecursively(null, mainFramePayload); 107 this._addFramesRecursively(null, mainFramePayload);
114 this.target().setInspectedURL(mainFramePayload.frame.url); 108 this.target().setInspectedURL(mainFramePayload.frame.url);
115 } 109 }
116 this._cachedResourcesProcessed = true; 110 this._cachedResourcesProcessed = true;
117 var runtimeModel = this.target().model(SDK.RuntimeModel); 111 var runtimeModel = this.target().model(SDK.RuntimeModel);
118 if (runtimeModel) { 112 if (runtimeModel) {
119 runtimeModel.setExecutionContextComparator(this._executionContextComparato r.bind(this)); 113 runtimeModel.setExecutionContextComparator(this._executionContextComparato r.bind(this));
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 this._resourceTreeModel.dispatchEventToListeners(SDK.ResourceTreeModel.Event s.InterstitialHidden); 878 this._resourceTreeModel.dispatchEventToListeners(SDK.ResourceTreeModel.Event s.InterstitialHidden);
885 } 879 }
886 880
887 /** 881 /**
888 * @override 882 * @override
889 */ 883 */
890 navigationRequested() { 884 navigationRequested() {
891 // Frontend is not interested in when navigations are requested. 885 // Frontend is not interested in when navigations are requested.
892 } 886 }
893 }; 887 };
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/bindings/NetworkProject.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698