2011-04-14 Ilya Tikhonovsky <loislo@chromium.org>
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Apr 2011 12:32:17 +0000 (12:32 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Apr 2011 12:32:17 +0000 (12:32 +0000)
        Reviewed by Pavel Feldman.

        Web Inspector:Duplicated display of storage db when running Web SQL from an iframe.
        https://bugs.webkit.org/show_bug.cgi?id=57830

        There was created a new InspectorDatabaseResource entry for every didOpenDatabase event.
        Moreover there is new WebCore::Database for each didOpenDatabase event.
        I decided to change the old instance of the Database to a new one if they both use the same file.

        * inspector/InspectorDatabaseAgent.cpp:
        (WebCore::InspectorDatabaseAgent::didOpenDatabase):
        (WebCore::InspectorDatabaseAgent::findByFileName):
        * inspector/InspectorDatabaseAgent.h:
        * inspector/InspectorDatabaseResource.h:
        (WebCore::InspectorDatabaseResource::setDatabase):

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorDatabaseAgent.cpp
Source/WebCore/inspector/InspectorDatabaseAgent.h
Source/WebCore/inspector/InspectorDatabaseResource.h

index 48ad559342e1d5c4c243ea8654420397e35d0af4..c3a19fe18269c20803f1f97d99dc5d60280f3088 100644 (file)
@@ -1,3 +1,21 @@
+2011-04-14  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector:Duplicated display of storage db when running Web SQL from an iframe.
+        https://bugs.webkit.org/show_bug.cgi?id=57830
+
+        There was created a new InspectorDatabaseResource entry for every didOpenDatabase event.
+        Moreover there is new WebCore::Database for each didOpenDatabase event.
+        I decided to change the old instance of the Database to a new one if they both use the same file.
+
+        * inspector/InspectorDatabaseAgent.cpp:
+        (WebCore::InspectorDatabaseAgent::didOpenDatabase):
+        (WebCore::InspectorDatabaseAgent::findByFileName):
+        * inspector/InspectorDatabaseAgent.h:
+        * inspector/InspectorDatabaseResource.h:
+        (WebCore::InspectorDatabaseResource::setDatabase):
+
 2011-04-14  Zoltan Herczeg  <zherczeg@inf.u-szeged.hu>
 
         Reviewed by Dirk Schulze.
index 7f6e37968ffe2f4f1fc26e76e0e35cb08597cb8e..c57e40c106d708c26592ac78bd31354898902950 100644 (file)
@@ -220,6 +220,11 @@ private:
 
 void InspectorDatabaseAgent::didOpenDatabase(PassRefPtr<Database> database, const String& domain, const String& name, const String& version)
 {
+    if (InspectorDatabaseResource* resource = findByFileName(database->fileName())) {
+        resource->setDatabase(database);
+        return;
+    }
+
     RefPtr<InspectorDatabaseResource> resource = InspectorDatabaseResource::create(database, domain, name, version);
     m_resources.set(resource->id(), resource);
     // Resources are only bound while visible.
@@ -293,6 +298,15 @@ int InspectorDatabaseAgent::databaseId(Database* database)
     return 0;
 }
 
+InspectorDatabaseResource* InspectorDatabaseAgent::findByFileName(const String& fileName)
+{
+    for (DatabaseResourcesMap::iterator it = m_resources.begin(); it != m_resources.end(); ++it) {
+        if (it->second->database()->fileName() == fileName)
+            return it->second.get();
+    }
+    return 0;
+}
+
 Database* InspectorDatabaseAgent::databaseForId(int databaseId)
 {
     DatabaseResourcesMap::iterator it = m_resources.find(databaseId);
index 45fbfa404eb42a7908c59ff96a3bba5549d0834b..f854a6e1bf486755ee4f8062f797be9ba7ec72df 100644 (file)
@@ -70,6 +70,7 @@ private:
     explicit InspectorDatabaseAgent(InstrumentingAgents*);
 
     Database* databaseForId(int databaseId);
+    InspectorDatabaseResource* findByFileName(const String& fileName);
 
     InstrumentingAgents* m_instrumentingAgents;
     typedef HashMap<int, RefPtr<InspectorDatabaseResource> > DatabaseResourcesMap;
index 9fa7ebd02c2948ee4346b2aaac47679ad9a9e994..281568ce7252d2909cc0222da93d09bdcaa8af82 100644 (file)
@@ -48,6 +48,7 @@ public:
 
     void bind(InspectorFrontend::Database*);
     Database* database() { return m_database.get(); }
+    void setDatabase(PassRefPtr<Database> database) { m_database = database; }
     int id() const { return m_id; }
 
 private: