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

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

Issue 2413233003: DevTools: introduce WI.Resource.contentSize() and WI.Resource.lastModified() (Closed)
Patch Set: add tests Created 4 years, 2 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) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 20 matching lines...) Expand all
31 * @extends {WebInspector.SDKObject} 31 * @extends {WebInspector.SDKObject}
32 * @implements {WebInspector.ContentProvider} 32 * @implements {WebInspector.ContentProvider}
33 * @param {!WebInspector.Target} target 33 * @param {!WebInspector.Target} target
34 * @param {?WebInspector.NetworkRequest} request 34 * @param {?WebInspector.NetworkRequest} request
35 * @param {string} url 35 * @param {string} url
36 * @param {string} documentURL 36 * @param {string} documentURL
37 * @param {!PageAgent.FrameId} frameId 37 * @param {!PageAgent.FrameId} frameId
38 * @param {!NetworkAgent.LoaderId} loaderId 38 * @param {!NetworkAgent.LoaderId} loaderId
39 * @param {!WebInspector.ResourceType} type 39 * @param {!WebInspector.ResourceType} type
40 * @param {string} mimeType 40 * @param {string} mimeType
41 * @param {?number} lastModified
dgozman 2016/10/14 18:48:51 Let's pass ?Date instead.
lushnikov 2016/10/14 20:56:27 Done.
42 * @param {?number} contentSize
41 */ 43 */
42 WebInspector.Resource = function(target, request, url, documentURL, frameId, loa derId, type, mimeType) 44 WebInspector.Resource = function(target, request, url, documentURL, frameId, loa derId, type, mimeType, lastModified, contentSize)
43 { 45 {
44 WebInspector.SDKObject.call(this, target); 46 WebInspector.SDKObject.call(this, target);
45 this._request = request; 47 this._request = request;
46 this.url = url; 48 this.url = url;
47 this._documentURL = documentURL; 49 this._documentURL = documentURL;
48 this._frameId = frameId; 50 this._frameId = frameId;
49 this._loaderId = loaderId; 51 this._loaderId = loaderId;
50 this._type = type || WebInspector.resourceTypes.Other; 52 this._type = type || WebInspector.resourceTypes.Other;
51 this._mimeType = mimeType; 53 this._mimeType = mimeType;
52 54
55 this._lastModified = lastModified ? new Date(lastModified * 1000) : null;
56 this._contentSize = contentSize;
57
53 /** @type {?string} */ this._content; 58 /** @type {?string} */ this._content;
54 /** @type {boolean} */ this._contentEncoded; 59 /** @type {boolean} */ this._contentEncoded;
55 this._pendingContentCallbacks = []; 60 this._pendingContentCallbacks = [];
56 if (this._request && !this._request.finished) 61 if (this._request && !this._request.finished)
57 this._request.addEventListener(WebInspector.NetworkRequest.Events.Finish edLoading, this._requestFinished, this); 62 this._request.addEventListener(WebInspector.NetworkRequest.Events.Finish edLoading, this._requestFinished, this);
58 } 63 }
59 64
60 WebInspector.Resource.prototype = { 65 WebInspector.Resource.prototype = {
61 /** 66 /**
67 * @return {?Date}
68 */
69 lastModified: function()
70 {
71 if (this._lastModified || !this._request)
72 return this._lastModified;
73 var lastModifiedHeader = this._request.responseLastModified();
74 this._lastModified = lastModifiedHeader ? new Date(lastModifiedHeader) : null;
75 return this._lastModified;
76 },
77
78 /**
79 * @return {?number}
80 */
81 contentSize: function()
82 {
83 if (typeof this._contentSize === "number" || !this._request)
84 return this._contentSize;
85 return this._request.resourceSize;
86 },
87
88 /**
62 * @return {?WebInspector.NetworkRequest} 89 * @return {?WebInspector.NetworkRequest}
63 */ 90 */
64 get request() 91 get request()
65 { 92 {
66 return this._request; 93 return this._request;
67 }, 94 },
68 95
69 /** 96 /**
70 * @return {string} 97 * @return {string}
71 */ 98 */
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 if (this._type.isTextType()) 346 if (this._type.isTextType())
320 return true; 347 return true;
321 if (this._type === WebInspector.resourceTypes.Other) 348 if (this._type === WebInspector.resourceTypes.Other)
322 return !!this._content && !this._contentEncoded; 349 return !!this._content && !this._contentEncoded;
323 return false; 350 return false;
324 }, 351 },
325 352
326 __proto__: WebInspector.SDKObject.prototype 353 __proto__: WebInspector.SDKObject.prototype
327 } 354 }
328 355
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698