diff options
Diffstat (limited to 'WebCore/storage')
-rw-r--r-- | WebCore/storage/Database.cpp | 20 | ||||
-rw-r--r-- | WebCore/storage/Database.h | 5 | ||||
-rw-r--r-- | WebCore/storage/DatabaseThread.cpp | 5 | ||||
-rw-r--r-- | WebCore/storage/DatabaseThread.h | 6 | ||||
-rw-r--r-- | WebCore/storage/SQLTransaction.cpp | 42 | ||||
-rw-r--r-- | WebCore/storage/SQLTransaction.h | 3 | ||||
-rw-r--r-- | WebCore/storage/SQLTransactionCoordinator.cpp | 102 | ||||
-rw-r--r-- | WebCore/storage/SQLTransactionCoordinator.h | 56 | ||||
-rw-r--r-- | WebCore/storage/Storage.h | 1 | ||||
-rw-r--r-- | WebCore/storage/StorageNamespace.h | 1 | ||||
-rw-r--r-- | WebCore/storage/StorageNamespaceImpl.cpp | 5 | ||||
-rw-r--r-- | WebCore/storage/StorageNamespaceImpl.h | 1 |
12 files changed, 9 insertions, 238 deletions
diff --git a/WebCore/storage/Database.cpp b/WebCore/storage/Database.cpp index 12416e9..5504cb1 100644 --- a/WebCore/storage/Database.cpp +++ b/WebCore/storage/Database.cpp @@ -50,7 +50,6 @@ #include "SQLiteFileSystem.h" #include "SQLiteStatement.h" #include "SQLResultSet.h" -#include "SQLTransactionCoordinator.h" #include <wtf/MainThread.h> #endif @@ -545,17 +544,13 @@ void Database::scheduleTransaction() m_transactionInProgress = false; } -void Database::scheduleTransactionStep(SQLTransaction* transaction, bool immediately) +void Database::scheduleTransactionStep(SQLTransaction* transaction) { - if (!m_document->databaseThread()) - return; - - RefPtr<DatabaseTransactionTask> task = DatabaseTransactionTask::create(transaction); - LOG(StorageAPI, "Scheduling DatabaseTransactionTask %p for the transaction step\n", task.get()); - if (immediately) - m_document->databaseThread()->scheduleImmediateTask(task.release()); - else + if (m_document->databaseThread()) { + RefPtr<DatabaseTransactionTask> task = DatabaseTransactionTask::create(transaction); + LOG(StorageAPI, "Scheduling DatabaseTransactionTask %p for the transaction step\n", task.get()); m_document->databaseThread()->scheduleTask(task.release()); + } } void Database::scheduleTransactionCallback(SQLTransaction* transaction) @@ -593,11 +588,6 @@ Vector<String> Database::performGetTableNames() return tableNames; } -SQLTransactionCoordinator* Database::transactionCoordinator() const -{ - return m_document->databaseThread()->transactionCoordinator(); -} - String Database::version() const { if (m_deleted) diff --git a/WebCore/storage/Database.h b/WebCore/storage/Database.h index 02736c8..0bdb37b 100644 --- a/WebCore/storage/Database.h +++ b/WebCore/storage/Database.h @@ -57,7 +57,6 @@ class DatabaseThread; class Document; class SQLResultSet; class SQLTransactionCallback; -class SQLTransactionCoordinator; class SQLTransactionErrorCallback; class SQLValue; @@ -117,8 +116,6 @@ public: Vector<String> performGetTableNames(); - SQLTransactionCoordinator* transactionCoordinator() const; - private: Database(Document* document, const String& name, const String& expectedVersion); @@ -126,7 +123,7 @@ private: void scheduleTransaction(); void scheduleTransactionCallback(SQLTransaction*); - void scheduleTransactionStep(SQLTransaction* transaction, bool immediately = false); + void scheduleTransactionStep(SQLTransaction* transaction); MessageQueue<RefPtr<SQLTransaction> > m_transactionQueue; Mutex m_transactionInProgressMutex; diff --git a/WebCore/storage/DatabaseThread.cpp b/WebCore/storage/DatabaseThread.cpp index fb9b603..b6c9b5d 100644 --- a/WebCore/storage/DatabaseThread.cpp +++ b/WebCore/storage/DatabaseThread.cpp @@ -35,13 +35,11 @@ #include "Database.h" #include "DatabaseTask.h" #include "Logging.h" -#include "SQLTransactionCoordinator.h" namespace WebCore { DatabaseThread::DatabaseThread() : m_threadID(0) - , m_transactionCoordinator(new SQLTransactionCoordinator()) { m_selfRef = this; } @@ -99,9 +97,6 @@ void* DatabaseThread::databaseThread() pool.cycle(); } - // Clean up the list of all pending transactions on this database thread - m_transactionCoordinator->shutdown(); - LOG(StorageAPI, "About to detach thread %i and clear the ref to DatabaseThread %p, which currently has %i ref(s)", m_threadID, this, refCount()); // Close the databases that we ran transactions on. This ensures that if any transactions are still open, they are rolled back and we don't leave the database in an diff --git a/WebCore/storage/DatabaseThread.h b/WebCore/storage/DatabaseThread.h index 59d7a5d..5aab5fd 100644 --- a/WebCore/storage/DatabaseThread.h +++ b/WebCore/storage/DatabaseThread.h @@ -33,7 +33,6 @@ #include <wtf/HashMap.h> #include <wtf/HashSet.h> #include <wtf/MessageQueue.h> -#include <wtf/OwnPtr.h> #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> #include <wtf/Threading.h> @@ -43,7 +42,6 @@ namespace WebCore { class Database; class DatabaseTask; class Document; -class SQLTransactionCoordinator; class DatabaseThread : public ThreadSafeShared<DatabaseThread> { public: @@ -62,8 +60,6 @@ public: void recordDatabaseClosed(Database*); ThreadIdentifier getThreadID() { return m_threadID; } - SQLTransactionCoordinator* transactionCoordinator() { return m_transactionCoordinator.get(); } - private: DatabaseThread(); @@ -79,8 +75,6 @@ private: // This set keeps track of the open databases that have been used on this thread. typedef HashSet<RefPtr<Database> > DatabaseSet; DatabaseSet m_openDatabaseSet; - - OwnPtr<SQLTransactionCoordinator> m_transactionCoordinator; }; } // namespace WebCore diff --git a/WebCore/storage/SQLTransaction.cpp b/WebCore/storage/SQLTransaction.cpp index dc48ae1..3331e6e 100644 --- a/WebCore/storage/SQLTransaction.cpp +++ b/WebCore/storage/SQLTransaction.cpp @@ -50,7 +50,6 @@ #include "SQLStatement.h" #include "SQLStatementCallback.h" #include "SQLStatementErrorCallback.h" -#include "SQLTransactionCoordinator.h" #include "SQLValue.h" // There's no way of knowing exactly how much more space will be required when a statement hits the quota limit. @@ -68,7 +67,7 @@ PassRefPtr<SQLTransaction> SQLTransaction::create(Database* db, PassRefPtr<SQLTr SQLTransaction::SQLTransaction(Database* db, PassRefPtr<SQLTransactionCallback> callback, PassRefPtr<SQLTransactionErrorCallback> errorCallback, PassRefPtr<VoidCallback> successCallback, PassRefPtr<SQLTransactionWrapper> wrapper) - : m_nextStep(&SQLTransaction::acquireLock) + : m_nextStep(&SQLTransaction::openTransactionAndPreflight) , m_executeSqlAllowed(false) , m_database(db) , m_wrapper(wrapper) @@ -77,7 +76,6 @@ SQLTransaction::SQLTransaction(Database* db, PassRefPtr<SQLTransactionCallback> , m_errorCallback(errorCallback) , m_shouldRetryCurrentStatement(false) , m_modifiedDatabase(false) - , m_lockAcquired(false) { ASSERT(m_database); } @@ -118,9 +116,7 @@ void SQLTransaction::enqueueStatement(PassRefPtr<SQLStatement> statement) #ifndef NDEBUG const char* SQLTransaction::debugStepName(SQLTransaction::TransactionStepMethod step) { - if (step == &SQLTransaction::acquireLock) - return "acquireLock"; - else if (step == &SQLTransaction::openTransactionAndPreflight) + if (step == &SQLTransaction::openTransactionAndPreflight) return "openTransactionAndPreflight"; else if (step == &SQLTransaction::runStatements) return "runStatements"; @@ -161,9 +157,6 @@ void SQLTransaction::checkAndHandleClosedDatabase() m_sqliteTransaction->stop(); m_sqliteTransaction.clear(); } - - if (m_lockAcquired) - m_database->transactionCoordinator()->releaseLock(this); } @@ -171,8 +164,7 @@ bool SQLTransaction::performNextStep() { LOG(StorageAPI, "Step %s\n", debugStepName(m_nextStep)); - ASSERT(m_nextStep == &SQLTransaction::acquireLock || - m_nextStep == &SQLTransaction::openTransactionAndPreflight || + ASSERT(m_nextStep == &SQLTransaction::openTransactionAndPreflight || m_nextStep == &SQLTransaction::runStatements || m_nextStep == &SQLTransaction::postflightAndCommit || m_nextStep == &SQLTransaction::cleanupAfterSuccessCallback || @@ -203,23 +195,9 @@ void SQLTransaction::performPendingCallback() (this->*m_nextStep)(); } -void SQLTransaction::acquireLock() -{ - m_database->transactionCoordinator()->acquireLock(this); -} - -void SQLTransaction::lockAcquired() -{ - m_lockAcquired = true; - m_nextStep = &SQLTransaction::openTransactionAndPreflight; - LOG(StorageAPI, "Scheduling openTransactionAndPreflight immediately for transaction %p\n", this); - m_database->scheduleTransactionStep(this, true); -} - void SQLTransaction::openTransactionAndPreflight() { ASSERT(!m_database->m_sqliteDatabase.transactionInProgress()); - ASSERT(m_lockAcquired); LOG(StorageAPI, "Opening and preflighting transaction %p", this); @@ -295,8 +273,6 @@ void SQLTransaction::scheduleToRunStatements() void SQLTransaction::runStatements() { - ASSERT(m_lockAcquired); - // If there is a series of statements queued up that are all successful and have no associated // SQLStatementCallback objects, then we can burn through the queue do { @@ -435,8 +411,6 @@ void SQLTransaction::deliverQuotaIncreaseCallback() void SQLTransaction::postflightAndCommit() { - ASSERT(m_lockAcquired); - // Transaction Step 7 - Peform postflight steps, jumping to the error callback if they fail if (m_wrapper && !m_wrapper->performPostflight(this)) { m_transactionError = m_wrapper->sqlError(); @@ -495,16 +469,11 @@ void SQLTransaction::deliverSuccessCallback() void SQLTransaction::cleanupAfterSuccessCallback() { - ASSERT(m_lockAcquired); - // Transaction Step 11 - End transaction steps // There is no next step LOG(StorageAPI, "Transaction %p is complete\n", this); ASSERT(!m_database->m_sqliteDatabase.transactionInProgress()); m_nextStep = 0; - - // Release the lock on this database - m_database->transactionCoordinator()->releaseLock(this); } void SQLTransaction::handleTransactionError(bool inCallback) @@ -547,8 +516,6 @@ void SQLTransaction::deliverTransactionErrorCallback() void SQLTransaction::cleanupAfterTransactionErrorCallback() { - ASSERT(m_lockAcquired); - m_database->m_databaseAuthorizer->disable(); if (m_sqliteTransaction) { // Transaction Step 12 - Rollback the transaction. @@ -573,9 +540,6 @@ void SQLTransaction::cleanupAfterTransactionErrorCallback() // Now release our callbacks, to break reference cycles. m_callback = 0; m_errorCallback = 0; - - // Now release the lock on this database - m_database->transactionCoordinator()->releaseLock(this); } } // namespace WebCore diff --git a/WebCore/storage/SQLTransaction.h b/WebCore/storage/SQLTransaction.h index 141cef7..e77c183 100644 --- a/WebCore/storage/SQLTransaction.h +++ b/WebCore/storage/SQLTransaction.h @@ -73,7 +73,6 @@ public: void executeSQL(const String& sqlStatement, const Vector<SQLValue>& arguments, PassRefPtr<SQLStatementCallback> callback, PassRefPtr<SQLStatementErrorCallback> callbackError, ExceptionCode& e); - void lockAcquired(); bool performNextStep(); void performPendingCallback(); @@ -89,7 +88,6 @@ private: void checkAndHandleClosedDatabase(); - void acquireLock(); void openTransactionAndPreflight(); void deliverTransactionCallback(); void scheduleToRunStatements(); @@ -122,7 +120,6 @@ private: RefPtr<SQLError> m_transactionError; bool m_shouldRetryCurrentStatement; bool m_modifiedDatabase; - bool m_lockAcquired; Mutex m_statementMutex; Deque<RefPtr<SQLStatement> > m_statementQueue; diff --git a/WebCore/storage/SQLTransactionCoordinator.cpp b/WebCore/storage/SQLTransactionCoordinator.cpp deleted file mode 100644 index 63fd38e..0000000 --- a/WebCore/storage/SQLTransactionCoordinator.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "SQLTransactionCoordinator.h" - -#include "CString.h" -#include "Database.h" -#include "SQLTransaction.h" -#include <wtf/Deque.h> -#include <wtf/HashMap.h> -#include <wtf/RefPtr.h> - -namespace WebCore { - -static String getDatabaseIdentifier(SQLTransaction* transaction) -{ - Database* database = transaction->database(); - ASSERT(database); - return database->stringIdentifier(); -} - -void SQLTransactionCoordinator::acquireLock(SQLTransaction* transaction) -{ - String dbIdentifier = getDatabaseIdentifier(transaction); - - TransactionsHashMap::iterator it = m_pendingTransactions.find(dbIdentifier); - if (it == m_pendingTransactions.end()) { - // No pending transactions for this DB - TransactionsQueue pendingTransactions; - pendingTransactions.append(transaction); - m_pendingTransactions.add(dbIdentifier, pendingTransactions); - - // Start the transaction - transaction->lockAcquired(); - } else { - // Another transaction is running on this DB; put this one in the queue - TransactionsQueue& pendingTransactions = it->second; - pendingTransactions.append(transaction); - } -} - -void SQLTransactionCoordinator::releaseLock(SQLTransaction* transaction) -{ - if (m_pendingTransactions.isEmpty()) - return; - - String dbIdentifier = getDatabaseIdentifier(transaction); - - TransactionsHashMap::iterator it = m_pendingTransactions.find(dbIdentifier); - ASSERT(it != m_pendingTransactions.end()); - TransactionsQueue& pendingTransactions = it->second; - ASSERT(!pendingTransactions.isEmpty()); - - // 'transaction' should always be the first transaction in this queue - ASSERT(pendingTransactions.first().get() == transaction); - - // Remove 'transaction' from the queue of pending transactions - pendingTransactions.removeFirst(); - if (pendingTransactions.isEmpty()) { - // No more pending transactions; delete dbIdentifier's queue - m_pendingTransactions.remove(it); - } else { - // We have more pending transactions; start the next one - pendingTransactions.first()->lockAcquired(); - } -} - -void SQLTransactionCoordinator::shutdown() -{ - // Clean up all pending transactions for all databases - m_pendingTransactions.clear(); -} - -} diff --git a/WebCore/storage/SQLTransactionCoordinator.h b/WebCore/storage/SQLTransactionCoordinator.h deleted file mode 100644 index c6abfda..0000000 --- a/WebCore/storage/SQLTransactionCoordinator.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SQLTransactionCoordinator_h -#define SQLTransactionCoordinator_h - -#include "CString.h" -#include "StringHash.h" -#include <wtf/Deque.h> -#include <wtf/HashMap.h> -#include <wtf/RefPtr.h> - -namespace WebCore { - - class SQLTransaction; - - class SQLTransactionCoordinator { - public: - void acquireLock(SQLTransaction*); - void releaseLock(SQLTransaction*); - void shutdown(); - private: - typedef Deque<RefPtr<SQLTransaction> > TransactionsQueue; - typedef HashMap<String, TransactionsQueue> TransactionsHashMap; - TransactionsHashMap m_pendingTransactions; - }; -} - -#endif // SQLTransactionCoordinator_h diff --git a/WebCore/storage/Storage.h b/WebCore/storage/Storage.h index 197e693..d68e9bc 100644 --- a/WebCore/storage/Storage.h +++ b/WebCore/storage/Storage.h @@ -53,7 +53,6 @@ namespace WebCore { bool contains(const String& key) const; - Frame* frame() { return m_frame; } void disconnectFrame() { m_frame = 0; } private: diff --git a/WebCore/storage/StorageNamespace.h b/WebCore/storage/StorageNamespace.h index 825581f..edbe339 100644 --- a/WebCore/storage/StorageNamespace.h +++ b/WebCore/storage/StorageNamespace.h @@ -48,7 +48,6 @@ namespace WebCore { virtual PassRefPtr<StorageArea> storageArea(SecurityOrigin*) = 0; virtual PassRefPtr<StorageNamespace> copy() = 0; virtual void close() = 0; - virtual void unlock() = 0; }; } // namespace WebCore diff --git a/WebCore/storage/StorageNamespaceImpl.cpp b/WebCore/storage/StorageNamespaceImpl.cpp index 23725a5..b4caaeb 100644 --- a/WebCore/storage/StorageNamespaceImpl.cpp +++ b/WebCore/storage/StorageNamespaceImpl.cpp @@ -134,11 +134,6 @@ void StorageNamespaceImpl::close() m_isShutdown = true; } -void StorageNamespaceImpl::unlock() -{ - // Because there's a single event loop per-process, this is a no-op. -} - } // namespace WebCore #endif // ENABLE(DOM_STORAGE) diff --git a/WebCore/storage/StorageNamespaceImpl.h b/WebCore/storage/StorageNamespaceImpl.h index d3ef37f..0b15e43 100644 --- a/WebCore/storage/StorageNamespaceImpl.h +++ b/WebCore/storage/StorageNamespaceImpl.h @@ -49,7 +49,6 @@ namespace WebCore { virtual PassRefPtr<StorageArea> storageArea(SecurityOrigin*); virtual PassRefPtr<StorageNamespace> copy(); virtual void close(); - virtual void unlock(); private: StorageNamespaceImpl(StorageType, const String& path); |