2010-09-14 Ilya Tikhonovsky <loislo@chromium.org>
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Sep 2010 11:17:48 +0000 (11:17 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Sep 2010 11:17:48 +0000 (11:17 +0000)
        Reviewed by Yury Semikhatsky.

        WebInspector: small refactoring for monitorXHR backend property.

        Our Inspector API is quite big and can be simplified a bit.
        As example for single backend property like monitoringXHR we
        have 4 functions in the API. Two functions for frontend
        enableMonitoringXHR/disableMonitoringXHR and
        two functions for backend monitoringXHRWasEnabled and
        monitoringXHRWasDisabled. These functions can be replaced by
        one setMonitoringXHR with one 'in' and one 'out' argument.
        The initial state of the flag can be gathered from backend
        with help of getSettings call where additional section was
        added for backend state information.

        https://bugs.webkit.org/show_bug.cgi?id=45759

        * inspector/Inspector.idl:
        * inspector/InspectorController.cpp:
        * inspector/InspectorController.h:
        * inspector/front-end/ConsoleView.js:
        * inspector/front-end/Settings.js:
        * inspector/front-end/inspector.js:

2010-09-14  Ilya Tikhonovsky  <loislo@chromium.org>

        Reviewed by Yury Semikhatsky.

        WebInspector: small refactoring for monitorXHR backend property.

        Our Inspector API is quite big and can be simplified a bit.
        As example for single backend property like monitoringXHR we
        have 4 functions in the API. Two functions for frontend
        enableMonitoringXHR/disableMonitoringXHR and
        two functions for backend monitoringXHRWasEnabled and
        monitoringXHRWasDisabled. These functions can be replaced by
        one setMonitoringXHR with one 'in' and one 'out' argument.
        The initial state of the flag can be gathered from backend
        with help of getSettings call where additional section was
        added for backend state information.

        https://bugs.webkit.org/show_bug.cgi?id=45759

        * inspector/Inspector.idl:
        * inspector/InspectorController.cpp:
        * inspector/InspectorController.h:
        * inspector/front-end/ConsoleView.js:
        * inspector/front-end/Settings.js:
        * inspector/front-end/inspector.js:

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

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/console-xhr-logging.html
LayoutTests/inspector/report-API-errors.html
WebCore/ChangeLog
WebCore/inspector/Inspector.idl
WebCore/inspector/InspectorController.cpp
WebCore/inspector/InspectorController.h
WebCore/inspector/front-end/ConsoleView.js
WebCore/inspector/front-end/Settings.js
WebCore/inspector/front-end/inspector.js

index 872814974e2417e2c5e8f6f1fe950f12bc9dd8c9..161e95a39da2d42eef33821a128df3d09cbda1f4 100644 (file)
@@ -1,3 +1,25 @@
+2010-09-14  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        WebInspector: small refactoring for monitorXHR backend property.
+
+        Our Inspector API is quite big and can be simplified a bit.
+        As example for single backend property like monitoringXHR we
+        have 4 functions in the API. Two functions for frontend
+        enableMonitoringXHR/disableMonitoringXHR and
+        two functions for backend monitoringXHRWasEnabled and
+        monitoringXHRWasDisabled. These functions can be replaced by
+        one setMonitoringXHR with one 'in' and one 'out' argument.
+        The initial state of the flag can be gathered from backend
+        with help of getSettings call where additional section was
+        added for backend state information.
+
+        https://bugs.webkit.org/show_bug.cgi?id=45759
+
+        * http/tests/inspector/console-xhr-logging.html:
+        * inspector/report-API-errors.html:
+
 2010-09-15  Steve Block  <steveblock@google.com>
 
         Reviewed by Kent Tamura.
index 825dc0524f5c3fac824d7d2861fb408d455f2a25..0bd755b698e1f1971ffc57168eb81b009b9ca60e 100755 (executable)
@@ -45,26 +45,28 @@ function requestHelper(method, url)
 
 function frontend_enableXMLHttpRequestLogging(testController)
 {
-    InspectorBackend.enableMonitoringXHR();
+    InspectorBackend.setMonitoringXHR(true, function(newStatus) {
+         if (newStatus)
+            testController.notifyDone("enabled");
+    });
+
     if (WebInspector.monitoringXHREnabled)
         return "enabled";
 
     testController.waitUntilDone();
-    frontend_addSniffer(WebInspector, "monitoringXHRWasEnabled", function() {
-         testController.notifyDone("enabled");
-    });
 }
 
 function frontend_disableXMLHttpRequestLogging(testController)
 {
-    InspectorBackend.disableMonitoringXHR();
+    InspectorBackend.setMonitoringXHR(false, function(newStatus) {
+        if (!newStatus)
+            testController.notifyDone("disabled");
+    });
+
     if (!WebInspector.monitoringXHREnabled)
         return "disabled";
 
     testController.waitUntilDone();
-    frontend_addSniffer(WebInspector, "monitoringXHRWasDisabled", function() {
-        testController.notifyDone("disabled");
-    });
 }
 
 </script>
index 0ddd9b88c764303d491ab8d026d7ecfd9cd10b83..c5dcf1a7c1310ec5dbe9446c2936e4314cea3493 100644 (file)
@@ -14,8 +14,8 @@ function test()
     InspectorBackend.enableResourceTracking(1);
     InspectorBackend.enableResourceTracking();
     InspectorBackend.enableResourceTracking(true, "not a function");
-    InspectorBackend.enableMonitoringXHR(undefined);
-    InspectorBackend.disableMonitoringXHR(undefined);
+    InspectorBackend.setMonitoringXHR(true, undefined);
+    InspectorBackend.setMonitoringXHR(false, undefined);
     WebInspector_syncDispatch('{"type": "event", "domain": "dom", "event": "something-strange", "data": {}}');
 
     InspectorTest.completeTest();
index 033ace7198c578e85a38c14a7d2e852e5b1a4902..f9143fb127a0c8dd57a20ca51ccec5510210ef92 100644 (file)
@@ -1,3 +1,29 @@
+2010-09-14  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        WebInspector: small refactoring for monitorXHR backend property.
+
+        Our Inspector API is quite big and can be simplified a bit.
+        As example for single backend property like monitoringXHR we
+        have 4 functions in the API. Two functions for frontend
+        enableMonitoringXHR/disableMonitoringXHR and
+        two functions for backend monitoringXHRWasEnabled and
+        monitoringXHRWasDisabled. These functions can be replaced by
+        one setMonitoringXHR with one 'in' and one 'out' argument.
+        The initial state of the flag can be gathered from backend
+        with help of getSettings call where additional section was
+        added for backend state information.
+
+        https://bugs.webkit.org/show_bug.cgi?id=45759
+
+        * inspector/Inspector.idl:
+        * inspector/InspectorController.cpp:
+        * inspector/InspectorController.h:
+        * inspector/front-end/ConsoleView.js:
+        * inspector/front-end/Settings.js:
+        * inspector/front-end/inspector.js:
+
 2010-09-15  Pavel Feldman  <pfeldman@chromium.org>
 
         Reviewed by Yury Semikhatsky.
index 169b188ac430758a63991d7ff8d4e03a8dd22f2f..26f26534f450b36c32e6cecb9f23e6b7cb4b36a9 100644 (file)
@@ -44,8 +44,6 @@ module core {
         [notify] void evaluateForTestInFrontend(out long testCallId, out String script);
         [notify] void disconnectFromBackend();
         [notify] void inspectedURLChanged(out String url);
-        [notify] void monitoringXHRWasEnabled();
-        [notify] void monitoringXHRWasDisabled();
         [notify] void removeResource(out unsigned long identifier);
         [notify] void reset();
         [notify] void resetProfilesPanel();
@@ -110,8 +108,7 @@ module core {
         [handler=Controller] void enableSearchingForNode();
         [handler=Controller] void disableSearchingForNode();
 
-        [handler=Controller] void enableMonitoringXHR();
-        [handler=Controller] void disableMonitoringXHR();
+        [handler=Controller] void setMonitoringXHR(in boolean enable, out boolean newState);
 
         [handler=Controller] void enableResourceTracking(in boolean always);
         [handler=Controller] void disableResourceTracking(in boolean always);
index 90ef344448941ba6667f16223c65f1624e53df9b..6e48fd090af7c5bffcf7a6284ff4034f06031eaf 100644 (file)
@@ -248,11 +248,19 @@ void InspectorController::saveSessionSettings(const String& settingsJSON)
     m_sessionSettings = InspectorValue::parseJSON(settingsJSON);
 }
 
+String InspectorController::getBackendSettings()
+{
+    RefPtr<InspectorObject> runtimeSettings = InspectorObject::create();
+    runtimeSettings->setBoolean(monitoringXHRSettingName, m_monitoringXHR);
+    return runtimeSettings->toJSONString();
+}
+
 void InspectorController::getSettings(RefPtr<InspectorObject>* settings)
 {
     *settings = InspectorObject::create();
     (*settings)->setString("application", setting(frontendSettingsSettingName()));
     (*settings)->setString("session", m_sessionSettings->toJSONString());
+    (*settings)->setString("backend", getBackendSettings());
 }
 
 void InspectorController::inspect(Node* node)
@@ -460,18 +468,13 @@ void InspectorController::setSearchingForNode(bool enabled)
     }
 }
 
-void InspectorController::setMonitoringXHR(bool enabled)
+void InspectorController::setMonitoringXHR(bool enabled, bool* newState)
 {
+    *newState = enabled;
     if (m_monitoringXHR == enabled)
         return;
     m_monitoringXHR = enabled;
     setSetting(monitoringXHRSettingName, enabled ? "true" : "false");
-    if (m_frontend) {
-        if (enabled)
-            m_frontend->monitoringXHRWasEnabled();
-        else
-            m_frontend->monitoringXHRWasDisabled();
-    }
 }
 
 void InspectorController::connectFrontend()
@@ -613,8 +616,6 @@ void InspectorController::populateScriptObjects()
     if (m_searchingForNode)
         m_frontend->searchingForNodeWasEnabled();
 
-    if (m_monitoringXHR)
-        m_frontend->monitoringXHRWasEnabled();
 
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     if (m_profilerAgent->enabled())
index 079cf55e95432a253d5b805936da869525a50410..13b6b4e98213c809ee124bf91020ed00480b3701 100644 (file)
@@ -270,6 +270,7 @@ public:
 
 private:
     static const String& frontendSettingsSettingName();
+    String getBackendSettings();
 
     friend class InspectorBackend;
     friend class InspectorBackendDispatcher;
@@ -283,9 +284,7 @@ private:
     void enableSearchingForNode() { setSearchingForNode(true); }
     void disableSearchingForNode() { setSearchingForNode(false); }
 
-    void setMonitoringXHR(bool enabled);
-    void enableMonitoringXHR() { setMonitoringXHR(true); }
-    void disableMonitoringXHR() { setMonitoringXHR(false); }
+    void setMonitoringXHR(bool enabled, bool* newState);
     void storeLastActivePanel(const String& panelName);
     InspectorDOMAgent* domAgent() { return m_domAgent.get(); }
     void releaseFrontendLifetimeAgents();
index dfb1e263ef75c7a92a1208a5c6744c8c5807cbbc..06b5564c3fd4ce6254c6236934dd1216baab66d6 100644 (file)
@@ -400,10 +400,13 @@ WebInspector.ConsoleView.prototype = {
         }
 
         var contextMenu = new WebInspector.ContextMenu();
-        if (!WebInspector.monitoringXHREnabled)
-            contextMenu.appendCheckboxItem(WebInspector.UIString("XMLHttpRequest logging"), InspectorBackend.enableMonitoringXHR.bind(InspectorBackend), false);
-        else
-            contextMenu.appendCheckboxItem(WebInspector.UIString("XMLHttpRequest logging"), InspectorBackend.disableMonitoringXHR.bind(InspectorBackend), true);
+
+        function monitoringXHRWasChanged(newState)
+        {
+            WebInspector.monitoringXHREnabled = newState;
+        }
+        var itemAction = InspectorBackend.setMonitoringXHR.bind(InspectorBackend, !WebInspector.monitoringXHREnabled, monitoringXHRWasChanged);
+        contextMenu.appendCheckboxItem(WebInspector.UIString("XMLHttpRequest logging"), itemAction, WebInspector.monitoringXHREnabled);
         contextMenu.appendItem(WebInspector.UIString("Clear Console"), this.requestClearMessages.bind(this));
         contextMenu.show(event);
     },
index 41d82f9087c58ba62ae168459984a0db5054ef11..1261cfdfc63a15c1773dd8c62dfbc877e4fd320e 100644 (file)
@@ -81,9 +81,17 @@ WebInspector.Settings.initialize = function()
         WebInspector.sessionSettings.dispatchEventToListeners("loaded");
     }
 
+    function populateBackendSettings(settingsString)
+    {
+        var settings = JSON.parse(settingsString);
+
+        WebInspector.monitoringXHREnabled = settings.monitoringXHREnabled;
+    }
+
     InspectorBackend.getSettings(function(settings) {
         populateApplicationSettings(settings.application);
         populateSessionSettings(settings.session);
+        populateBackendSettings(settings.backend);
     });
 }
 
index cbaba2d03e2fb982ebf4b408bb74c967af8716b0..da77de387e660836e8a4460a035866fe6b04cc8b 100644 (file)
@@ -1393,16 +1393,6 @@ WebInspector.searchingForNodeWasDisabled = function()
     this.panels.elements.searchingForNodeWasDisabled();
 }
 
-WebInspector.monitoringXHRWasEnabled = function()
-{
-    this.monitoringXHREnabled = true;
-}
-
-WebInspector.monitoringXHRWasDisabled = function()
-{
-    this.monitoringXHREnabled = false;
-}
-
 WebInspector.attachDebuggerWhenShown = function()
 {
     this.panels.scripts.attachDebuggerWhenShown();