2011-04-14 Ilya Tikhonovsky <loislo@chromium.org>
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Apr 2011 13:35:54 +0000 (13:35 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Apr 2011 13:35:54 +0000 (13:35 +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

        * inspector/Inspector.json:
        * inspector/InspectorDatabaseAgent.cpp:
        (WebCore::InspectorDatabaseAgent::didOpenDatabase):
        (WebCore::InspectorDatabaseAgent::InspectorDatabaseAgent):
        (WebCore::InspectorDatabaseAgent::setFrontend):
        (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@83849 268f45cc-cd09-0410-ab3c-d52691b4dbfc

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 1aa63a100c759a88c0af64e7cf8a9d394f484d3e..bee61ea678c67e3febf1a6b4c0817cd1195c151c 100644 (file)
@@ -1,3 +1,22 @@
+2011-04-14  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::enable):
+        (WebCore::InspectorDatabaseAgent::disable):
+        (WebCore::InspectorDatabaseAgent::getDatabaseTableNames):
+        (WebCore::InspectorDatabaseAgent::executeSQL):
+        * inspector/InspectorDatabaseAgent.h:
+        * inspector/front-end/inspector.js:
+
 2011-04-14  Alexander Pavlov  <apavlov@chromium.org>
 
         Reviewed by Yury Semikhatsky.
index 43a0393c07cfe4fc4332cd35cde6141fa93a0409..1fcd45ff71572716c3693ff9bb3e3ff173ac9c51 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..0ca2766ba3224ecc95a4897f0fde20465ef62547 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,9 +252,6 @@ 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()
@@ -262,8 +260,31 @@ void InspectorDatabaseAgent::clearFrontend()
     m_frontendProvider.clear();
 }
 
-void InspectorDatabaseAgent::getDatabaseTableNames(ErrorString*, int databaseId, RefPtr<InspectorArray>* names)
+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::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 +294,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 3c30a20ffff6772dc056e6890853080e7355d0ad..510f9317e068a6dcb32f33c86e8de1bde70a1e6a 100644 (file)
@@ -508,6 +508,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)