2011-12-14 Ilya Tikhonovsky <loislo@chromium.org>
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Dec 2011 19:33:47 +0000 (19:33 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Dec 2011 19:33:47 +0000 (19:33 +0000)
        Web Inspector: consider disabling network tracking while running the CPU profile.
        https://bugs.webkit.org/show_bug.cgi?id=74221

        The WebCore instrumentation on the backend affects the performance of inspected page.
        As the result the CPU profiler's stats data are far away from the reality.
        Solution: the profiler code will temporary disable the resource tracking on backend.
        Side effect: the resource tree gets out of sinc because it uses Network Agent's notifications for updating the resource tree.
        Solution: NetworkManager will report about the changes of the resource tracking state and ResourcePanel will re-fetch the resources tree.

        Reviewed by Pavel Feldman.

        * inspector/front-end/NetworkManager.js:
        (WebInspector.NetworkManager.prototype.enableResourceTracking.networkAgentEnabled):
        (WebInspector.NetworkManager.prototype.enableResourceTracking):
        (WebInspector.NetworkManager.prototype.disableResourceTracking.networkAgentDisabled):
        (WebInspector.NetworkManager.prototype.disableResourceTracking):
        (WebInspector.NetworkManager.prototype.inflightResourceForURL):
        * inspector/front-end/ProfileView.js:
        (WebInspector.CPUProfileType.prototype.buttonClicked):
        * inspector/front-end/ResourceTreeModel.js:
        (WebInspector.ResourceTreeModel):
        (WebInspector.ResourceTreeModel.prototype._onResourceTrackingEnabled):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@102803 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/NetworkManager.js
Source/WebCore/inspector/front-end/ProfileView.js
Source/WebCore/inspector/front-end/ResourceTreeModel.js

index f80f22c0b654858308b4d921e34d752e19ad123a..56e8160eb555bbf79348a83d2500aaf6a145c4b9 100644 (file)
@@ -1,3 +1,28 @@
+2011-12-14  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: consider disabling network tracking while running the CPU profile.
+        https://bugs.webkit.org/show_bug.cgi?id=74221
+
+        The WebCore instrumentation on the backend affects the performance of inspected page.
+        As the result the CPU profiler's stats data are far away from the reality.
+        Solution: the profiler code will temporary disable the resource tracking on backend.
+        Side effect: the resource tree gets out of sinc because it uses Network Agent's notifications for updating the resource tree.
+        Solution: NetworkManager will report about the changes of the resource tracking state and ResourcePanel will re-fetch the resources tree.
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/front-end/NetworkManager.js:
+        (WebInspector.NetworkManager.prototype.enableResourceTracking.networkAgentEnabled):
+        (WebInspector.NetworkManager.prototype.enableResourceTracking):
+        (WebInspector.NetworkManager.prototype.disableResourceTracking.networkAgentDisabled):
+        (WebInspector.NetworkManager.prototype.disableResourceTracking):
+        (WebInspector.NetworkManager.prototype.inflightResourceForURL):
+        * inspector/front-end/ProfileView.js:
+        (WebInspector.CPUProfileType.prototype.buttonClicked):
+        * inspector/front-end/ResourceTreeModel.js:
+        (WebInspector.ResourceTreeModel):
+        (WebInspector.ResourceTreeModel.prototype._onResourceTrackingEnabled):
+
 2011-12-14  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Fix PlatformScreen::screenAvailableRect when there's no view widget
index d6cf706d5a4a7ed512459d0e7996e4d02cd49cdf..681d56888672bb4dc25ca7934a92ec281b44d2af 100644 (file)
@@ -38,7 +38,9 @@ WebInspector.NetworkManager = function()
     this._dispatcher = new WebInspector.NetworkDispatcher(this);
     if (WebInspector.settings.cacheDisabled.get())
         NetworkAgent.setCacheDisabled(true);
+
     NetworkAgent.enable();
+    this._resourceTracking = true;
 
     WebInspector.settings.cacheDisabled.addChangeListener(this._cacheDisabledSettingChanged, this);
 
@@ -48,6 +50,8 @@ WebInspector.NetworkManager = function()
 }
 
 WebInspector.NetworkManager.EventTypes = {
+    ResourceTrackingEnabled: "ResourceTrackingEnabled",
+    ResourceTrackingDisabled: "ResourceTrackingDisabled",
     ResourceStarted: "ResourceStarted",
     ResourceUpdated: "ResourceUpdated",
     ResourceFinished: "ResourceFinished",
@@ -72,6 +76,28 @@ WebInspector.NetworkManager.prototype = {
             PageAgent.getResourceContent(resource.frameId, resource.url, callbackWrapper);
     },
 
+    enableResourceTracking: function()
+    {
+        function networkAgentEnabled()
+        {
+            this._resourceTracking = true;
+            this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceTrackingEnabled);
+        }
+
+        NetworkAgent.enable(networkAgentEnabled.bind(this));
+    },
+
+    disableResourceTracking: function()
+    {
+        function networkAgentDisabled()
+        {
+            this._resourceTracking = false;
+            this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceTrackingDisabled);
+        }
+
+        NetworkAgent.disable(networkAgentDisabled.bind(this));
+    },
+
     inflightResourceForURL: function(url)
     {
         return this._dispatcher._inflightResourcesByURL[url];
index 74cd3b2e66acd3896222625a815987a918b2b1a5..8547a6db1a85b278ab466b2d5935b5d18561a453 100644 (file)
@@ -586,10 +586,13 @@ WebInspector.CPUProfileType.prototype = {
     {
         this._recording = !this._recording;
 
-        if (this._recording)
+        if (this._recording) {
+            WebInspector.networkManager.disableResourceTracking();
             ProfilerAgent.start();
-        else
+        } else {
             ProfilerAgent.stop();
+            WebInspector.networkManager.enableResourceTracking();
+        }
     },
 
     get welcomeMessage()
index edc5fde0a31993f56aefcdd41b9709312fdf147b..d74b257e374dbae7f64415e809c37673254c4560 100644 (file)
@@ -35,6 +35,7 @@
  */
 WebInspector.ResourceTreeModel = function(networkManager)
 {
+    networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceTrackingEnabled, this._onResourceTrackingEnabled, this);
     networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceUpdated, this._onResourceUpdated, this);
     networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._onResourceUpdated, this);
     networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceUpdateDropped, this._onResourceUpdateDropped, this);
@@ -45,7 +46,9 @@ WebInspector.ResourceTreeModel = function(networkManager)
 
     PageAgent.enable();
 
+    NetworkAgent.enable();
     this._fetchResourceTree();
+
     InspectorBackend.registerPageDispatcher(new WebInspector.PageDispatcher(this));
 
     this._pendingConsoleMessages = {};
@@ -66,6 +69,11 @@ WebInspector.ResourceTreeModel.EventTypes = {
 }
 
 WebInspector.ResourceTreeModel.prototype = {
+    _onResourceTrackingEnabled: function()
+    {
+        this._fetchResourceTree();
+    },
+
     _fetchResourceTree: function()
     {
         this._frames = {};