[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

caseq at chromium.org caseq at chromium.org
Sun Feb 20 23:09:55 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 10d59b295774b8bb3c5acd25266ecc0efe1e5ba7
Author: caseq at chromium.org <caseq at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jan 18 14:25:34 2011 +0000

    2011-01-17  Andrey Kosyakov  <caseq at chromium.org>
    
            Reviewed by Yury Semikhatsky.
    
            Web Inspector: [refactoring] use events to notify NetworkManager clients
            https://bugs.webkit.org/show_bug.cgi?id=52588
    
            * inspector/front-end/AuditLauncherView.js:
            (WebInspector.AuditLauncherView): Do not expose public interface to resource count. Do not reset resource count upon reset().
            (WebInspector.AuditLauncherView.prototype._resetResourceCount):
            (WebInspector.AuditLauncherView.prototype._onResourceStarted):
            (WebInspector.AuditLauncherView.prototype._onResourceFinished):
            * inspector/front-end/AuditsPanel.js: Do not expose public interface to resource start/finish events.
            * inspector/front-end/ExtensionServer.js:
            (WebInspector.ExtensionServer):
            (WebInspector.ExtensionServer.prototype._notifyResourceFinished):
            (WebInspector.ExtensionServer.prototype.initExtensions):
            * inspector/front-end/NetworkManager.js: Dispatch events rather than directly call clients.
            (WebInspector.NetworkManager):
            (WebInspector.NetworkManager.prototype.willSendRequest):
            (WebInspector.NetworkManager.prototype.markResourceAsCached):
            (WebInspector.NetworkManager.prototype.didReceiveResponse):
            (WebInspector.NetworkManager.prototype.didReceiveContentLength):
            (WebInspector.NetworkManager.prototype.setInitialContent):
            (WebInspector.NetworkManager.prototype.didCommitLoadForFrame):
            (WebInspector.NetworkManager.prototype.willSendWebSocketHandshakeRequest):
            (WebInspector.NetworkManager.prototype.didReceiveWebSocketHandshakeResponse):
            (WebInspector.NetworkManager.prototype._startResource):
            (WebInspector.NetworkManager.prototype._finishResource):
            * inspector/front-end/NetworkPanel.js:
            (WebInspector.NetworkPanel):
            (WebInspector.NetworkPanel.prototype._onResourceStarted):
            (WebInspector.NetworkPanel.prototype._appendResource):
            (WebInspector.NetworkPanel.prototype._onResourceUpdated):
            (WebInspector.NetworkPanel.prototype._refreshResource):
            (WebInspector.NetworkPanel.prototype._onMainResourceChanged):
            * inspector/front-end/ResourcesPanel.js:
            (WebInspector.ResourcesPanel):
            (WebInspector.ResourcesPanel.prototype._refreshResource):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76022 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 8359a92..829a491 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,43 @@
+2011-01-17  Andrey Kosyakov  <caseq at chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: [refactoring] use events to notify NetworkManager clients
+        https://bugs.webkit.org/show_bug.cgi?id=52588
+
+        * inspector/front-end/AuditLauncherView.js:
+        (WebInspector.AuditLauncherView): Do not expose public interface to resource count. Do not reset resource count upon reset().
+        (WebInspector.AuditLauncherView.prototype._resetResourceCount):
+        (WebInspector.AuditLauncherView.prototype._onResourceStarted):
+        (WebInspector.AuditLauncherView.prototype._onResourceFinished):
+        * inspector/front-end/AuditsPanel.js: Do not expose public interface to resource start/finish events.
+        * inspector/front-end/ExtensionServer.js:
+        (WebInspector.ExtensionServer):
+        (WebInspector.ExtensionServer.prototype._notifyResourceFinished):
+        (WebInspector.ExtensionServer.prototype.initExtensions):
+        * inspector/front-end/NetworkManager.js: Dispatch events rather than directly call clients.
+        (WebInspector.NetworkManager):
+        (WebInspector.NetworkManager.prototype.willSendRequest):
+        (WebInspector.NetworkManager.prototype.markResourceAsCached):
+        (WebInspector.NetworkManager.prototype.didReceiveResponse):
+        (WebInspector.NetworkManager.prototype.didReceiveContentLength):
+        (WebInspector.NetworkManager.prototype.setInitialContent):
+        (WebInspector.NetworkManager.prototype.didCommitLoadForFrame):
+        (WebInspector.NetworkManager.prototype.willSendWebSocketHandshakeRequest):
+        (WebInspector.NetworkManager.prototype.didReceiveWebSocketHandshakeResponse):
+        (WebInspector.NetworkManager.prototype._startResource):
+        (WebInspector.NetworkManager.prototype._finishResource):
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkPanel):
+        (WebInspector.NetworkPanel.prototype._onResourceStarted):
+        (WebInspector.NetworkPanel.prototype._appendResource):
+        (WebInspector.NetworkPanel.prototype._onResourceUpdated):
+        (WebInspector.NetworkPanel.prototype._refreshResource):
+        (WebInspector.NetworkPanel.prototype._onMainResourceChanged):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel):
+        (WebInspector.ResourcesPanel.prototype._refreshResource):
+
 2011-01-18  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Yury Semikhatsky.
diff --git a/Source/WebCore/inspector/front-end/AuditLauncherView.js b/Source/WebCore/inspector/front-end/AuditLauncherView.js
index c140589..df16a41 100644
--- a/Source/WebCore/inspector/front-end/AuditLauncherView.js
+++ b/Source/WebCore/inspector/front-end/AuditLauncherView.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -50,60 +50,38 @@ WebInspector.AuditLauncherView = function(runnerCallback)
     this._headerElement.className = "no-audits";
     this._headerElement.textContent = WebInspector.UIString("No audits to run");
     this._contentElement.appendChild(this._headerElement);
+
+    WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceStarted, this._onResourceStarted, this);
+    WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._onResourceFinished, this);
 }
 
 WebInspector.AuditLauncherView.prototype = {
-    get totalResources()
+    _resetResourceCount: function()
     {
-        return this._totalResources;
+        this._loadedResources = 0;
+        this._totalResources = 0;
     },
 
-    set totalResources(x)
+    _onResourceStarted: function(event)
     {
-        if (this._totalResources === x)
+        var resource = event.data;
+        // Ignore long-living WebSockets for the sake of progress indicator, as we won't be waiting them anyway.
+        if (resource.type === WebInspector.Resource.Type.WebSocket)
             return;
-        this._totalResources = x;
+        ++this._totalResources;
         this._updateResourceProgress();
     },
 
-    get loadedResources()
-    {
-        return this._loadedResources;
-    },
-
-    set loadedResources(x)
+    _onResourceFinished: function(event)
     {
-        if (this._loadedResources === x)
+        var resource = event.data;
+        // See resorceStarted for details.
+        if (resource.type === WebInspector.Resource.Type.WebSocket)
             return;
-        this._loadedResources = x;
+        ++this._loadedResources;
         this._updateResourceProgress();
     },
 
-    _resetResourceCount: function()
-    {
-        this.loadedResources = 0;
-        this.totalResources = 0;
-    },
-
-    resourceStarted: function(resource)
-    {
-        // Ignore long-living WebSockets for the sake of progress indicator, as we won't be waiting them anyway.
-        if (resource.type !== WebInspector.Resource.Type.WebSocket)
-            ++this.totalResources;
-    },
-
-    resourceFinished: function(resource)
-    {
-        // See resorceStarted for details.
-        if (resource.type !== WebInspector.Resource.Type.WebSocket)
-            ++this.loadedResources;
-    },
-
-    reset: function()
-    {
-        this._resetResourceCount();
-    },
-
     addCategory: function(category)
     {
         if (!this._sortedCategories.length)
@@ -264,7 +242,7 @@ WebInspector.AuditLauncherView.prototype = {
             this._resourceProgressContainer.addStyleClass("hidden");
         } else
             this._resourceProgressContainer.removeStyleClass("hidden");
-        this._resourceProgressTextElement.textContent = WebInspector.UIString("Loading (%d of %d)", this.loadedResources, this.totalResources);
+        this._resourceProgressTextElement.textContent = WebInspector.UIString("Loading (%d of %d)", this._loadedResources, this._totalResources);
     },
 
     _updateButton: function()
diff --git a/Source/WebCore/inspector/front-end/AuditsPanel.js b/Source/WebCore/inspector/front-end/AuditsPanel.js
index c639f47..f3cbfa7 100644
--- a/Source/WebCore/inspector/front-end/AuditsPanel.js
+++ b/Source/WebCore/inspector/front-end/AuditsPanel.js
@@ -96,16 +96,6 @@ WebInspector.AuditsPanel.prototype = {
         return this._auditCategoriesById;
     },
 
-    resourceStarted: function(resource)
-    {
-        this._launcherView.resourceStarted(resource);
-    },
-
-    resourceFinished: function(resource)
-    {
-        this._launcherView.resourceFinished(resource);
-    },
-
     addCategory: function(category)
     {
         this.categoriesById[category.id] = category;
@@ -246,11 +236,6 @@ WebInspector.AuditsPanel.prototype = {
             x.show(this.viewsContainerElement);
     },
 
-    reset: function()
-    {
-        this._launcherView.reset();
-    },
-
     attach: function()
     {
         WebInspector.Panel.prototype.attach.call(this);
diff --git a/Source/WebCore/inspector/front-end/ExtensionServer.js b/Source/WebCore/inspector/front-end/ExtensionServer.js
index 1320efb..961c7a2 100644
--- a/Source/WebCore/inspector/front-end/ExtensionServer.js
+++ b/Source/WebCore/inspector/front-end/ExtensionServer.js
@@ -53,7 +53,6 @@ WebInspector.ExtensionServer = function()
     this._registerHandler("subscribe", this._onSubscribe.bind(this));
     this._registerHandler("unsubscribe", this._onUnsubscribe.bind(this));
 
-
     window.addEventListener("message", this._onWindowMessage.bind(this), false);
 }
 
@@ -68,11 +67,6 @@ WebInspector.ExtensionServer.prototype = {
         this._postNotification("panel-objectSelected-" + panelId, objectId);
     },
 
-    notifyResourceFinished: function(resource)
-    {
-        this._postNotification("resource-finished", resource.identifier, (new WebInspector.HAREntry(resource)).build());
-    },
-
     notifySearchAction: function(panelId, action, searchString)
     {
         this._postNotification("panel-search-" + panelId, action, searchString);
@@ -114,6 +108,12 @@ WebInspector.ExtensionServer.prototype = {
         delete this._clientObjects[auditRun.id];
     },
 
+    _notifyResourceFinished: function(event)
+    {
+        var resource = event.data;
+        this._postNotification("resource-finished", resource.identifier, (new WebInspector.HAREntry(resource)).build());
+    },
+
     _postNotification: function(type, details)
     {
         var subscribers = this._subscribers[type];
@@ -356,6 +356,9 @@ WebInspector.ExtensionServer.prototype = {
 
     initExtensions: function()
     {
+        // The networkManager is normally created after the ExtensionServer is constructed, but before initExtensions() is called.
+        WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._notifyResourceFinished, this);
+
         InspectorExtensionRegistry.getExtensionsAsync();
     },
 
diff --git a/Source/WebCore/inspector/front-end/NetworkManager.js b/Source/WebCore/inspector/front-end/NetworkManager.js
index a657377..ed4309e 100644
--- a/Source/WebCore/inspector/front-end/NetworkManager.js
+++ b/Source/WebCore/inspector/front-end/NetworkManager.js
@@ -30,6 +30,8 @@
 
 WebInspector.NetworkManager = function(resourceTreeModel)
 {
+    WebInspector.Object.call(this);
+
     this._inflightResources = {};
     this._resourceTreeModel = resourceTreeModel;
     this._lastIdentifierForCachedResource = 0;
@@ -86,6 +88,13 @@ WebInspector.NetworkManager.updateResourceWithCachedResource = function(resource
     WebInspector.NetworkManager.updateResourceWithResponse(resource, cachedResource.response);
 }
 
+WebInspector.NetworkManager.EventTypes = {
+    ResourceStarted: "ResourceStarted",
+    ResourceUpdated: "ResourceUpdated",
+    ResourceFinished: "ResourceFinished",
+    MainResourceCommitLoad: "MainResourceCommitLoad"
+}
+
 WebInspector.NetworkManager.prototype = {
     reset: function()
     {
@@ -119,7 +128,7 @@ WebInspector.NetworkManager.prototype = {
         if (isRedirect)
             this._startResource(resource);
         else
-            WebInspector.panels.network.refreshResource(resource);
+            this._updateResource(resource);
     },
 
     markResourceAsCached: function(identifier)
@@ -129,7 +138,7 @@ WebInspector.NetworkManager.prototype = {
             return;
 
         resource.cached = true;
-        WebInspector.panels.network.refreshResource(resource);
+        this._updateResource(resource);
     },
 
     didReceiveResponse: function(identifier, time, resourceType, response)
@@ -143,7 +152,7 @@ WebInspector.NetworkManager.prototype = {
 
         WebInspector.NetworkManager.updateResourceWithResponse(resource, response);
 
-        WebInspector.panels.network.refreshResource(resource);
+        this._updateResource(resource);
         this._resourceTreeModel.addResourceToFrame(resource.loader.frameId, resource);
     },
 
@@ -156,7 +165,7 @@ WebInspector.NetworkManager.prototype = {
         resource.resourceSize += lengthReceived;
         resource.endTime = time;
 
-        WebInspector.panels.network.refreshResource(resource);
+        this._updateResource(resource);
     },
 
     didFinishLoading: function(identifier, finishTime)
@@ -204,8 +213,7 @@ WebInspector.NetworkManager.prototype = {
 
         resource.type = WebInspector.Resource.Type[type];
         resource.setInitialContent(sourceString);
-        WebInspector.panels.resources.refreshResource(resource);
-        WebInspector.panels.network.refreshResource(resource);
+        this._updateResource(resource);
     },
 
     didCommitLoadForFrame: function(frame, loader)
@@ -216,7 +224,7 @@ WebInspector.NetworkManager.prototype = {
             if (mainResource) {
                 WebInspector.mainResource = mainResource;
                 mainResource.isMainResource = true;
-                WebInspector.panels.network.mainResourceChanged();
+                this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.MainResourceCommitLoad, mainResource);
             }
         }
     },
@@ -239,7 +247,7 @@ WebInspector.NetworkManager.prototype = {
         resource.webSocketRequestKey3 = request.webSocketRequestKey3;
         resource.startTime = time;
 
-        WebInspector.panels.network.refreshResource(resource);
+        this._updateResource(resource);
     },
 
     didReceiveWebSocketHandshakeResponse: function(identifier, time, response)
@@ -254,7 +262,7 @@ WebInspector.NetworkManager.prototype = {
         resource.webSocketChallengeResponse = response.webSocketChallengeResponse;
         resource.responseReceivedTime = time;
 
-        WebInspector.panels.network.refreshResource(resource);
+        this._updateResource(resource);
     },
 
     didCloseWebSocket: function(identifier, time)
@@ -283,20 +291,24 @@ WebInspector.NetworkManager.prototype = {
         return newResource;
     },
 
-    _startResource: function(resource, skipRefresh)
+    _startResource: function(resource)
     {
         this._inflightResources[resource.identifier] = resource;
-        WebInspector.panels.network.appendResource(resource, skipRefresh);
-        WebInspector.panels.audits.resourceStarted(resource);
+        this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceStarted, resource);
+    },
+
+    _updateResource: function(resource)
+    {
+        this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceUpdated, resource);
     },
 
     _finishResource: function(resource, finishTime)
     {
         resource.endTime = finishTime;
         resource.finished = true;
-        WebInspector.panels.network.refreshResource(resource);
-        WebInspector.panels.audits.resourceFinished(resource);
-        WebInspector.extensionServer.notifyResourceFinished(resource);
+        this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceFinished, resource);
         delete this._inflightResources[resource.identifier];
     }
 }
+
+WebInspector.NetworkManager.prototype.__proto__ = WebInspector.Object.prototype;
diff --git a/Source/WebCore/inspector/front-end/NetworkPanel.js b/Source/WebCore/inspector/front-end/NetworkPanel.js
index 28cbd36..943ee7f 100644
--- a/Source/WebCore/inspector/front-end/NetworkPanel.js
+++ b/Source/WebCore/inspector/front-end/NetworkPanel.js
@@ -78,6 +78,11 @@ WebInspector.NetworkPanel = function()
     this._filter(this._filterAllElement, false);
 
     this._toggleGridMode();
+
+    WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceStarted, this._onResourceStarted, this);
+    WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceUpdated, this._onResourceUpdated, this);
+    WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._onResourceUpdated, this);
+    WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.MainResourceCommitLoad, this._onMainResourceCommitLoad, this);
 }
 
 WebInspector.NetworkPanel.prototype = {
@@ -772,7 +777,12 @@ WebInspector.NetworkPanel.prototype = {
         return this._resourcesById[id];
     },
 
-    appendResource: function(resource)
+    _onResourceStarted: function(event)
+    {
+        this._appendResource(event.data);
+    },
+
+    _appendResource: function(resource)
     {
         this._resources.push(resource);
         this._resourcesById[resource.identifier] = resource;
@@ -781,13 +791,18 @@ WebInspector.NetworkPanel.prototype = {
         // Pull all the redirects of the main resource upon commit load.
         if (resource.redirects) {
             for (var i = 0; i < resource.redirects.length; ++i)
-                this.refreshResource(resource.redirects[i]);
+                this._refreshResource(resource.redirects[i]);
         }
 
-        this.refreshResource(resource);
+        this._refreshResource(resource);
+    },
+
+    _onResourceUpdated: function(event)
+    {
+        this._refreshResource(event.data);
     },
 
-    refreshResource: function(resource)
+    _refreshResource: function(resource)
     {
         this._staleResources.push(resource);
         this._scheduleRefresh();
@@ -811,7 +826,7 @@ WebInspector.NetworkPanel.prototype = {
         this._reset();
     },
 
-    mainResourceChanged: function()
+    _onMainResourceCommitLoad: function()
     {
         if (this._preserveLogToggle.toggled)
             return;
@@ -819,7 +834,7 @@ WebInspector.NetworkPanel.prototype = {
         this._reset();
         // Now resurrect the main resource along with all redirects that lead to it.
         var resourcesToAppend = (WebInspector.mainResource.redirects || []).concat(WebInspector.mainResource);
-        resourcesToAppend.forEach(this.appendResource, this);
+        resourcesToAppend.forEach(this._appendResource, this);
     },
 
     canShowSourceLine: function(url, line)
diff --git a/Source/WebCore/inspector/front-end/ResourcesPanel.js b/Source/WebCore/inspector/front-end/ResourcesPanel.js
index d96989b..7e1fcc0 100644
--- a/Source/WebCore/inspector/front-end/ResourcesPanel.js
+++ b/Source/WebCore/inspector/front-end/ResourcesPanel.js
@@ -78,6 +78,8 @@ WebInspector.ResourcesPanel = function(database)
 
     this.sidebarElement.addEventListener("mousemove", this._onmousemove.bind(this), false);
     this.sidebarElement.addEventListener("mouseout", this._onmouseout.bind(this), false);
+
+    WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceUpdated, this._refreshResource, this);
 }
 
 WebInspector.ResourcesPanel.prototype = {
@@ -253,8 +255,9 @@ WebInspector.ResourcesPanel.prototype = {
             frameTreeElement.removeChildren();
     },
 
-    refreshResource: function(resource)
+    _refreshResource: function(event)
     {
+        var resource = event.data;
         // FIXME: do not add XHR in the first place based on the native instrumentation.
         if (resource.type === WebInspector.Resource.Type.XHR) {
             var resourceTreeElement = this._findTreeElementForResource(resource);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list