<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[128875] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/128875">128875</a></dd>
<dt>Author</dt> <dd>caseq@chromium.org</dd>
<dt>Date</dt> <dd>2012-09-18 04:41:16 -0700 (Tue, 18 Sep 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: [Extensions API] explicitly manage extension audit progress
https://bugs.webkit.org/show_bug.cgi?id=96803

Reviewed by Alexander Pavlov.

Source/WebCore:

- create a sub-progress per audit category;
- manage audit category progress within the category, not in the panel logic;
- consider audit is done when all categories are done;
- expose AuditResults.updateProgress(worked, totalWork) in the extensions API;
- retain old magic for computing audit progress if extension specifies extension results count.

* inspector/front-end/AuditsPanel.js:
(WebInspector.AuditsPanel.prototype._executeAudit.ruleResultReadyCallback):
(WebInspector.AuditsPanel.prototype._executeAudit):
(WebInspector.AuditCategory.prototype.run.callbackWrapper):
(WebInspector.AuditCategory.prototype.run):
* inspector/front-end/ExtensionAPI.js:
(defineCommonExtensionSymbols):
(injectedExtensionAPI.Audits.prototype.addCategory):
(injectedExtensionAPI.AuditResultImpl.prototype.updateProgress):
* inspector/front-end/ExtensionAuditCategory.js:
(WebInspector.ExtensionAuditCategory.prototype.run):
(WebInspector.ExtensionAuditCategoryResults):
(WebInspector.ExtensionAuditCategoryResults.prototype.done):
(WebInspector.ExtensionAuditCategoryResults.prototype._addResult):
(WebInspector.ExtensionAuditCategoryResults.prototype.updateProgress):
* inspector/front-end/ExtensionServer.js:
(WebInspector.ExtensionServer):
(WebInspector.ExtensionServer.prototype._onUpdateAuditProgress):
(WebInspector.ExtensionServer.prototype._onStopAuditCategoryRun):
* inspector/front-end/ProgressBar.js:
(WebInspector.ProgressIndicator.prototype.done): Assure only first call to done() has effect.

LayoutTests:

* inspector/extensions/extensions-audits-api-expected.txt: Added AuditResults.updateProgress()
* inspector/extensions/extensions-audits.html: Added a call to updateProgress()</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsinspectorextensionsextensionsauditsapiexpectedtxt">trunk/LayoutTests/inspector/extensions/extensions-audits-api-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorextensionsextensionsauditsexpectedtxt">trunk/LayoutTests/inspector/extensions/extensions-audits-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorextensionsextensionsauditstestsjs">trunk/LayoutTests/inspector/extensions/extensions-audits-tests.js</a></li>
<li><a href="#trunkLayoutTestsinspectorextensionsextensionsauditshtml">trunk/LayoutTests/inspector/extensions/extensions-audits.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreinspectorfrontendAuditsPaneljs">trunk/Source/WebCore/inspector/front-end/AuditsPanel.js</a></li>
<li><a href="#trunkSourceWebCoreinspectorfrontendExtensionAPIjs">trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js</a></li>
<li><a href="#trunkSourceWebCoreinspectorfrontendExtensionAuditCategoryjs">trunk/Source/WebCore/inspector/front-end/ExtensionAuditCategory.js</a></li>
<li><a href="#trunkSourceWebCoreinspectorfrontendExtensionServerjs">trunk/Source/WebCore/inspector/front-end/ExtensionServer.js</a></li>
<li><a href="#trunkSourceWebCoreinspectorfrontendProgressBarjs">trunk/Source/WebCore/inspector/front-end/ProgressBar.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (128874 => 128875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/LayoutTests/ChangeLog        2012-09-18 11:41:16 UTC (rev 128875)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2012-09-14  Andrey Kosyakov  &lt;caseq@chromium.org&gt;
+
+        Web Inspector: [Extensions API] explicitly manage extension audit progress
+        https://bugs.webkit.org/show_bug.cgi?id=96803
+
+        Reviewed by Alexander Pavlov.
+
+        * inspector/extensions/extensions-audits-api-expected.txt: Added AuditResults.updateProgress()
+        * inspector/extensions/extensions-audits.html: Added a call to updateProgress()
+
</ins><span class="cx"> 2012-09-18  Raphael Kubo da Costa  &lt;raphael.kubo.da.costa@intel.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [EFL] Unreviewed gardening.
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorextensionsextensionsauditsapiexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/extensions/extensions-audits-api-expected.txt (128874 => 128875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/extensions/extensions-audits-api-expected.txt        2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/LayoutTests/inspector/extensions/extensions-audits-api-expected.txt        2012-09-18 11:41:16 UTC (rev 128875)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx">     createText : &lt;function&gt;
</span><span class="cx">     createURL : &lt;function&gt;
</span><span class="cx">     done : &lt;function&gt;
</span><ins>+    updateProgress : &lt;function&gt;
</ins><span class="cx"> }
</span><span class="cx"> {
</span><span class="cx">     children : {
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorextensionsextensionsauditsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/extensions/extensions-audits-expected.txt (128874 => 128875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/extensions/extensions-audits-expected.txt        2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/LayoutTests/inspector/extensions/extensions-audits-expected.txt        2012-09-18 11:41:16 UTC (rev 128875)
</span><span class="lines">@@ -3,6 +3,8 @@
</span><span class="cx">  Started extension.
</span><span class="cx"> Running tests...
</span><span class="cx"> RUNNING TEST: extension_testAudits
</span><ins>+Progress: 50%
+Progress: 75%
</ins><span class="cx">   Extension audits
</span><span class="cx">     Failed rule (42)
</span><span class="cx">      this rule always fails
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorextensionsextensionsauditstestsjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/extensions/extensions-audits-tests.js (128874 => 128875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/extensions/extensions-audits-tests.js        2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/LayoutTests/inspector/extensions/extensions-audits-tests.js        2012-09-18 11:41:16 UTC (rev 128875)
</span><span class="lines">@@ -29,4 +29,10 @@
</span><span class="cx"> 
</span><span class="cx">         launcherView._launchButtonClicked();
</span><span class="cx">     }
</span><ins>+
+    InspectorTest.dumpAuditProgress = function()
+    {
+        var progress = document.querySelector(&quot;.panel.audits progress&quot;);
+        InspectorTest.addResult(&quot;Progress: &quot; + Math.round(100 * progress.value / progress.max) + &quot;%&quot;);
+    }
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorextensionsextensionsauditshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/extensions/extensions-audits.html (128874 => 128875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/extensions/extensions-audits.html        2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/LayoutTests/inspector/extensions/extensions-audits.html        2012-09-18 11:41:16 UTC (rev 128875)
</span><span class="lines">@@ -29,12 +29,11 @@
</span><span class="cx">         webInspector.inspectedWindow.eval(&quot;location.href&quot;, function(inspectedPageURL) {
</span><span class="cx">             nestedNode.addChild(results.createResourceLink(inspectedPageURL, 20));
</span><span class="cx"> 
</span><del>-            results.addResult(&quot;Rule with details subtree (1)&quot;, &quot;This rule has a lot of details&quot;, results.Severity.Warning, node);
-
-            // Audit normally terminates when number of added rule results is equal to
-            // the rule count declared when adding a category. done() is only for
-            // emergency cases, when we know we won't be able to run the rest of the rules.
-            results.done();
</del><ins>+            evaluateOnFrontend(&quot;InspectorTest.dumpAuditProgress(); reply();&quot;, function() {
+                results.addResult(&quot;Rule with details subtree (1)&quot;, &quot;This rule has a lot of details&quot;, results.Severity.Warning, node);
+                results.updateProgress(10, 20);
+                evaluateOnFrontend(&quot;InspectorTest.dumpAuditProgress(); reply();&quot;, results.done.bind(results));
+            });
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx">     function onStartAuditFailedCategory()
</span><span class="lines">@@ -48,7 +47,7 @@
</span><span class="cx">         results.done();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    var category = webInspector.audits.addCategory(&quot;Extension audits&quot;, 20);
</del><ins>+    var category = webInspector.audits.addCategory(&quot;Extension audits&quot;);
</ins><span class="cx">     category.onAuditStarted.addListener(onStartAuditCategory);
</span><span class="cx"> 
</span><span class="cx">     var failedCategory = webInspector.audits.addCategory(&quot;Extension audits that fail&quot;, 2);
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (128874 => 128875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/Source/WebCore/ChangeLog        2012-09-18 11:41:16 UTC (rev 128875)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2012-09-14  Andrey Kosyakov  &lt;caseq@chromium.org&gt;
+
+        Web Inspector: [Extensions API] explicitly manage extension audit progress
+        https://bugs.webkit.org/show_bug.cgi?id=96803
+
+        Reviewed by Alexander Pavlov.
+
+        - create a sub-progress per audit category;
+        - manage audit category progress within the category, not in the panel logic;
+        - consider audit is done when all categories are done;
+        - expose AuditResults.updateProgress(worked, totalWork) in the extensions API;
+        - retain old magic for computing audit progress if extension specifies extension results count.
+
+        * inspector/front-end/AuditsPanel.js:
+        (WebInspector.AuditsPanel.prototype._executeAudit.ruleResultReadyCallback):
+        (WebInspector.AuditsPanel.prototype._executeAudit):
+        (WebInspector.AuditCategory.prototype.run.callbackWrapper):
+        (WebInspector.AuditCategory.prototype.run):
+        * inspector/front-end/ExtensionAPI.js:
+        (defineCommonExtensionSymbols):
+        (injectedExtensionAPI.Audits.prototype.addCategory):
+        (injectedExtensionAPI.AuditResultImpl.prototype.updateProgress):
+        * inspector/front-end/ExtensionAuditCategory.js:
+        (WebInspector.ExtensionAuditCategory.prototype.run):
+        (WebInspector.ExtensionAuditCategoryResults):
+        (WebInspector.ExtensionAuditCategoryResults.prototype.done):
+        (WebInspector.ExtensionAuditCategoryResults.prototype._addResult):
+        (WebInspector.ExtensionAuditCategoryResults.prototype.updateProgress):
+        * inspector/front-end/ExtensionServer.js:
+        (WebInspector.ExtensionServer):
+        (WebInspector.ExtensionServer.prototype._onUpdateAuditProgress):
+        (WebInspector.ExtensionServer.prototype._onStopAuditCategoryRun):
+        * inspector/front-end/ProgressBar.js:
+        (WebInspector.ProgressIndicator.prototype.done): Assure only first call to done() has effect.
+
</ins><span class="cx"> 2012-09-19  Allan Sandfeld Jensen  &lt;allan.jensen@nokia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Revert r127457 and following fixes due to several hit-testing regressions
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorfrontendAuditsPaneljs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/front-end/AuditsPanel.js (128874 => 128875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/front-end/AuditsPanel.js        2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/Source/WebCore/inspector/front-end/AuditsPanel.js        2012-09-18 11:41:16 UTC (rev 128875)
</span><span class="lines">@@ -98,43 +98,38 @@
</span><span class="cx"> 
</span><span class="cx">     _executeAudit: function(categories, resultCallback)
</span><span class="cx">     {
</span><del>-        var requests = WebInspector.networkLog.requests;
-
-        var rulesRemaining = 0;
-        for (var i = 0; i &lt; categories.length; ++i)
-            rulesRemaining += categories[i].ruleCount;
-
-        this._progress.setTotalWork(rulesRemaining);
</del><span class="cx">         this._progress.setTitle(WebInspector.UIString(&quot;Running audit&quot;));
</span><span class="cx"> 
</span><del>-        var results = [];
-        var mainResourceURL = WebInspector.inspectedPageURL;
-
</del><span class="cx">         function ruleResultReadyCallback(categoryResult, ruleResult)
</span><span class="cx">         {
</span><del>-            if (this._progress.isCanceled())
-                return;
-
</del><span class="cx">             if (ruleResult &amp;&amp; ruleResult.children)
</span><span class="cx">                 categoryResult.addRuleResult(ruleResult);
</span><span class="cx"> 
</span><del>-            --rulesRemaining;
-            this._progress.worked();
-
-            if (!rulesRemaining || this._progress.isCanceled())
-                resultCallback(mainResourceURL, results);
</del><ins>+            if (this._progress.isCanceled())
+                this._progress.done();
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (!rulesRemaining || this._progress.isCanceled()) {
-            resultCallback(mainResourceURL, results);
-            return;
</del><ins>+        var results = [];
+        var mainResourceURL = WebInspector.inspectedPageURL;
+        var categoriesDone = 0;
+        function categoryDoneCallback()
+        {
+            if (++categoriesDone !== categories.length)
+                return;
+            this._progress.done();
+            resultCallback(mainResourceURL, results)
</ins><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        var requests = WebInspector.networkLog.requests.slice();
+        var compositeProgress = new WebInspector.CompositeProgress(this._progress);
+        var subprogresses = [];
+        for (var i = 0; i &lt; categories.length; ++i)
+            subprogresses.push(compositeProgress.createSubProgress());
</ins><span class="cx">         for (var i = 0; i &lt; categories.length; ++i) {
</span><span class="cx">             var category = categories[i];
</span><span class="cx">             var result = new WebInspector.AuditCategoryResult(category);
</span><span class="cx">             results.push(result);
</span><del>-            category.run(requests, ruleResultReadyCallback.bind(this, result), this._progress);
</del><ins>+            category.run(requests, ruleResultReadyCallback.bind(this, result), categoryDoneCallback.bind(this), subprogresses[i]);
</ins><span class="cx">         }
</span><span class="cx">     },
</span><span class="cx"> 
</span><span class="lines">@@ -270,12 +265,6 @@
</span><span class="cx">         return this._displayName;
</span><span class="cx">     },
</span><span class="cx"> 
</span><del>-    get ruleCount()
-    {
-        this._ensureInitialized();
-        return this._rules.length;
-    },
-
</del><span class="cx">     addRule: function(rule, severity)
</span><span class="cx">     {
</span><span class="cx">         rule.severity = severity;
</span><span class="lines">@@ -284,14 +273,24 @@
</span><span class="cx"> 
</span><span class="cx">     /**
</span><span class="cx">      * @param {Array.&lt;WebInspector.NetworkRequest&gt;} requests
</span><del>-     * @param {function()} callback
</del><ins>+     * @param {function(WebInspector.AuditRuleResult)} ruleResultCallback
+     * @param {function()} categoryDoneCallback
</ins><span class="cx">      * @param {WebInspector.Progress} progress
</span><span class="cx">      */
</span><del>-    run: function(requests, callback, progress)
</del><ins>+    run: function(requests, ruleResultCallback, categoryDoneCallback, progress)
</ins><span class="cx">     {
</span><span class="cx">         this._ensureInitialized();
</span><ins>+        var remainingRulesCount = this._rules.length;
+        progress.setTotalWork(remainingRulesCount);
+        function callbackWrapper()
+        {
+            ruleResultCallback.apply(this, arguments);
+            progress.worked();
+            if (!--remainingRulesCount)
+                categoryDoneCallback();
+        }
</ins><span class="cx">         for (var i = 0; i &lt; this._rules.length; ++i)
</span><del>-            this._rules[i].run(requests, callback, progress);
</del><ins>+            this._rules[i].run(requests, callbackWrapper, progress);
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     _ensureInitialized: function()
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorfrontendExtensionAPIjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js (128874 => 128875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js        2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js        2012-09-18 11:41:16 UTC (rev 128875)
</span><span class="lines">@@ -97,6 +97,7 @@
</span><span class="cx">         ShowPanel: &quot;showPanel&quot;,
</span><span class="cx">         StopAuditCategoryRun: &quot;stopAuditCategoryRun&quot;,
</span><span class="cx">         Unsubscribe: &quot;unsubscribe&quot;,
</span><ins>+        UpdateAuditProgress: &quot;updateAuditProgress&quot;,
</ins><span class="cx">         UpdateButton: &quot;updateButton&quot;,
</span><span class="cx">         InspectedURLChanged: &quot;inspectedURLChanged&quot;
</span><span class="cx">     };
</span><span class="lines">@@ -509,6 +510,8 @@
</span><span class="cx">     addCategory: function(displayName, resultCount)
</span><span class="cx">     {
</span><span class="cx">         var id = &quot;extension-audit-category-&quot; + extensionServer.nextObjectId();
</span><ins>+        if (typeof resultCount !== &quot;undefined&quot;)
+            console.warn(&quot;Passing resultCount to audits.addCategory() is deprecated. Use AuditResult.updateProgress() instead.&quot;);
</ins><span class="cx">         extensionServer.sendRequest({ command: commands.AddAuditCategory, id: id, displayName: displayName, resultCount: resultCount });
</span><span class="cx">         return new AuditCategory(id);
</span><span class="cx">     }
</span><span class="lines">@@ -570,6 +573,11 @@
</span><span class="cx">         return new AuditResultNode(Array.prototype.slice.call(arguments));
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    updateProgress: function(worked, totalWork)
+    {
+        extensionServer.sendRequest({ command: commands.UpdateAuditProgress, resultId: this._id, progress: worked / totalWork });
+    },
+
</ins><span class="cx">     done: function()
</span><span class="cx">     {
</span><span class="cx">         extensionServer.sendRequest({ command: commands.StopAuditCategoryRun, resultId: this._id });
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorfrontendExtensionAuditCategoryjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/front-end/ExtensionAuditCategory.js (128874 => 128875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/front-end/ExtensionAuditCategory.js        2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionAuditCategory.js        2012-09-18 11:41:16 UTC (rev 128875)
</span><span class="lines">@@ -30,10 +30,11 @@
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * @constructor
</span><ins>+ * @extends {WebInspector.AuditCategory}
</ins><span class="cx">  * @param {string} extensionOrigin
</span><span class="cx">  * @param {string} id
</span><span class="cx">  * @param {string} displayName
</span><del>- * @param {number} ruleCount
</del><ins>+ * @param {number=} ruleCount
</ins><span class="cx">  */
</span><span class="cx"> WebInspector.ExtensionAuditCategory = function(extensionOrigin, id, displayName, ruleCount)
</span><span class="cx"> {
</span><span class="lines">@@ -55,44 +56,47 @@
</span><span class="cx">         return this._displayName;
</span><span class="cx">     },
</span><span class="cx"> 
</span><del>-    get ruleCount()
</del><ins>+    /**
+     * @param {Array.&lt;WebInspector.NetworkRequest&gt;} requests
+     * @param {function(WebInspector.AuditRuleResult)} ruleResultCallback
+     * @param {function()} categoryDoneCallback
+     * @param {WebInspector.Progress} progress
+     */
+    run: function(requests, ruleResultCallback, categoryDoneCallback, progress)
</ins><span class="cx">     {
</span><del>-        return this._ruleCount;
-    },
-
-    run: function(resources, callback)
-    {
-        new WebInspector.ExtensionAuditCategoryResults(this, callback);
</del><ins>+        var results = new WebInspector.ExtensionAuditCategoryResults(this, ruleResultCallback, categoryDoneCallback, progress);
+        WebInspector.extensionServer.startAuditRun(this, results);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * @constructor
</span><span class="cx">  * @param {WebInspector.ExtensionAuditCategory} category
</span><del>- * @param {function(WebInspector.AuditRuleResult)} callback
</del><ins>+ * @param {function(WebInspector.AuditRuleResult)} ruleResultCallback
+ * @param {function()} categoryDoneCallback
+ * @param {WebInspector.Progress} progress
</ins><span class="cx">  */
</span><del>-WebInspector.ExtensionAuditCategoryResults = function(category, callback)
</del><ins>+WebInspector.ExtensionAuditCategoryResults = function(category, ruleResultCallback, categoryDoneCallback, progress)
</ins><span class="cx"> {
</span><span class="cx">     this._category = category;
</span><del>-    this._pendingRules = category.ruleCount;
-    this._ruleCompletionCallback = callback;
</del><ins>+    this._ruleResultCallback = ruleResultCallback;
+    this._categoryDoneCallback = categoryDoneCallback;
+    this._progress = progress;
+    this._progress.setTotalWork(1);
+    this._expectedResults = category._ruleCount;
+    this._actualResults = 0;
</ins><span class="cx"> 
</span><span class="cx">     this.id = category.id + &quot;-&quot; + ++WebInspector.ExtensionAuditCategoryResults._lastId;
</span><del>-    WebInspector.extensionServer.startAuditRun(category, this);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebInspector.ExtensionAuditCategoryResults.prototype = {
</span><del>-    get complete()
</del><ins>+    done: function()
</ins><span class="cx">     {
</span><del>-        return !this._pendingRules;
</del><ins>+        WebInspector.extensionServer.stopAuditRun(this);
+        this._progress.done();
+        this._categoryDoneCallback();
</ins><span class="cx">     },
</span><span class="cx"> 
</span><del>-    cancel: function()
-    {
-        while (!this.complete)
-            this._addResult(null);
-    },
-
</del><span class="cx">     addResult: function(displayName, description, severity, details)
</span><span class="cx">     {
</span><span class="cx">         var result = new WebInspector.AuditRuleResult(displayName);
</span><span class="lines">@@ -115,13 +119,24 @@
</span><span class="cx"> 
</span><span class="cx">     _addResult: function(result)
</span><span class="cx">     {
</span><del>-        this._ruleCompletionCallback(result);
-        this._pendingRules--;
-        if (!this._pendingRules)
-            WebInspector.extensionServer.stopAuditRun(this);
</del><ins>+        this._ruleResultCallback(result);
+        ++this._actualResults;
+        if (typeof this._expectedResults === &quot;number&quot;) {
+            this._progress.setWorked(this._actualResults / this._expectedResults);
+            if (this._actualResults === this._expectedResults)
+                this.done();
+        }
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     /**
</span><ins>+     * @param {number} progress
+     */
+    updateProgress: function(progress)
+    {
+        this._progress.setWorked(progress);
+    },
+
+    /**
</ins><span class="cx">      * @param {string} expression
</span><span class="cx">      * @param {function(WebInspector.RemoteObject)} callback
</span><span class="cx">      */
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorfrontendExtensionServerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/front-end/ExtensionServer.js (128874 => 128875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/front-end/ExtensionServer.js        2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionServer.js        2012-09-18 11:41:16 UTC (rev 128875)
</span><span class="lines">@@ -71,6 +71,7 @@
</span><span class="cx">     this._registerHandler(commands.Subscribe, this._onSubscribe.bind(this));
</span><span class="cx">     this._registerHandler(commands.Unsubscribe, this._onUnsubscribe.bind(this));
</span><span class="cx">     this._registerHandler(commands.UpdateButton, this._onUpdateButton.bind(this));
</span><ins>+    this._registerHandler(commands.UpdateAuditProgress, this._onUpdateAuditProgress.bind(this));
</ins><span class="cx"> 
</span><span class="cx">     window.addEventListener(&quot;message&quot;, this._onWindowMessage.bind(this), false);
</span><span class="cx"> }
</span><span class="lines">@@ -550,12 +551,20 @@
</span><span class="cx">         return this._status.OK();
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    _onUpdateAuditProgress: function(message)
+    {
+        var auditResult = this._clientObjects[message.resultId];
+        if (!auditResult)
+            return this._status.E_NOTFOUND(message.resultId);
+        auditResult.updateProgress(Math.min(Math.max(0, message.progress), 1));
+    },
+
</ins><span class="cx">     _onStopAuditCategoryRun: function(message)
</span><span class="cx">     {
</span><span class="cx">         var auditRun = this._clientObjects[message.resultId];
</span><span class="cx">         if (!auditRun)
</span><span class="cx">             return this._status.E_NOTFOUND(message.resultId);
</span><del>-        auditRun.cancel();
</del><ins>+        auditRun.done();
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     _dispatchCallback: function(requestId, port, result)
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorfrontendProgressBarjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/front-end/ProgressBar.js (128874 => 128875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/front-end/ProgressBar.js        2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/Source/WebCore/inspector/front-end/ProgressBar.js        2012-09-18 11:41:16 UTC (rev 128875)
</span><span class="lines">@@ -105,6 +105,9 @@
</span><span class="cx"> 
</span><span class="cx">     done: function()
</span><span class="cx">     {
</span><ins>+        if (this._isDone)
+            return;
+        this._isDone = true;
</ins><span class="cx">         this.hide();
</span><span class="cx">         this.dispatchEventToListeners(WebInspector.ProgressIndicator.Events.Done);
</span><span class="cx">     },
</span></span></pre>
</div>
</div>

</body>
</html>