DatabaseProcess: Implement version changing
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Dec 2013 00:29:03 +0000 (00:29 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Dec 2013 00:29:03 +0000 (00:29 +0000)
commit33a9f81496df1f7c53c1d5f1b5194e7a14ff5e52
treea23fd8d8f70931eef8a0047f41ab8a0092e2e19d
parentf75c6fa1a767a14f0773b31e5f1776e212e3bb41
DatabaseProcess: Implement version changing
https://bugs.webkit.org/show_bug.cgi?id=126099

Reviewed by Sam Weinig.

Source/WebCore:

No new tests (No change in WebCore behavior).

* Modules/indexeddb/IDBTransactionBackend.cpp:
(WebCore::IDBTransactionBackend::commit): Update some logging.

* Modules/indexeddb/IDBTransactionBackendOperations.cpp:
(WebCore::IDBDatabaseBackend::VersionChangeOperation::perform): Move some things that used to be in
  IDBServerConnectionLevelDB::changeDatabaseVersion to this cross-platform location.
* Modules/indexeddb/IDBTransactionBackendOperations.h:
(WebCore::IDBDatabaseBackend::VersionChangeOperation::transaction):

* Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp:
(WebCore::IDBServerConnectionLevelDB::changeDatabaseVersion): Move the actual updating of the database backend
  metadata to the VersionChangeOperation.

Source/WebKit2:

* DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp:
(WebKit::DatabaseProcessIDBConnection::getOrEstablishIDBDatabaseMetadata): Add logging.
(WebKit::DatabaseProcessIDBConnection::openTransaction): Ditto.
(WebKit::DatabaseProcessIDBConnection::beginTransaction): Ditto.
(WebKit::DatabaseProcessIDBConnection::commitTransaction): Ditto.
(WebKit::DatabaseProcessIDBConnection::resetTransaction): Ditto.
(WebKit::DatabaseProcessIDBConnection::rollbackTransaction): Ditto.
(WebKit::DatabaseProcessIDBConnection::changeDatabaseVersion): Implement this!
* DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.h:
* DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.messages.in:

* DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
(WebKit::UniqueIDBDatabase::shutdown): Clean up all requests, and also cleanup the backing store
  on the database queue.
(WebKit::UniqueIDBDatabase::shutdownBackingStore): Shutdown the backing store.
(WebKit::UniqueIDBDatabase::didShutdownBackingStore):
(WebKit::UniqueIDBDatabase::changeDatabaseVersion): Pass along the new version to the database queue.
(WebKit::UniqueIDBDatabase::didChangeDatabaseVersion):
(WebKit::UniqueIDBDatabase::changeDatabaseVersionInBackingStore): Set the new version in the backing store.
(WebKit::UniqueIDBDatabase::postMainThreadTask): Add a ref() to keep the database alive incase it is being
  shutdown on the main thread.
(WebKit::UniqueIDBDatabase::performNextMainThreadTask): Balance the ref() from postMainThreadTask, and
  accept an empty mainThreadTask queue.
* DatabaseProcess/IndexedDB/UniqueIDBDatabase.h:

* DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h: Add changeDatabaseVersion.

Flesh out SQLiteIDBTransaction to actually operation on a SQLiteTransaction in a real SQLiteDatabase:
* DatabaseProcess/IndexedDB/sqlite/SQLiteIDBTransaction.cpp:
(WebKit::SQLiteIDBTransaction::SQLiteIDBTransaction):
(WebKit::SQLiteIDBTransaction::~SQLiteIDBTransaction):
(WebKit::SQLiteIDBTransaction::begin):
(WebKit::SQLiteIDBTransaction::commit):
(WebKit::SQLiteIDBTransaction::reset):
(WebKit::SQLiteIDBTransaction::rollback):
(WebKit::SQLiteIDBTransaction::inProgress):
* DatabaseProcess/IndexedDB/sqlite/SQLiteIDBTransaction.h:
(WebKit::SQLiteIDBTransaction::create):
(WebKit::SQLiteIDBTransaction::mode):

Rename m_metadataDB to m_sqliteDB,
* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::createAndPopulateInitialMetadata):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::extractExistingMetadata):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::openSQLiteDatabaseAtPath): Disable threading checks on the DB
  as work queues can change threads.
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::getOrEstablishMetadata):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::establishTransaction):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::beginTransaction):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::changeDatabaseVersion): After validating the transaction, actually
  update the version number on disk.
* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h:

* WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp:
(WebKit::WebIDBServerConnection::~WebIDBServerConnection): Make sure to abort in-flight requests.
(WebKit::WebIDBServerConnection::changeDatabaseVersion):
(WebKit::WebIDBServerConnection::didChangeDatabaseVersion):
* WebProcess/Databases/IndexedDB/WebIDBServerConnection.h:
* WebProcess/Databases/IndexedDB/WebIDBServerConnection.messages.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161076 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBTransactionBackend.cpp
Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.cpp
Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.h
Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.cpp
Source/WebKit2/DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.h
Source/WebKit2/DatabaseProcess/IndexedDB/DatabaseProcessIDBConnection.messages.in
Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp
Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.h
Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBTransaction.cpp
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBTransaction.h
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h
Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp
Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.h
Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.messages.in