A new database should be registered with the Document,
authordumi@chromium.org <dumi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Dec 2009 01:38:53 +0000 (01:38 +0000)
committerdumi@chromium.org <dumi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Dec 2009 01:38:53 +0000 (01:38 +0000)
DatabaseTracker and DatabaseThread only after it was successfully
opened and its version was successfully verified.

Reviewed by Eric Seidel.

Fixes a regression introduced by
http://trac.webkit.org/changeset/52530.

LayoutTests/storage/open-database-while-transaction-in-progress.html
should pass again (or rather, it should pass again when run after
open-database-set-empty-version.html).

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

* storage/Database.cpp:
(WebCore::Database::openDatabase):
(WebCore::Database::Database):
(WebCore::Database::performOpenAndVerify):

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

WebCore/ChangeLog
WebCore/storage/Database.cpp

index 7d0fcd2684ca0672d3d7d10e800c785cd50eccd3..009f67e62d950419fa3553ede8a4b6d8eca3209a 100644 (file)
@@ -1,3 +1,25 @@
+2009-12-23  Dumitru Daniliuc  <dumi@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        A new database should be registered with the Document,
+        DatabaseTracker and DatabaseThread only after it was successfully
+        opened and its version was successfully verified.
+
+        Fixes a regression introduced by
+        http://trac.webkit.org/changeset/52530.
+
+        LayoutTests/storage/open-database-while-transaction-in-progress.html
+        should pass again (or rather, it should pass again when run after
+        open-database-set-empty-version.html).
+
+        https://bugs.webkit.org/show_bug.cgi?id=32913
+
+        * storage/Database.cpp:
+        (WebCore::Database::openDatabase):
+        (WebCore::Database::Database):
+        (WebCore::Database::performOpenAndVerify):
+
 2009-12-23  David Levin  <levin@chromium.org>
 
         REGRESSION (r52494): Assertion failure in Frame::caretBlinkTimerFired() (selection()->isCaret())
 2009-12-23  David Levin  <levin@chromium.org>
 
         REGRESSION (r52494): Assertion failure in Frame::caretBlinkTimerFired() (selection()->isCaret())
index 62d4039af2a61021fc994dd1ef94ef151dda760d..aca66b057a285ea1e2b30bd1a351ebfcda23dd75 100644 (file)
@@ -132,11 +132,12 @@ PassRefPtr<Database> Database::openDatabase(Document* document, const String& na
 
     if (!database->openAndVerifyVersion(e)) {
        LOG(StorageAPI, "Failed to open and verify version (expected %s) of database %s", expectedVersion.ascii().data(), database->databaseDebugName().ascii().data());
 
     if (!database->openAndVerifyVersion(e)) {
        LOG(StorageAPI, "Failed to open and verify version (expected %s) of database %s", expectedVersion.ascii().data(), database->databaseDebugName().ascii().data());
-       document->removeOpenDatabase(database.get());
-       DatabaseTracker::tracker().removeOpenDatabase(database.get());
        return 0;
     }
 
        return 0;
     }
 
+    DatabaseTracker::tracker().addOpenDatabase(database.get());
+    document->addOpenDatabase(database.get());
+
     DatabaseTracker::tracker().setDatabaseDetails(document->securityOrigin(), name, displayName, estimatedSize);
 
     document->setHasOpenDatabases();
     DatabaseTracker::tracker().setDatabaseDetails(document->securityOrigin(), name, displayName, estimatedSize);
 
     document->setHasOpenDatabases();
@@ -188,9 +189,6 @@ Database::Database(Document* document, const String& name, const String& expecte
     ASSERT(m_document->databaseThread());
 
     m_filename = DatabaseTracker::tracker().fullPathForDatabase(m_mainThreadSecurityOrigin.get(), m_name);
     ASSERT(m_document->databaseThread());
 
     m_filename = DatabaseTracker::tracker().fullPathForDatabase(m_mainThreadSecurityOrigin.get(), m_name);
-
-    DatabaseTracker::tracker().addOpenDatabase(this);
-    m_document->addOpenDatabase(this);
 }
 
 static void derefDocument(void* document)
 }
 
 static void derefDocument(void* document)
@@ -462,10 +460,6 @@ bool Database::performOpenAndVerify(ExceptionCode& e)
         return false;
     }
 
         return false;
     }
 
-    m_opened = true;
-    if (m_document->databaseThread())
-        m_document->databaseThread()->recordDatabaseOpen(this);
-
     ASSERT(m_databaseAuthorizer);
     m_sqliteDatabase.setAuthorizer(m_databaseAuthorizer);
     m_sqliteDatabase.setBusyTimeout(maxSqliteBusyWaitTime);
     ASSERT(m_databaseAuthorizer);
     m_sqliteDatabase.setAuthorizer(m_databaseAuthorizer);
     m_sqliteDatabase.setBusyTimeout(maxSqliteBusyWaitTime);
@@ -525,6 +519,10 @@ bool Database::performOpenAndVerify(ExceptionCode& e)
         return false;
     }
 
         return false;
     }
 
+    m_opened = true;
+    if (m_document->databaseThread())
+        m_document->databaseThread()->recordDatabaseOpen(this);
+
     return true;
 }
 
     return true;
 }