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

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

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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 13 matching lines...) Expand all
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 /** 31 /**
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.NetworkLog = class extends WebInspector.SDKModel { 34 SDK.NetworkLog = class extends SDK.SDKModel {
35 /** 35 /**
36 * @param {!WebInspector.Target} target 36 * @param {!SDK.Target} target
37 * @param {!WebInspector.ResourceTreeModel} resourceTreeModel 37 * @param {!SDK.ResourceTreeModel} resourceTreeModel
38 * @param {!WebInspector.NetworkManager} networkManager 38 * @param {!SDK.NetworkManager} networkManager
39 */ 39 */
40 constructor(target, resourceTreeModel, networkManager) { 40 constructor(target, resourceTreeModel, networkManager) {
41 super(WebInspector.NetworkLog, target); 41 super(SDK.NetworkLog, target);
42 42
43 this._requests = []; 43 this._requests = [];
44 this._requestForId = {}; 44 this._requestForId = {};
45 networkManager.addEventListener(WebInspector.NetworkManager.Events.RequestSt arted, this._onRequestStarted, this); 45 networkManager.addEventListener(SDK.NetworkManager.Events.RequestStarted, th is._onRequestStarted, this);
46 resourceTreeModel.addEventListener( 46 resourceTreeModel.addEventListener(
47 WebInspector.ResourceTreeModel.Events.MainFrameNavigated, this._onMainFr ameNavigated, this); 47 SDK.ResourceTreeModel.Events.MainFrameNavigated, this._onMainFrameNaviga ted, this);
48 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Events.Loa d, this._onLoad, this); 48 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.Load, this._ onLoad, this);
49 resourceTreeModel.addEventListener( 49 resourceTreeModel.addEventListener(
50 WebInspector.ResourceTreeModel.Events.DOMContentLoaded, this._onDOMConte ntLoaded, this); 50 SDK.ResourceTreeModel.Events.DOMContentLoaded, this._onDOMContentLoaded, this);
51 } 51 }
52 52
53 /** 53 /**
54 * @param {!WebInspector.Target} target 54 * @param {!SDK.Target} target
55 * @return {?WebInspector.NetworkLog} 55 * @return {?SDK.NetworkLog}
56 */ 56 */
57 static fromTarget(target) { 57 static fromTarget(target) {
58 return /** @type {?WebInspector.NetworkLog} */ (target.model(WebInspector.Ne tworkLog)); 58 return /** @type {?SDK.NetworkLog} */ (target.model(SDK.NetworkLog));
59 } 59 }
60 60
61 /** 61 /**
62 * @param {string} url 62 * @param {string} url
63 * @return {?WebInspector.NetworkRequest} 63 * @return {?SDK.NetworkRequest}
64 */ 64 */
65 static requestForURL(url) { 65 static requestForURL(url) {
66 for (var target of WebInspector.targetManager.targets()) { 66 for (var target of SDK.targetManager.targets()) {
67 var networkLog = WebInspector.NetworkLog.fromTarget(target); 67 var networkLog = SDK.NetworkLog.fromTarget(target);
68 var result = networkLog && networkLog.requestForURL(url); 68 var result = networkLog && networkLog.requestForURL(url);
69 if (result) 69 if (result)
70 return result; 70 return result;
71 } 71 }
72 return null; 72 return null;
73 } 73 }
74 74
75 /** 75 /**
76 * @return {!Array.<!WebInspector.NetworkRequest>} 76 * @return {!Array.<!SDK.NetworkRequest>}
77 */ 77 */
78 static requests() { 78 static requests() {
79 var result = []; 79 var result = [];
80 for (var target of WebInspector.targetManager.targets()) { 80 for (var target of SDK.targetManager.targets()) {
81 var networkLog = WebInspector.NetworkLog.fromTarget(target); 81 var networkLog = SDK.NetworkLog.fromTarget(target);
82 if (networkLog) 82 if (networkLog)
83 result = result.concat(networkLog.requests()); 83 result = result.concat(networkLog.requests());
84 } 84 }
85 return result; 85 return result;
86 } 86 }
87 87
88 /** 88 /**
89 * @return {!Array.<!WebInspector.NetworkRequest>} 89 * @return {!Array.<!SDK.NetworkRequest>}
90 */ 90 */
91 requests() { 91 requests() {
92 return this._requests; 92 return this._requests;
93 } 93 }
94 94
95 /** 95 /**
96 * @param {string} url 96 * @param {string} url
97 * @return {?WebInspector.NetworkRequest} 97 * @return {?SDK.NetworkRequest}
98 */ 98 */
99 requestForURL(url) { 99 requestForURL(url) {
100 for (var i = 0; i < this._requests.length; ++i) { 100 for (var i = 0; i < this._requests.length; ++i) {
101 if (this._requests[i].url === url) 101 if (this._requests[i].url === url)
102 return this._requests[i]; 102 return this._requests[i];
103 } 103 }
104 return null; 104 return null;
105 } 105 }
106 106
107 /** 107 /**
108 * @param {!WebInspector.NetworkRequest} request 108 * @param {!SDK.NetworkRequest} request
109 * @return {!WebInspector.PageLoad} 109 * @return {!SDK.PageLoad}
110 */ 110 */
111 pageLoadForRequest(request) { 111 pageLoadForRequest(request) {
112 return request.__page; 112 return request.__page;
113 } 113 }
114 114
115 /** 115 /**
116 * @param {!WebInspector.Event} event 116 * @param {!Common.Event} event
117 */ 117 */
118 _onMainFrameNavigated(event) { 118 _onMainFrameNavigated(event) {
119 var mainFrame = /** type {WebInspector.ResourceTreeFrame} */ event.data; 119 var mainFrame = /** type {SDK.ResourceTreeFrame} */ event.data;
120 // Preserve requests from the new session. 120 // Preserve requests from the new session.
121 this._currentPageLoad = null; 121 this._currentPageLoad = null;
122 var oldRequests = this._requests.splice(0, this._requests.length); 122 var oldRequests = this._requests.splice(0, this._requests.length);
123 this._requestForId = {}; 123 this._requestForId = {};
124 for (var i = 0; i < oldRequests.length; ++i) { 124 for (var i = 0; i < oldRequests.length; ++i) {
125 var request = oldRequests[i]; 125 var request = oldRequests[i];
126 if (request.loaderId === mainFrame.loaderId) { 126 if (request.loaderId === mainFrame.loaderId) {
127 if (!this._currentPageLoad) 127 if (!this._currentPageLoad)
128 this._currentPageLoad = new WebInspector.PageLoad(request); 128 this._currentPageLoad = new SDK.PageLoad(request);
129 this._requests.push(request); 129 this._requests.push(request);
130 this._requestForId[request.requestId] = request; 130 this._requestForId[request.requestId] = request;
131 request.__page = this._currentPageLoad; 131 request.__page = this._currentPageLoad;
132 } 132 }
133 } 133 }
134 } 134 }
135 135
136 /** 136 /**
137 * @param {!WebInspector.Event} event 137 * @param {!Common.Event} event
138 */ 138 */
139 _onRequestStarted(event) { 139 _onRequestStarted(event) {
140 var request = /** @type {!WebInspector.NetworkRequest} */ (event.data); 140 var request = /** @type {!SDK.NetworkRequest} */ (event.data);
141 this._requests.push(request); 141 this._requests.push(request);
142 this._requestForId[request.requestId] = request; 142 this._requestForId[request.requestId] = request;
143 request.__page = this._currentPageLoad; 143 request.__page = this._currentPageLoad;
144 } 144 }
145 145
146 /** 146 /**
147 * @param {!WebInspector.Event} event 147 * @param {!Common.Event} event
148 */ 148 */
149 _onDOMContentLoaded(event) { 149 _onDOMContentLoaded(event) {
150 if (this._currentPageLoad) 150 if (this._currentPageLoad)
151 this._currentPageLoad.contentLoadTime = event.data; 151 this._currentPageLoad.contentLoadTime = event.data;
152 } 152 }
153 153
154 /** 154 /**
155 * @param {!WebInspector.Event} event 155 * @param {!Common.Event} event
156 */ 156 */
157 _onLoad(event) { 157 _onLoad(event) {
158 if (this._currentPageLoad) 158 if (this._currentPageLoad)
159 this._currentPageLoad.loadTime = event.data; 159 this._currentPageLoad.loadTime = event.data;
160 } 160 }
161 161
162 /** 162 /**
163 * @param {!Protocol.Network.RequestId} requestId 163 * @param {!Protocol.Network.RequestId} requestId
164 * @return {?WebInspector.NetworkRequest} 164 * @return {?SDK.NetworkRequest}
165 */ 165 */
166 requestForId(requestId) { 166 requestForId(requestId) {
167 return this._requestForId[requestId]; 167 return this._requestForId[requestId];
168 } 168 }
169 }; 169 };
170 170
171 171
172 /** 172 /**
173 * @unrestricted 173 * @unrestricted
174 */ 174 */
175 WebInspector.PageLoad = class { 175 SDK.PageLoad = class {
176 /** 176 /**
177 * @param {!WebInspector.NetworkRequest} mainRequest 177 * @param {!SDK.NetworkRequest} mainRequest
178 */ 178 */
179 constructor(mainRequest) { 179 constructor(mainRequest) {
180 this.id = ++WebInspector.PageLoad._lastIdentifier; 180 this.id = ++SDK.PageLoad._lastIdentifier;
181 this.url = mainRequest.url; 181 this.url = mainRequest.url;
182 this.startTime = mainRequest.startTime; 182 this.startTime = mainRequest.startTime;
183 } 183 }
184 }; 184 };
185 185
186 WebInspector.PageLoad._lastIdentifier = 0; 186 SDK.PageLoad._lastIdentifier = 0;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698