Changeset 84483 in webkit


Ignore:
Timestamp:
Apr 21, 2011 4:43:42 AM (13 years ago)
Author:
pfeldman@chromium.org
Message:

2011-04-21 Pavel Feldman <pfeldman@google.com>

Reviewed by Yury Semikhatsky.

Web Inspector: persist local resource history between inspector / browser launches.
https://bugs.webkit.org/show_bug.cgi?id=58993

  • inspector/front-end/Resource.js: (WebInspector.Resource.prototype._restoreRevisions):
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r84481 r84483  
     12011-04-21  Pavel Feldman  <pfeldman@google.com>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: persist local resource history between inspector / browser launches.
     6        https://bugs.webkit.org/show_bug.cgi?id=58993
     7
     8        * inspector/front-end/Resource.js:
     9        (WebInspector.Resource.prototype._restoreRevisions):
     10
    1112011-04-20  Alexander Pavlov  <apavlov@chromium.org>
    212
  • trunk/Source/WebCore/inspector/front-end/NetworkManager.js

    r84260 r84483  
    318318    _createResource: function(identifier, frameId, loaderId, url, documentURL, stackTrace)
    319319    {
    320         var resource = new WebInspector.Resource(identifier, url);
     320        var resource = new WebInspector.Resource(identifier, url, loaderId);
    321321        resource.documentURL = documentURL;
    322322        resource.frameId = frameId;
    323         resource.loaderId = loaderId;
    324323        resource.stackTrace = stackTrace;
    325324        return resource;
  • trunk/Source/WebCore/inspector/front-end/Resource.js

    r83987 r84483  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 WebInspector.Resource = function(identifier, url)
     28WebInspector.Resource = function(identifier, url, loaderId)
    2929{
    3030    this.identifier = identifier;
    3131    this.url = url;
     32    this.loaderId = loaderId;
    3233    this._startTime = -1;
    3334    this._endTime = -1;
     
    3536    this._pendingContentCallbacks = [];
    3637    this.history = [];
     38
     39    this._restoreRevisions();
    3740}
    3841
     
    107110{
    108111    WebInspector.Resource._domainModelBindings[type] = binding;
     112}
     113
     114WebInspector.Resource.clearRevisionHistory = function()
     115{
     116    if (!window.localStorage)
     117        return;
     118
     119    for (var key in window.localStorage) {
     120        if (key.indexOf("resource-history|") === 0)
     121            delete window.localStorage[key];
     122    }
    109123}
    110124
     
    722736    },
    723737
    724     addRevision: function(newContent)
     738    addRevision: function(newContent, timestamp, restoringHistory)
    725739    {
    726740        var revision = new WebInspector.ResourceRevision(this, this._content, this._contentTimestamp);
     
    728742
    729743        this._content = newContent;
    730         this._contentTimestamp = new Date();
     744        this._contentTimestamp = timestamp || new Date();
    731745
    732746        this.dispatchEventToListeners(WebInspector.Resource.Events.RevisionAdded, revision);
     747
     748        if (!restoringHistory)
     749            this._persistRevision();
     750    },
     751
     752    _persistRevision: function()
     753    {
     754        if (!window.localStorage)
     755            return;
     756
     757        var url = this.url;
     758        var loaderId = this.loaderId;
     759        var timestamp = this._contentTimestamp.getTime();
     760        var content = this._content;
     761        function persist()
     762        {
     763            var key = "resource-history|" + url + "|" + loaderId + "|" + timestamp;
     764            window.localStorage[key] = content;
     765        }
     766   
     767        // Schedule async storage.
     768        setTimeout(persist, 0);
     769    },
     770
     771    _restoreRevisions: function()
     772    {
     773        if (!window.localStorage)
     774            return;
     775
     776        try {
     777            var urlKey = "resource-history|" + this.url + "|" + this.loaderId + "|";
     778
     779            var content = {};
     780            var timestamps = [];
     781            for (var key in window.localStorage) {
     782                if (key.indexOf(urlKey) !== 0)
     783                    continue;
     784                var timestamp = parseInt(key.substring(urlKey.length));
     785                content[timestamp] = window.localStorage[key];
     786                timestamps.push(timestamp);
     787            }
     788
     789            if (!timestamps.length)
     790                return;
     791
     792            timestamps.sort();
     793            for (var i = 0; i < timestamps.length; ++i) {
     794                var timestamp = timestamps[i];
     795                this.addRevision(content[timestamp], new Date(timestamp), true);
     796            }
     797        } catch(e) {
     798            console.error(e.toString());
     799        }
    733800    },
    734801
  • trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js

    r83845 r84483  
    124124        if (isMainFrame && this.resourceForURL(frame.url))
    125125            WebInspector.mainResource = this.resourceForURL(frame.url);
     126
     127        if (isMainFrame)
     128            WebInspector.Resource.clearRevisionHistory();
    126129    },
    127130
     
    300303    _createResource: function(frame, url)
    301304    {
    302         var resource = new WebInspector.Resource(null, url);
     305        var resource = new WebInspector.Resource(null, url, frame.loaderId);
    303306        resource.frameId = frame.id;
    304         resource.loaderId = frame.loaderId;
    305307        resource.documentURL = frame.url;
    306308        return resource;
  • trunk/Source/WebCore/inspector/front-end/SourceCSSTokenizer.js

    r74352 r84483  
    4646    WebInspector.SourceTokenizer.call(this);
    4747
    48     this._propertyKeywords = WebInspector.cssNameCompletions.keySet();
     48    this._propertyKeywords = WebInspector.cssNameCompletions ? WebInspector.cssNameCompletions.keySet() : {};
    4949
    5050    this._valueKeywords = [
Note: See TracChangeset for help on using the changeset viewer.