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

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: Created 3 years, 8 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 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 this.mainFrame = null;
57
58 this._fetchResourceTree();
59 } 59 }
60 60
61 /** 61 /**
62 * @return {!Array.<!SDK.ResourceTreeFrame>} 62 * @return {!Array.<!SDK.ResourceTreeFrame>}
63 */ 63 */
64 static frames() { 64 static frames() {
65 var result = []; 65 var result = [];
66 for (var resourceTreeModel of SDK.targetManager.models(SDK.ResourceTreeModel )) 66 for (var resourceTreeModel of SDK.targetManager.models(SDK.ResourceTreeModel ))
67 result = result.concat(resourceTreeModel._frames.valuesArray()); 67 result = result.concat(resourceTreeModel._frames.valuesArray());
68 return result; 68 return result;
(...skipping 25 matching lines...) Expand all
94 } 94 }
95 95
96 /** 96 /**
97 * @return {!SDK.DOMModel} 97 * @return {!SDK.DOMModel}
98 */ 98 */
99 domModel() { 99 domModel() {
100 return /** @type {!SDK.DOMModel} */ (this.target().model(SDK.DOMModel)); 100 return /** @type {!SDK.DOMModel} */ (this.target().model(SDK.DOMModel));
101 } 101 }
102 102
103 _fetchResourceTree() { 103 _fetchResourceTree() {
104 /** @type {!Map<string, !SDK.ResourceTreeFrame>} */
105 this._frames = new Map(); 104 this._frames = new Map();
dgozman 2017/04/20 17:23:17 You can just remove this - it's only called from c
lushnikov 2017/04/21 00:51:27 it is also called from test - i preferred to keep
106 this._cachedResourcesProcessed = false; 105 this._cachedResourcesProcessed = false;
107 this._agent.getResourceTree(this._processCachedResources.bind(this)); 106 this._agent.getResourceTree(this._processCachedResources.bind(this));
108 } 107 }
109 108
110 _processCachedResources(error, mainFramePayload) { 109 _processCachedResources(error, mainFramePayload) {
111 if (!error) { 110 if (!error) {
112 this.dispatchEventToListeners(SDK.ResourceTreeModel.Events.WillLoadCachedR esources); 111 this.dispatchEventToListeners(SDK.ResourceTreeModel.Events.WillLoadCachedR esources);
113 this._addFramesRecursively(null, mainFramePayload); 112 this._addFramesRecursively(null, mainFramePayload);
114 this.target().setInspectedURL(mainFramePayload.frame.url); 113 this.target().setInspectedURL(mainFramePayload.frame.url);
115 } 114 }
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 this._resourceTreeModel.dispatchEventToListeners(SDK.ResourceTreeModel.Event s.InterstitialHidden); 882 this._resourceTreeModel.dispatchEventToListeners(SDK.ResourceTreeModel.Event s.InterstitialHidden);
884 } 883 }
885 884
886 /** 885 /**
887 * @override 886 * @override
888 */ 887 */
889 navigationRequested() { 888 navigationRequested() {
890 // Frontend is not interested in when navigations are requested. 889 // Frontend is not interested in when navigations are requested.
891 } 890 }
892 }; 891 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698