2011-05-26 Michael Nordman <michaeln@google.com>
authormichaeln@google.com <michaeln@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 May 2011 19:43:47 +0000 (19:43 +0000)
committermichaeln@google.com <michaeln@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 May 2011 19:43:47 +0000 (19:43 +0000)
        Reviewed by Darin Fisher.

        [Chromium] Use SecurityOrigin produced databaseIdentifier strings, instead of
        SecurityOrigin RefPtrs, as the top level key into the DatabaseTracker's
        collection of open databases. Otherwise we can fail to lookup databases when
        trying to forceably close them via  WebDatabase::closeDatabaseImmediately.
        https://bugs.webkit.org/show_bug.cgi?id=61417

        * src/WebDatabase.cpp:
        (WebKit::WebDatabase::closeDatabaseImmediately):
2011-05-26  Michael Nordman  <michaeln@google.com>

        Reviewed by Darin Fisher.

        [Chromium] Use SecurityOrigin produced databaseIdentifier strings, instead of
        SecurityOrigin RefPtrs, as the top level key into the DatabaseTracker's
        collection of open databases. Otherwise we can fail to lookup databases when
        trying to forceably close them via  WebDatabase::closeDatabaseImmediately.
        https://bugs.webkit.org/show_bug.cgi?id=61417

        New new functionality, no tests.

        * storage/DatabaseTracker.h:
        * storage/chromium/DatabaseTrackerChromium.cpp:
        (WebCore::DatabaseTracker::addOpenDatabase):
        (WebCore::DatabaseTracker::removeOpenDatabase):
        (WebCore::DatabaseTracker::getOpenDatabases):
        (WebCore::DatabaseTracker::interruptAllDatabasesForContext):

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

Source/WebCore/ChangeLog
Source/WebCore/storage/DatabaseTracker.h
Source/WebCore/storage/chromium/DatabaseTrackerChromium.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebDatabase.cpp

index 29515ca..d1e544f 100644 (file)
@@ -1,3 +1,22 @@
+2011-05-26  Michael Nordman  <michaeln@google.com>
+
+        Reviewed by Darin Fisher.
+
+        [Chromium] Use SecurityOrigin produced databaseIdentifier strings, instead of
+        SecurityOrigin RefPtrs, as the top level key into the DatabaseTracker's
+        collection of open databases. Otherwise we can fail to lookup databases when
+        trying to forceably close them via  WebDatabase::closeDatabaseImmediately.
+        https://bugs.webkit.org/show_bug.cgi?id=61417
+
+        New new functionality, no tests.
+
+        * storage/DatabaseTracker.h:
+        * storage/chromium/DatabaseTrackerChromium.cpp:
+        (WebCore::DatabaseTracker::addOpenDatabase):
+        (WebCore::DatabaseTracker::removeOpenDatabase):
+        (WebCore::DatabaseTracker::getOpenDatabases):
+        (WebCore::DatabaseTracker::interruptAllDatabasesForContext):
+
 2011-05-25  Jer Noble  <jer.noble@apple.com>
 
         Reviewed by Maciej Stachowiak.
index a1a5bdf..688a06f 100644 (file)
@@ -84,13 +84,6 @@ public:
 private:
     DatabaseTracker(const String& databasePath);
 
-    typedef HashSet<AbstractDatabase*> DatabaseSet;
-    typedef HashMap<String, DatabaseSet*> DatabaseNameMap;
-    typedef HashMap<RefPtr<SecurityOrigin>, DatabaseNameMap*, SecurityOriginHash> DatabaseOriginMap;
-
-    Mutex m_openDatabaseMapGuard;
-    mutable OwnPtr<DatabaseOriginMap> m_openDatabaseMap;
-
 #if !PLATFORM(CHROMIUM)
 public:
     void setDatabaseDirectoryPath(const String&);
@@ -136,6 +129,13 @@ private:
 
     bool deleteDatabaseFile(SecurityOrigin*, const String& name);
 
+    typedef HashSet<AbstractDatabase*> DatabaseSet;
+    typedef HashMap<String, DatabaseSet*> DatabaseNameMap;
+    typedef HashMap<RefPtr<SecurityOrigin>, DatabaseNameMap*, SecurityOriginHash> DatabaseOriginMap;
+
+    Mutex m_openDatabaseMapGuard;
+    mutable OwnPtr<DatabaseOriginMap> m_openDatabaseMap;
+
     // This lock protects m_database, m_quotaMap, m_proposedDatabases, m_databaseDirectoryPath, m_originsBeingDeleted, m_beingCreated, and m_beingDeleted.
     Mutex m_databaseGuard;
     SQLiteDatabase m_database;
@@ -171,6 +171,17 @@ private:
 
     static void scheduleForNotification();
     static void notifyDatabasesChanged(void*);
+#else
+public:
+    void getOpenDatabases(String originIdentifier, const String& name, HashSet<RefPtr<AbstractDatabase> >* databases);
+
+private:
+    typedef HashSet<AbstractDatabase*> DatabaseSet;
+    typedef HashMap<String, DatabaseSet*> DatabaseNameMap;
+    typedef HashMap<String, DatabaseNameMap*> DatabaseOriginMap;
+
+    Mutex m_openDatabaseMapGuard;
+    mutable OwnPtr<DatabaseOriginMap> m_openDatabaseMap;
 #endif // !PLATFORM(CHROMIUM)
 };
 
index 765e3b2..8dbc792 100644 (file)
@@ -76,12 +76,13 @@ void DatabaseTracker::addOpenDatabase(AbstractDatabase* database)
     ASSERT(database->scriptExecutionContext()->isContextThread());
     MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
     if (!m_openDatabaseMap)
-        m_openDatabaseMap = adoptPtr(new DatabaseOriginMap());
+        m_openDatabaseMap = adoptPtr(new DatabaseOriginMap);
 
-    DatabaseNameMap* nameMap = m_openDatabaseMap->get(database->securityOrigin());
+    String originIdentifier = database->securityOrigin()->databaseIdentifier();
+    DatabaseNameMap* nameMap = m_openDatabaseMap->get(originIdentifier);
     if (!nameMap) {
         nameMap = new DatabaseNameMap();
-        m_openDatabaseMap->set(database->securityOrigin(), nameMap);
+        m_openDatabaseMap->set(originIdentifier, nameMap);
     }
 
     String name(database->stringIdentifier());
@@ -124,9 +125,10 @@ void DatabaseTracker::removeOpenDatabase(AbstractDatabase* database)
         return;
     }
 
+    String originIdentifier = database->securityOrigin()->databaseIdentifier();
     MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
     ASSERT(m_openDatabaseMap);
-    DatabaseNameMap* nameMap = m_openDatabaseMap->get(database->securityOrigin());
+    DatabaseNameMap* nameMap = m_openDatabaseMap->get(originIdentifier);
     ASSERT(nameMap);
     String name(database->stringIdentifier());
     DatabaseSet* databaseSet = nameMap->get(name);
@@ -137,7 +139,7 @@ void DatabaseTracker::removeOpenDatabase(AbstractDatabase* database)
         nameMap->remove(name);
         delete databaseSet;
         if (nameMap->isEmpty()) {
-            m_openDatabaseMap->remove(database->securityOrigin());
+            m_openDatabaseMap->remove(originIdentifier);
             delete nameMap;
         }
     }
@@ -145,14 +147,18 @@ void DatabaseTracker::removeOpenDatabase(AbstractDatabase* database)
     DatabaseObserver::databaseClosed(database);
 }
 
-
 void DatabaseTracker::getOpenDatabases(SecurityOrigin* origin, const String& name, HashSet<RefPtr<AbstractDatabase> >* databases)
 {
+    getOpenDatabases(origin->databaseIdentifier(), name, databases);
+}
+
+void DatabaseTracker::getOpenDatabases(String originIdentifier, const String& name, HashSet<RefPtr<AbstractDatabase> >* databases)
+{
     MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
     if (!m_openDatabaseMap)
         return;
 
-    DatabaseNameMap* nameMap = m_openDatabaseMap->get(origin);
+    DatabaseNameMap* nameMap = m_openDatabaseMap->get(originIdentifier);
     if (!nameMap)
         return;
 
@@ -183,7 +189,7 @@ void DatabaseTracker::interruptAllDatabasesForContext(const ScriptExecutionConte
         if (!m_openDatabaseMap)
             return;
 
-        DatabaseNameMap* nameMap = m_openDatabaseMap->get(context->securityOrigin());
+        DatabaseNameMap* nameMap = m_openDatabaseMap->get(context->securityOrigin()->databaseIdentifier());
         if (!nameMap)
             return;
 
index bce7253..9e845da 100644 (file)
@@ -1,3 +1,16 @@
+2011-05-26  Michael Nordman  <michaeln@google.com>
+
+        Reviewed by Darin Fisher.
+
+        [Chromium] Use SecurityOrigin produced databaseIdentifier strings, instead of
+        SecurityOrigin RefPtrs, as the top level key into the DatabaseTracker's
+        collection of open databases. Otherwise we can fail to lookup databases when
+        trying to forceably close them via  WebDatabase::closeDatabaseImmediately.
+        https://bugs.webkit.org/show_bug.cgi?id=61417
+
+        * src/WebDatabase.cpp:
+        (WebKit::WebDatabase::closeDatabaseImmediately):
+
 2011-05-26  Sailesh Agrawal  <sail@chromium.org>
 
         Reviewed by Tony Chang.
index 3053daa..4f4eeba 100644 (file)
@@ -96,21 +96,21 @@ void WebDatabase::updateDatabaseSize(const WebString& originIdentifier, const We
 {
 #if ENABLE(DATABASE)
     QuotaTracker::instance().updateDatabaseSize(originIdentifier, name, size);
-#endif // ENABLE(DATABASE)
+#endif
 }
 
 void WebDatabase::updateSpaceAvailable(const WebString& originIdentifier, long long spaceAvailable)
 {
 #if ENABLE(DATABASE)
     QuotaTracker::instance().updateSpaceAvailableToOrigin(originIdentifier, spaceAvailable);
-#endif // ENABLE(DATABASE)
+#endif
 }
 
 void WebDatabase::resetSpaceAvailable(const WebString& originIdentifier)
 {
 #if ENABLE(DATABASE)
     QuotaTracker::instance().resetSpaceAvailableToOrigin(originIdentifier);
-#endif // ENABLE(DATABASE)
+#endif
 }
 
 // FIXME: This is deprecated, delete after rolling DEPs and chrome is using the new methods.
@@ -121,18 +121,17 @@ void WebDatabase::updateDatabaseSize(
 #if ENABLE(DATABASE)
     updateDatabaseSize(originIdentifier, databaseName, databaseSize);
     updateSpaceAvailable(originIdentifier, spaceAvailable);
-#endif // ENABLE(DATABASE)
+#endif
 }
 
 void WebDatabase::closeDatabaseImmediately(const WebString& originIdentifier, const WebString& databaseName)
 {
 #if ENABLE(DATABASE)
     HashSet<RefPtr<AbstractDatabase> > databaseHandles;
-    RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromDatabaseIdentifier(originIdentifier);
-    DatabaseTracker::tracker().getOpenDatabases(origin.get(), databaseName, &databaseHandles);
+    DatabaseTracker::tracker().getOpenDatabases(originIdentifier, databaseName, &databaseHandles);
     for (HashSet<RefPtr<AbstractDatabase> >::iterator it = databaseHandles.begin(); it != databaseHandles.end(); ++it)
         it->get()->closeImmediately();
-#endif // ENABLE(DATABASE)
+#endif
 }
 
 WebDatabase::WebDatabase(const AbstractDatabase* database)