Index: WebCore/inspector/front-end/Resource.js |
=================================================================== |
--- WebCore/inspector/front-end/Resource.js (revision 73033) |
+++ WebCore/inspector/front-end/Resource.js (working copy) |
@@ -625,22 +625,69 @@ |
return this._content; |
}, |
- set content(content) |
+ get contentTimestamp() |
{ |
- var data = { oldContent: this._content, oldContentTimestamp: this._contentTimestamp }; |
+ return this._contentTimestamp; |
+ }, |
+ |
+ setInitialContent: function(content) |
+ { |
this._content = content; |
- this._contentTimestamp = new Date(); |
+ }, |
+ |
+ isLocallyModified: function() |
+ { |
+ return !!this._baseRevision; |
+ }, |
+ |
+ setContent: function(newContent, onRevert) |
+ { |
+ var revisionResource = new WebInspector.Resource(null, this.url); |
+ revisionResource.type = this.type; |
+ revisionResource.loader = this.loader; |
+ revisionResource.timestamp = this.timestamp; |
+ revisionResource._content = this._content; |
+ revisionResource._actualResource = this; |
+ revisionResource._fireOnRevert = onRevert; |
+ |
+ if (this.finished) |
+ revisionResource.finished = true; |
+ else { |
+ function finished() |
+ { |
+ this.removeEventListener("finished", finished); |
+ revisionResource.finished = true; |
+ } |
+ this.addEventListener("finished", finished.bind(this)); |
+ } |
+ |
+ if (!this._baseRevision) |
+ this._baseRevision = revisionResource; |
+ else |
+ revisionResource._baseRevision = this._baseRevision; |
+ |
+ var data = { revision: revisionResource }; |
+ this._content = newContent; |
+ this.timestamp = new Date(); |
this.dispatchEventToListeners("content-changed", data); |
}, |
- get contentTimestamp() |
+ revertToThis: function() |
{ |
- return this._contentTimestamp; |
+ if (!this._actualResource || !this._fireOnRevert) |
+ return; |
+ |
+ function callback(content) |
+ { |
+ if (content) |
+ this._fireOnRevert(content); |
+ } |
+ this.requestContent(callback.bind(this)); |
}, |
- setInitialContent: function(content) |
+ get baseRevision() |
{ |
- this._content = content; |
+ return this._baseRevision; |
}, |
requestContent: function(callback) |