| OLD | NEW |
| 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 Loading... |
| 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 {?Date} lastModified |
| 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 && lastModified.isValid() ? lastModified :
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 var date = lastModifiedHeader ? new Date(lastModifiedHeader) : null; |
| 75 this._lastModified = date && date.isValid() ? date : null; |
| 76 return this._lastModified; |
| 77 }, |
| 78 |
| 79 /** |
| 80 * @return {?number} |
| 81 */ |
| 82 contentSize: function() |
| 83 { |
| 84 if (typeof this._contentSize === "number" || !this._request) |
| 85 return this._contentSize; |
| 86 return this._request.resourceSize; |
| 87 }, |
| 88 |
| 89 /** |
| 62 * @return {?WebInspector.NetworkRequest} | 90 * @return {?WebInspector.NetworkRequest} |
| 63 */ | 91 */ |
| 64 get request() | 92 get request() |
| 65 { | 93 { |
| 66 return this._request; | 94 return this._request; |
| 67 }, | 95 }, |
| 68 | 96 |
| 69 /** | 97 /** |
| 70 * @return {string} | 98 * @return {string} |
| 71 */ | 99 */ |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 if (this._type.isTextType()) | 347 if (this._type.isTextType()) |
| 320 return true; | 348 return true; |
| 321 if (this._type === WebInspector.resourceTypes.Other) | 349 if (this._type === WebInspector.resourceTypes.Other) |
| 322 return !!this._content && !this._contentEncoded; | 350 return !!this._content && !this._contentEncoded; |
| 323 return false; | 351 return false; |
| 324 }, | 352 }, |
| 325 | 353 |
| 326 __proto__: WebInspector.SDKObject.prototype | 354 __proto__: WebInspector.SDKObject.prototype |
| 327 } | 355 } |
| 328 | 356 |
| OLD | NEW |