DatabaseProcess: Fix a few bugs with opening an IDB connection
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Dec 2013 21:26:59 +0000 (21:26 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Dec 2013 21:26:59 +0000 (21:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=125798

Reviewed by Alexey Proskuryakov.

Source/WebCore:

* Modules/indexeddb/IDBDatabaseBackend.cpp:
(WebCore::IDBDatabaseBackend::processPendingCalls): As the comment says, we should only
  early return when there *are* pending delete calls. The logic here was backwards,
  preventing the backend from ever getting to processPendingOpenCalls().

Source/WebKit2:

Database metadata always needs a non-zero database identifier, unique at runtime.

* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
(WebKit::generateDatabaseId):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::getOrEstablishMetadata):

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBDatabaseBackend.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp

index e8d88bc..1ea21a9 100644 (file)
@@ -1,3 +1,15 @@
+2013-12-16  Brady Eidson  <beidson@apple.com>
+
+        DatabaseProcess: Fix a few bugs with opening an IDB connection
+        https://bugs.webkit.org/show_bug.cgi?id=125798
+
+        Reviewed by Alexey Proskuryakov.
+
+        * Modules/indexeddb/IDBDatabaseBackend.cpp:
+        (WebCore::IDBDatabaseBackend::processPendingCalls): As the comment says, we should only
+          early return when there *are* pending delete calls. The logic here was backwards,
+          preventing the backend from ever getting to processPendingOpenCalls().
+
 2013-12-16  Alex Christensen  <achristensen@webkit.org>
 
         Fixed Win64 build on VS2013.
index fd996a5..68fafa8 100644 (file)
@@ -391,7 +391,7 @@ void IDBDatabaseBackend::processPendingCalls()
 
     // If there are any database deletions waiting for completion, we're done for now.
     // Further callbacks will be handled in a future call to processPendingCalls().
-    if (m_deleteCallbacksWaitingCompletion.isEmpty())
+    if (!m_deleteCallbacksWaitingCompletion.isEmpty())
         return;
 
     if (m_runningVersionChangeTransaction)
index 9c14a69..5b828cb 100644 (file)
@@ -1,3 +1,16 @@
+2013-12-16  Brady Eidson  <beidson@apple.com>
+
+        DatabaseProcess: Fix a few bugs with opening an IDB connection
+        https://bugs.webkit.org/show_bug.cgi?id=125798
+
+        Reviewed by Alexey Proskuryakov.
+
+        Database metadata always needs a non-zero database identifier, unique at runtime.
+
+        * DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
+        (WebKit::generateDatabaseId):
+        (WebKit::UniqueIDBDatabaseBackingStoreSQLite::getOrEstablishMetadata):
+
 2013-12-16  Anders Carlsson  <andersca@apple.com>
 
         UserData should encode and decode API::Data objects
index 4fa370a..92d1c42 100644 (file)
@@ -41,6 +41,14 @@ namespace WebKit {
 // Current version of the metadata schema being used in the metadata database.
 static const int currentMetadataVersion = 1;
 
+static int64_t generateDatabaseId()
+{
+    static int64_t databaseID = 0;
+
+    ASSERT(!isMainThread());
+    return ++databaseID;
+}
+
 UniqueIDBDatabaseBackingStoreSQLite::UniqueIDBDatabaseBackingStoreSQLite(const UniqueIDBDatabaseIdentifier& identifier, const String& databaseDirectory)
     : m_identifier(identifier)
     , m_absoluteDatabaseDirectory(databaseDirectory)
@@ -173,6 +181,9 @@ std::unique_ptr<IDBDatabaseMetadata> UniqueIDBDatabaseBackingStoreSQLite::getOrE
     if (!metadata)
         LOG_ERROR("Unable to establish IDB database at path '%s'", metadataDBFilename.utf8().data());
 
+    // The database id is a runtime concept and doesn't need to be stored in the metadata database.
+    metadata->id = generateDatabaseId();
+
     return metadata;
 }