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

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

Issue 2616023003: [Devtools] Reverse dependency of ResourceTreeModel and NetworkLog (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js » ('j') | 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 16 matching lines...) Expand all
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 /** 31 /**
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 SDK.NetworkLog = class extends SDK.SDKModel { 34 SDK.NetworkLog = class extends SDK.SDKModel {
35 /** 35 /**
36 * @param {!SDK.Target} target 36 * @param {!SDK.Target} target
37 * @param {!SDK.ResourceTreeModel} resourceTreeModel
38 * @param {!SDK.NetworkManager} networkManager 37 * @param {!SDK.NetworkManager} networkManager
39 */ 38 */
40 constructor(target, resourceTreeModel, networkManager) { 39 constructor(target, networkManager) {
41 super(SDK.NetworkLog, target); 40 super(SDK.NetworkLog, target);
42 41
43 this._requests = []; 42 this._requests = [];
44 this._requestForId = {}; 43 this._requestForId = {};
45 networkManager.addEventListener(SDK.NetworkManager.Events.RequestStarted, th is._onRequestStarted, this); 44 networkManager.addEventListener(SDK.NetworkManager.Events.RequestStarted, th is._onRequestStarted, this);
46 resourceTreeModel.addEventListener(
47 SDK.ResourceTreeModel.Events.MainFrameNavigated, this._onMainFrameNaviga ted, this);
48 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.Load, this._ onLoad, this);
49 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.DOMContentLo aded, this._onDOMContentLoaded, this);
50 } 45 }
51 46
52 /** 47 /**
53 * @param {!SDK.Target} target 48 * @param {!SDK.Target} target
54 * @return {?SDK.NetworkLog} 49 * @return {?SDK.NetworkLog}
55 */ 50 */
56 static fromTarget(target) { 51 static fromTarget(target) {
57 return target.model(SDK.NetworkLog); 52 return target.model(SDK.NetworkLog);
58 } 53 }
59 54
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 100
106 /** 101 /**
107 * @param {!SDK.NetworkRequest} request 102 * @param {!SDK.NetworkRequest} request
108 * @return {!SDK.PageLoad} 103 * @return {!SDK.PageLoad}
109 */ 104 */
110 pageLoadForRequest(request) { 105 pageLoadForRequest(request) {
111 return request.__page; 106 return request.__page;
112 } 107 }
113 108
114 /** 109 /**
115 * @param {!Common.Event} event 110 * @param {!SDK.ResourceTreeFrame} mainFrame
116 */ 111 */
117 _onMainFrameNavigated(event) { 112 mainFrameNavigated(mainFrame) {
caseq 2017/01/06 01:40:48 Let's take this one step further and make sure Net
118 var mainFrame = /** type {SDK.ResourceTreeFrame} */ event.data;
119 // Preserve requests from the new session. 113 // Preserve requests from the new session.
120 this._currentPageLoad = null; 114 this._currentPageLoad = null;
121 var oldRequests = this._requests.splice(0, this._requests.length); 115 var oldRequests = this._requests.splice(0, this._requests.length);
122 this._requestForId = {}; 116 this._requestForId = {};
123 for (var i = 0; i < oldRequests.length; ++i) { 117 for (var i = 0; i < oldRequests.length; ++i) {
124 var request = oldRequests[i]; 118 var request = oldRequests[i];
125 if (request.loaderId === mainFrame.loaderId) { 119 if (request.loaderId === mainFrame.loaderId) {
126 if (!this._currentPageLoad) 120 if (!this._currentPageLoad)
127 this._currentPageLoad = new SDK.PageLoad(request); 121 this._currentPageLoad = new SDK.PageLoad(request);
128 this._requests.push(request); 122 this._requests.push(request);
129 this._requestForId[request.requestId] = request; 123 this._requestForId[request.requestId] = request;
130 request.__page = this._currentPageLoad; 124 request.__page = this._currentPageLoad;
131 } 125 }
132 } 126 }
133 } 127 }
134 128
135 /** 129 /**
136 * @param {!Common.Event} event 130 * @param {!Common.Event} event
137 */ 131 */
138 _onRequestStarted(event) { 132 _onRequestStarted(event) {
139 var request = /** @type {!SDK.NetworkRequest} */ (event.data); 133 var request = /** @type {!SDK.NetworkRequest} */ (event.data);
140 this._requests.push(request); 134 this._requests.push(request);
141 this._requestForId[request.requestId] = request; 135 this._requestForId[request.requestId] = request;
142 request.__page = this._currentPageLoad; 136 request.__page = this._currentPageLoad;
143 } 137 }
144 138
145 /** 139 /**
146 * @param {!Common.Event} event 140 * @param {number} time
147 */ 141 */
148 _onDOMContentLoaded(event) { 142 domContentLoaded(time) {
caseq 2017/01/06 01:40:48 ditto.
149 if (this._currentPageLoad) 143 if (this._currentPageLoad)
150 this._currentPageLoad.contentLoadTime = event.data; 144 this._currentPageLoad.contentLoadTime = time;
151 } 145 }
152 146
153 /** 147 /**
154 * @param {!Common.Event} event 148 * @param {number} time
155 */ 149 */
156 _onLoad(event) { 150 pageLoaded(time) {
caseq 2017/01/06 01:40:48 ditto.
157 if (this._currentPageLoad) 151 if (this._currentPageLoad)
158 this._currentPageLoad.loadTime = event.data; 152 this._currentPageLoad.loadTime = time;
159 } 153 }
160 154
161 /** 155 /**
162 * @param {!Protocol.Network.RequestId} requestId 156 * @param {!Protocol.Network.RequestId} requestId
163 * @return {?SDK.NetworkRequest} 157 * @return {?SDK.NetworkRequest}
164 */ 158 */
165 requestForId(requestId) { 159 requestForId(requestId) {
166 return this._requestForId[requestId]; 160 return this._requestForId[requestId];
167 } 161 }
168 }; 162 };
169 163
170 164
171 /** 165 /**
172 * @unrestricted 166 * @unrestricted
173 */ 167 */
174 SDK.PageLoad = class { 168 SDK.PageLoad = class {
175 /** 169 /**
176 * @param {!SDK.NetworkRequest} mainRequest 170 * @param {!SDK.NetworkRequest} mainRequest
177 */ 171 */
178 constructor(mainRequest) { 172 constructor(mainRequest) {
179 this.id = ++SDK.PageLoad._lastIdentifier; 173 this.id = ++SDK.PageLoad._lastIdentifier;
180 this.url = mainRequest.url; 174 this.url = mainRequest.url;
181 this.startTime = mainRequest.startTime; 175 this.startTime = mainRequest.startTime;
182 } 176 }
183 }; 177 };
184 178
185 SDK.PageLoad._lastIdentifier = 0; 179 SDK.PageLoad._lastIdentifier = 0;
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698