2011-04-15 Ilya Tikhonovsky <loislo@chromium.org>
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Apr 2011 05:32:07 +0000 (05:32 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Apr 2011 05:32:07 +0000 (05:32 +0000)
        Reviewed by Pavel Feldman.

        Web Inspector: The list of Database entries is empty if the page opens a database just before Web Inspector.
        https://bugs.webkit.org/show_bug.cgi?id=57833

        * http/tests/inspector-enabled/database-open.html:
2011-04-15  Ilya Tikhonovsky  <loislo@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: The list of Database entries is empty if the page opens a database just before Web Inspector.
        https://bugs.webkit.org/show_bug.cgi?id=57833

        * inspector/Inspector.json:
        * inspector/InspectorDatabaseAgent.cpp:
        (WebCore::InspectorDatabaseAgent::didOpenDatabase):
        (WebCore::InspectorDatabaseAgent::InspectorDatabaseAgent):
        (WebCore::InspectorDatabaseAgent::setFrontend):
        (WebCore::InspectorDatabaseAgent::clearFrontend):
        (WebCore::InspectorDatabaseAgent::enable):
        (WebCore::InspectorDatabaseAgent::disable):
        (WebCore::InspectorDatabaseAgent::getDatabaseTableNames):
        (WebCore::InspectorDatabaseAgent::executeSQL):
        * inspector/InspectorDatabaseAgent.h:
        * inspector/front-end/inspector.js:

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

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector-enabled/database-open.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/Inspector.json
Source/WebCore/inspector/InspectorDatabaseAgent.cpp
Source/WebCore/inspector/InspectorDatabaseAgent.h
Source/WebCore/inspector/front-end/inspector.js

index 3c0d4f8dae7e2ba1c857eca417810f5f19335100..d83bf63b76de85bd5ed688016a866c40026a758d 100644 (file)
@@ -1,3 +1,12 @@
+2011-04-15  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: The list of Database entries is empty if the page opens a database just before Web Inspector.
+        https://bugs.webkit.org/show_bug.cgi?id=57833
+
+        * http/tests/inspector-enabled/database-open.html:
+
 2011-04-15  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Eric Seidel.
index 60668af22e3a9129afe357c9cbc0a0a272e4d9fc..83ce386fc48f5cbba9bd293aff0fee60e33ea390 100644 (file)
@@ -18,13 +18,17 @@ function onload()
 
 function test()
 {
-    var databases = WebInspector.panels.resources._databases;
-    for (var i = 0; i < databases.length; ++i) {
-        InspectorTest.addResult("Name: " + databases[i].name);
-        InspectorTest.addResult("Version: " + databases[i].version);
-        InspectorTest.addResult("Domain: " + databases[i].domain);
+    function run()
+    {
+        var databases = WebInspector.panels.resources._databases;
+        for (var i = 0; i < databases.length; ++i) {
+            InspectorTest.addResult("Name: " + databases[i].name);
+            InspectorTest.addResult("Version: " + databases[i].version);
+            InspectorTest.addResult("Domain: " + databases[i].domain);
+        }
+        InspectorTest.completeTest();
     }
-    InspectorTest.completeTest();
+    InspectorBackend.runAfterPendingDispatches(run);
 }
 
 </script>
index 9995ccaa622f8522d47b61f2de8c2c5353c03faf..d686c1656c8af8771c6bdec645388f25d42712b9 100644 (file)
@@ -1,3 +1,23 @@
+2011-04-15  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: The list of Database entries is empty if the page opens a database just before Web Inspector.
+        https://bugs.webkit.org/show_bug.cgi?id=57833
+
+        * inspector/Inspector.json:
+        * inspector/InspectorDatabaseAgent.cpp:
+        (WebCore::InspectorDatabaseAgent::didOpenDatabase):
+        (WebCore::InspectorDatabaseAgent::InspectorDatabaseAgent):
+        (WebCore::InspectorDatabaseAgent::setFrontend):
+        (WebCore::InspectorDatabaseAgent::clearFrontend):
+        (WebCore::InspectorDatabaseAgent::enable):
+        (WebCore::InspectorDatabaseAgent::disable):
+        (WebCore::InspectorDatabaseAgent::getDatabaseTableNames):
+        (WebCore::InspectorDatabaseAgent::executeSQL):
+        * inspector/InspectorDatabaseAgent.h:
+        * inspector/front-end/inspector.js:
+
 2011-04-15  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Eric Seidel.
index 958d54461a2c98aabdc588378ad24fd75a9c2739..9d7168ba6efc239ff620a77693bd767260fbb1f6 100644 (file)
         "domain": "Database",
         "types": [],
         "commands": [
+            {
+                "name": "enable",
+                "description": "Enables database tracking, database events will now be delivered to the client."
+            },
+            {
+                "name": "disable",
+                "description": "Disables database tracking, prevents database events from being sent to the client."
+            },
             {
                 "name": "getDatabaseTableNames",
                 "parameters": [
index c57e40c106d708c26592ac78bd31354898902950..2be6c52a3ed389be591e45272d5db615c326bd56 100644 (file)
@@ -228,7 +228,7 @@ void InspectorDatabaseAgent::didOpenDatabase(PassRefPtr<Database> database, cons
     RefPtr<InspectorDatabaseResource> resource = InspectorDatabaseResource::create(database, domain, name, version);
     m_resources.set(resource->id(), resource);
     // Resources are only bound while visible.
-    if (m_frontendProvider)
+    if (m_frontendProvider && m_enabled)
         resource->bind(m_frontendProvider->frontend());
 }
 
@@ -239,6 +239,7 @@ void InspectorDatabaseAgent::clearResources()
 
 InspectorDatabaseAgent::InspectorDatabaseAgent(InstrumentingAgents* instrumentingAgents)
     : m_instrumentingAgents(instrumentingAgents)
+    , m_enabled(false)
 {
     m_instrumentingAgents->setInspectorDatabaseAgent(this);
 }
@@ -251,19 +252,40 @@ InspectorDatabaseAgent::~InspectorDatabaseAgent()
 void InspectorDatabaseAgent::setFrontend(InspectorFrontend* frontend)
 {
     m_frontendProvider = FrontendProvider::create(frontend);
-    DatabaseResourcesMap::iterator databasesEnd = m_resources.end();
-    for (DatabaseResourcesMap::iterator it = m_resources.begin(); it != databasesEnd; ++it)
-        it->second->bind(m_frontendProvider->frontend());
 }
 
 void InspectorDatabaseAgent::clearFrontend()
 {
     m_frontendProvider->clearFrontend();
     m_frontendProvider.clear();
+    m_enabled = false;
+}
+
+void InspectorDatabaseAgent::enable(ErrorString*)
+{
+    if (m_enabled)
+        return;
+    m_enabled = true;
+
+    DatabaseResourcesMap::iterator databasesEnd = m_resources.end();
+    for (DatabaseResourcesMap::iterator it = m_resources.begin(); it != databasesEnd; ++it)
+        it->second->bind(m_frontendProvider->frontend());
 }
 
-void InspectorDatabaseAgent::getDatabaseTableNames(ErrorString*, int databaseId, RefPtr<InspectorArray>* names)
+void InspectorDatabaseAgent::disable(ErrorString*)
 {
+    if (!m_enabled)
+        return;
+    m_enabled = false;
+}
+
+void InspectorDatabaseAgent::getDatabaseTableNames(ErrorString* error, int databaseId, RefPtr<InspectorArray>* names)
+{
+    if (!m_enabled) {
+        *error = "Database agent is not enabled";
+        return;
+    }
+
     Database* database = databaseForId(databaseId);
     if (database) {
         Vector<String> tableNames = database->tableNames();
@@ -273,8 +295,13 @@ void InspectorDatabaseAgent::getDatabaseTableNames(ErrorString*, int databaseId,
     }
 }
 
-void InspectorDatabaseAgent::executeSQL(ErrorString*, int databaseId, const String& query, bool* success, int* transactionId)
+void InspectorDatabaseAgent::executeSQL(ErrorString* error, int databaseId, const String& query, bool* success, int* transactionId)
 {
+    if (!m_enabled) {
+        *error = "Database agent is not enabled";
+        return;
+    }
+
     Database* database = databaseForId(databaseId);
     if (!database) {
         *success = false;
index f854a6e1bf486755ee4f8062f797be9ba7ec72df..6fce09b038df921228ab86a6a460378672f62c80 100644 (file)
@@ -59,6 +59,8 @@ public:
     void clearResources();
 
     // Called from the front-end.
+    void enable(ErrorString*);
+    void disable(ErrorString*);
     void getDatabaseTableNames(ErrorString*, int databaseId, RefPtr<InspectorArray>* names);
     void executeSQL(ErrorString*, int databaseId, const String& query, bool* success, int* transactionId);
 
@@ -76,6 +78,7 @@ private:
     typedef HashMap<int, RefPtr<InspectorDatabaseResource> > DatabaseResourcesMap;
     DatabaseResourcesMap m_resources;
     RefPtr<FrontendProvider> m_frontendProvider;
+    bool m_enabled;
 };
 
 } // namespace WebCore
index da7b89a52a4de8f22ac40fc287b820e672f0d311..c599e4635483338ded8b51104cb63031d37cd026 100644 (file)
@@ -499,6 +499,8 @@ WebInspector.doLoadedDone = function()
         ConsoleAgent.setMonitoringXHREnabled(true);
     ConsoleAgent.enable(this.console.setConsoleMessageExpiredCount.bind(this.console));
 
+    DatabaseAgent.enable();
+
     WebInspector.showPanel(WebInspector.settings.lastActivePanel);
 
     function propertyNamesCallback(error, names)