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

Side by Side Diff: Source/devtools/front_end/NetworkManager.js

Issue 209343005: Move 'response' check in responseReceived() to the backend. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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 | « Source/core/inspector/InspectorResourceAgent.cpp ('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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 networkRequest.setRequestHeaders(this._headersMapToHeadersArray(request. headers)); 157 networkRequest.setRequestHeaders(this._headersMapToHeadersArray(request. headers));
158 networkRequest.requestFormData = request.postData; 158 networkRequest.requestFormData = request.postData;
159 }, 159 },
160 160
161 /** 161 /**
162 * @param {!WebInspector.NetworkRequest} networkRequest 162 * @param {!WebInspector.NetworkRequest} networkRequest
163 * @param {!NetworkAgent.Response=} response 163 * @param {!NetworkAgent.Response=} response
164 */ 164 */
165 _updateNetworkRequestWithResponse: function(networkRequest, response) 165 _updateNetworkRequestWithResponse: function(networkRequest, response)
166 { 166 {
167 if (!response)
168 return;
169
170 if (response.url && networkRequest.url !== response.url) 167 if (response.url && networkRequest.url !== response.url)
171 networkRequest.url = response.url; 168 networkRequest.url = response.url;
172 networkRequest.mimeType = response.mimeType; 169 networkRequest.mimeType = response.mimeType;
173 networkRequest.statusCode = response.status; 170 networkRequest.statusCode = response.status;
174 networkRequest.statusText = response.statusText; 171 networkRequest.statusText = response.statusText;
175 networkRequest.responseHeaders = this._headersMapToHeadersArray(response .headers); 172 networkRequest.responseHeaders = this._headersMapToHeadersArray(response .headers);
176 if (response.encodedDataLength >= 0) 173 if (response.encodedDataLength >= 0)
177 networkRequest.setTransferSize(response.encodedDataLength); 174 networkRequest.setTransferSize(response.encodedDataLength);
178 if (response.headersText) 175 if (response.headersText)
179 networkRequest.responseHeadersText = response.headersText; 176 networkRequest.responseHeadersText = response.headersText;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 if (!networkRequest.mimeType) 225 if (!networkRequest.mimeType)
229 return true; // Might be not known for cached resources with null re sponses. 226 return true; // Might be not known for cached resources with null re sponses.
230 227
231 if (networkRequest.mimeType in WebInspector.NetworkManager._MIMETypes) 228 if (networkRequest.mimeType in WebInspector.NetworkManager._MIMETypes)
232 return networkRequest.type.name() in WebInspector.NetworkManager._MI METypes[networkRequest.mimeType]; 229 return networkRequest.type.name() in WebInspector.NetworkManager._MI METypes[networkRequest.mimeType];
233 230
234 return false; 231 return false;
235 }, 232 },
236 233
237 /** 234 /**
238 * @param {!NetworkAgent.Response} response
239 * @return {boolean}
240 */
241 _isNull: function(response)
242 {
243 if (!response)
244 return true;
245 return !response.status && !response.mimeType && (!response.headers || ! Object.keys(response.headers).length);
246 },
247
248 /**
249 * @param {!NetworkAgent.RequestId} requestId 235 * @param {!NetworkAgent.RequestId} requestId
250 * @param {!PageAgent.FrameId} frameId 236 * @param {!PageAgent.FrameId} frameId
251 * @param {!NetworkAgent.LoaderId} loaderId 237 * @param {!NetworkAgent.LoaderId} loaderId
252 * @param {string} documentURL 238 * @param {string} documentURL
253 * @param {!NetworkAgent.Request} request 239 * @param {!NetworkAgent.Request} request
254 * @param {!NetworkAgent.Timestamp} time 240 * @param {!NetworkAgent.Timestamp} time
255 * @param {!NetworkAgent.Initiator} initiator 241 * @param {!NetworkAgent.Initiator} initiator
256 * @param {!NetworkAgent.Response=} redirectResponse 242 * @param {!NetworkAgent.Response=} redirectResponse
257 */ 243 */
258 requestWillBeSent: function(requestId, frameId, loaderId, documentURL, reque st, time, initiator, redirectResponse) 244 requestWillBeSent: function(requestId, frameId, loaderId, documentURL, reque st, time, initiator, redirectResponse)
(...skipping 29 matching lines...) Expand all
288 /** 274 /**
289 * @param {!NetworkAgent.RequestId} requestId 275 * @param {!NetworkAgent.RequestId} requestId
290 * @param {!PageAgent.FrameId} frameId 276 * @param {!PageAgent.FrameId} frameId
291 * @param {!NetworkAgent.LoaderId} loaderId 277 * @param {!NetworkAgent.LoaderId} loaderId
292 * @param {!NetworkAgent.Timestamp} time 278 * @param {!NetworkAgent.Timestamp} time
293 * @param {!PageAgent.ResourceType} resourceType 279 * @param {!PageAgent.ResourceType} resourceType
294 * @param {!NetworkAgent.Response} response 280 * @param {!NetworkAgent.Response} response
295 */ 281 */
296 responseReceived: function(requestId, frameId, loaderId, time, resourceType, response) 282 responseReceived: function(requestId, frameId, loaderId, time, resourceType, response)
297 { 283 {
298 // FIXME: move this check to the backend.
299 if (this._isNull(response))
300 return;
301
302 var networkRequest = this._inflightRequestsById[requestId]; 284 var networkRequest = this._inflightRequestsById[requestId];
303 if (!networkRequest) { 285 if (!networkRequest) {
304 // We missed the requestWillBeSent. 286 // We missed the requestWillBeSent.
305 var eventData = {}; 287 var eventData = {};
306 eventData.url = response.url; 288 eventData.url = response.url;
307 eventData.frameId = frameId; 289 eventData.frameId = frameId;
308 eventData.loaderId = loaderId; 290 eventData.loaderId = loaderId;
309 eventData.resourceType = resourceType; 291 eventData.resourceType = resourceType;
310 eventData.mimeType = response.mimeType; 292 eventData.mimeType = response.mimeType;
311 this._manager.dispatchEventToListeners(WebInspector.NetworkManager.E ventTypes.RequestUpdateDropped, eventData); 293 this._manager.dispatchEventToListeners(WebInspector.NetworkManager.E ventTypes.RequestUpdateDropped, eventData);
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 var networkRequest = new WebInspector.NetworkRequest(requestId, url, doc umentURL, frameId, loaderId); 546 var networkRequest = new WebInspector.NetworkRequest(requestId, url, doc umentURL, frameId, loaderId);
565 networkRequest.initiator = initiator; 547 networkRequest.initiator = initiator;
566 return networkRequest; 548 return networkRequest;
567 } 549 }
568 } 550 }
569 551
570 /** 552 /**
571 * @type {!WebInspector.NetworkManager} 553 * @type {!WebInspector.NetworkManager}
572 */ 554 */
573 WebInspector.networkManager; 555 WebInspector.networkManager;
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorResourceAgent.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698