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

Unified 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: always send last-modified in php script 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sdk/Resource.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/Resource.js b/third_party/WebKit/Source/devtools/front_end/sdk/Resource.js
index 4db1ddc2a7f1040b27a84ea5231ff156ec6ea993..bc515f9acd80c5856d3b3fb23f6466d2a27d66bd 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/Resource.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/Resource.js
@@ -38,8 +38,10 @@
* @param {!NetworkAgent.LoaderId} loaderId
* @param {!WebInspector.ResourceType} type
* @param {string} mimeType
+ * @param {?Date} lastModified
+ * @param {?number} contentSize
*/
-WebInspector.Resource = function(target, request, url, documentURL, frameId, loaderId, type, mimeType)
+WebInspector.Resource = function(target, request, url, documentURL, frameId, loaderId, type, mimeType, lastModified, contentSize)
{
WebInspector.SDKObject.call(this, target);
this._request = request;
@@ -50,6 +52,9 @@ WebInspector.Resource = function(target, request, url, documentURL, frameId, loa
this._type = type || WebInspector.resourceTypes.Other;
this._mimeType = mimeType;
+ this._lastModified = lastModified && lastModified.isValid() ? lastModified : null;
+ this._contentSize = contentSize;
+
/** @type {?string} */ this._content;
/** @type {boolean} */ this._contentEncoded;
this._pendingContentCallbacks = [];
@@ -59,6 +64,29 @@ WebInspector.Resource = function(target, request, url, documentURL, frameId, loa
WebInspector.Resource.prototype = {
/**
+ * @return {?Date}
+ */
+ lastModified: function()
+ {
+ if (this._lastModified || !this._request)
+ return this._lastModified;
+ var lastModifiedHeader = this._request.responseLastModified();
+ var date = lastModifiedHeader ? new Date(lastModifiedHeader) : null;
+ this._lastModified = date && date.isValid() ? date : null;
+ return this._lastModified;
+ },
+
+ /**
+ * @return {?number}
+ */
+ contentSize: function()
+ {
+ if (typeof this._contentSize === "number" || !this._request)
+ return this._contentSize;
+ return this._request.resourceSize;
+ },
+
+ /**
* @return {?WebInspector.NetworkRequest}
*/
get request()

Powered by Google App Engine
This is Rietveld 408576698