Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (157765 => 157766)
--- trunk/Source/WebCore/CMakeLists.txt 2013-10-21 23:55:17 UTC (rev 157765)
+++ trunk/Source/WebCore/CMakeLists.txt 2013-10-22 00:18:03 UTC (rev 157766)
@@ -779,6 +779,7 @@
Modules/indexeddb/IDBPendingTransactionMonitor.cpp
Modules/indexeddb/IDBRequest.cpp
Modules/indexeddb/IDBTransaction.cpp
+ Modules/indexeddb/IDBTransactionCoordinator.cpp
Modules/indexeddb/IDBVersionChangeEvent.cpp
Modules/indexeddb/PageGroupIndexedDatabase.cpp
Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.cpp
@@ -790,7 +791,6 @@
Modules/indexeddb/leveldb/IDBObjectStoreBackendLevelDB.cpp
Modules/indexeddb/leveldb/IDBTransactionBackendLevelDB.cpp
Modules/indexeddb/leveldb/IDBTransactionBackendLevelDBOperations.cpp
- Modules/indexeddb/leveldb/IDBTransactionCoordinatorLevelDB.cpp
Modules/mediasource/MediaSource.cpp
Modules/mediasource/MediaSourceRegistry.cpp
Modified: trunk/Source/WebCore/ChangeLog (157765 => 157766)
--- trunk/Source/WebCore/ChangeLog 2013-10-21 23:55:17 UTC (rev 157765)
+++ trunk/Source/WebCore/ChangeLog 2013-10-22 00:18:03 UTC (rev 157766)
@@ -1,3 +1,40 @@
+2013-10-21 Brady Eidson <beid...@apple.com>
+
+ Make IDBTransactionCoordinatorLevelDB cross platform
+ https://bugs.webkit.org/show_bug.cgi?id=123124
+
+ Enthusiastically reviewed by Tim Horton.
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * WebCore.xcodeproj/project.pbxproj:
+
+ Make more methods pure virtual in the interface:
+ * Modules/indexeddb/IDBTransactionBackendInterface.h:
+ * Modules/indexeddb/leveldb/IDBTransactionBackendLevelDB.cpp:
+ * Modules/indexeddb/leveldb/IDBTransactionBackendLevelDB.h:
+
+ Update the name of the class, and use IDBTransactionBackendInterface instead of IDBTransactionBackendLeveDB:
+ * Modules/indexeddb/IDBTransactionCoordinator.cpp: Renamed from Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionCoordinatorLevelDB.cpp.
+ (WebCore::IDBTransactionCoordinator::create):
+ (WebCore::IDBTransactionCoordinator::IDBTransactionCoordinator):
+ (WebCore::IDBTransactionCoordinator::~IDBTransactionCoordinator):
+ (WebCore::IDBTransactionCoordinator::didCreateTransaction):
+ (WebCore::IDBTransactionCoordinator::didStartTransaction):
+ (WebCore::IDBTransactionCoordinator::didFinishTransaction):
+ (WebCore::IDBTransactionCoordinator::isActive):
+ (WebCore::IDBTransactionCoordinator::processStartedTransactions):
+ (WebCore::doScopesOverlap):
+ (WebCore::IDBTransactionCoordinator::canRunTransaction):
+ * Modules/indexeddb/IDBTransactionCoordinator.h: Renamed from Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionCoordinatorLevelDB.h.
+
+ Update the name of the class elsewhere:
+ * Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.cpp:
+ (WebCore::IDBDatabaseBackendLevelDB::IDBDatabaseBackendLevelDB):
+ * Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.h:
+ (WebCore::IDBDatabaseBackendLevelDB::transactionCoordinator):
+ * Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp:
+
2013-10-21 Daniel Bates <daba...@apple.com>
[iOS] Upstream JSGlobalObject::shouldInterruptScriptBeforeTimeout()
Modified: trunk/Source/WebCore/GNUmakefile.list.am (157765 => 157766)
--- trunk/Source/WebCore/GNUmakefile.list.am 2013-10-21 23:55:17 UTC (rev 157765)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2013-10-22 00:18:03 UTC (rev 157766)
@@ -1847,11 +1847,11 @@
Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionBackendLevelDB.h \
Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionBackendLevelDBOperations.cpp \
Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionBackendLevelDBOperations.h \
- Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionCoordinatorLevelDB.cpp \
- Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionCoordinatorLevelDB.h \
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp \
Source/WebCore/Modules/indexeddb/IDBTransaction.h \
Source/WebCore/Modules/indexeddb/IDBTransactionBackendInterface.h \
+ Source/WebCore/Modules/indexeddb/IDBTransactionCoordinator.cpp \
+ Source/WebCore/Modules/indexeddb/IDBTransactionCoordinator.h \
Source/WebCore/Modules/indexeddb/IDBVersionChangeEvent.cpp \
Source/WebCore/Modules/indexeddb/IDBVersionChangeEvent.h \
Source/WebCore/Modules/indexeddb/IndexedDB.h \
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendInterface.h (157765 => 157766)
--- trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendInterface.h 2013-10-21 23:55:17 UTC (rev 157765)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendInterface.h 2013-10-22 00:18:03 UTC (rev 157766)
@@ -52,9 +52,11 @@
virtual IndexedDB::TransactionMode mode() const = 0;
+ virtual void run() = 0;
virtual void commit() = 0;
virtual void abort() = 0;
virtual void abort(PassRefPtr<IDBDatabaseError>) = 0;
+ virtual const HashSet<int64_t>& scope() const = 0;
virtual void scheduleCreateObjectStoreOperation(const IDBObjectStoreMetadata&) = 0;
virtual void scheduleDeleteObjectStoreOperation(const IDBObjectStoreMetadata&) = 0;
Copied: trunk/Source/WebCore/Modules/indexeddb/IDBTransactionCoordinator.cpp (from rev 157764, trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionCoordinatorLevelDB.cpp) (0 => 157766)
--- trunk/Source/WebCore/Modules/indexeddb/IDBTransactionCoordinator.cpp (rev 0)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransactionCoordinator.cpp 2013-10-22 00:18:03 UTC (rev 157766)
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2010 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:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE OR ITS 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 "IDBTransactionCoordinator.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBDatabaseCallbacks.h"
+#include "IDBTransactionBackendInterface.h"
+
+namespace WebCore {
+
+PassOwnPtr<IDBTransactionCoordinator> IDBTransactionCoordinator::create()
+{
+ return adoptPtr(new IDBTransactionCoordinator());
+}
+
+IDBTransactionCoordinator::IDBTransactionCoordinator()
+{
+}
+
+IDBTransactionCoordinator::~IDBTransactionCoordinator()
+{
+}
+
+void IDBTransactionCoordinator::didCreateTransaction(IDBTransactionBackendInterface* transaction)
+{
+ ASSERT(!m_transactions.contains(transaction));
+ m_transactions.add(transaction, transaction);
+}
+
+void IDBTransactionCoordinator::didStartTransaction(IDBTransactionBackendInterface* transaction)
+{
+ ASSERT(m_transactions.contains(transaction));
+
+ m_queuedTransactions.add(transaction);
+ processStartedTransactions();
+}
+
+void IDBTransactionCoordinator::didFinishTransaction(IDBTransactionBackendInterface* transaction)
+{
+ ASSERT(m_transactions.contains(transaction));
+
+ if (m_queuedTransactions.contains(transaction)) {
+ ASSERT(!m_startedTransactions.contains(transaction));
+ m_queuedTransactions.remove(transaction);
+ } else if (m_startedTransactions.contains(transaction))
+ m_startedTransactions.remove(transaction);
+
+ m_transactions.remove(transaction);
+
+ processStartedTransactions();
+}
+
+#ifndef NDEBUG
+// Verifies internal consistiency while returning whether anything is found.
+bool IDBTransactionCoordinator::isActive(IDBTransactionBackendInterface* transaction)
+{
+ bool found = false;
+ if (m_queuedTransactions.contains(transaction))
+ found = true;
+ if (m_startedTransactions.contains(transaction)) {
+ ASSERT(!found);
+ found = true;
+ }
+ ASSERT(found == m_transactions.contains(transaction));
+ return found;
+}
+#endif
+
+void IDBTransactionCoordinator::processStartedTransactions()
+{
+ if (m_queuedTransactions.isEmpty())
+ return;
+
+ ASSERT(m_startedTransactions.isEmpty() || (*m_startedTransactions.begin())->mode() != IndexedDB::TransactionVersionChange);
+
+ ListHashSet<IDBTransactionBackendInterface*>::const_iterator it = m_queuedTransactions.begin();
+ while (it != m_queuedTransactions.end()) {
+ IDBTransactionBackendInterface* transaction = *it;
+ ++it;
+ if (canRunTransaction(transaction)) {
+ m_queuedTransactions.remove(transaction);
+ m_startedTransactions.add(transaction);
+ transaction->run();
+ }
+ }
+}
+
+static bool doScopesOverlap(const HashSet<int64_t>& scope1, const HashSet<int64_t>& scope2)
+{
+ for (HashSet<int64_t>::const_iterator it = scope1.begin(); it != scope1.end(); ++it) {
+ if (scope2.contains(*it))
+ return true;
+ }
+ return false;
+}
+
+bool IDBTransactionCoordinator::canRunTransaction(IDBTransactionBackendInterface* transaction)
+{
+ ASSERT(m_queuedTransactions.contains(transaction));
+ switch (transaction->mode()) {
+ case IndexedDB::TransactionVersionChange:
+ ASSERT(m_queuedTransactions.size() == 1);
+ ASSERT(m_startedTransactions.isEmpty());
+ return true;
+
+ case IndexedDB::TransactionReadOnly:
+ return true;
+
+ case IndexedDB::TransactionReadWrite:
+ for (HashSet<IDBTransactionBackendInterface*>::const_iterator it = m_startedTransactions.begin(); it != m_startedTransactions.end(); ++it) {
+ if ((*it)->mode() == IndexedDB::TransactionReadWrite && doScopesOverlap(transaction->scope(), (*it)->scope()))
+ return false;
+ }
+ for (ListHashSet<IDBTransactionBackendInterface*>::const_iterator it = m_queuedTransactions.begin(); *it != transaction; ++it) {
+ ASSERT(it != m_queuedTransactions.end());
+ if ((*it)->mode() == IndexedDB::TransactionReadWrite && doScopesOverlap(transaction->scope(), (*it)->scope()))
+ return false;
+ }
+ return true;
+ }
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+};
+
+#endif // ENABLE(INDEXED_DATABASE)
Copied: trunk/Source/WebCore/Modules/indexeddb/IDBTransactionCoordinator.h (from rev 157764, trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionCoordinatorLevelDB.h) (0 => 157766)
--- trunk/Source/WebCore/Modules/indexeddb/IDBTransactionCoordinator.h (rev 0)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransactionCoordinator.h 2013-10-22 00:18:03 UTC (rev 157766)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 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:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE OR ITS 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 IDBTransactionCoordinator_h
+#define IDBTransactionCoordinator_h
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include <wtf/HashMap.h>
+#include <wtf/ListHashSet.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class IDBTransactionBackendInterface;
+
+// Transactions are executed in the order the were created.
+class IDBTransactionCoordinator {
+public:
+ static PassOwnPtr<IDBTransactionCoordinator> create();
+ virtual ~IDBTransactionCoordinator();
+
+ // Called by transactions as they start and finish.
+ void didCreateTransaction(IDBTransactionBackendInterface*);
+ void didStartTransaction(IDBTransactionBackendInterface*);
+ void didFinishTransaction(IDBTransactionBackendInterface*);
+
+#ifndef NDEBUG
+ bool isActive(IDBTransactionBackendInterface*);
+#endif
+
+private:
+ IDBTransactionCoordinator();
+
+ void processStartedTransactions();
+ bool canRunTransaction(IDBTransactionBackendInterface*);
+
+ // This is just an efficient way to keep references to all transactions.
+ HashMap<IDBTransactionBackendInterface*, RefPtr<IDBTransactionBackendInterface> > m_transactions;
+ // Transactions in different states are grouped below.
+ ListHashSet<IDBTransactionBackendInterface*> m_queuedTransactions;
+ HashSet<IDBTransactionBackendInterface*> m_startedTransactions;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
+
+#endif // IDBTransactionCoordinator_h
Modified: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.cpp (157765 => 157766)
--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.cpp 2013-10-21 23:55:17 UTC (rev 157765)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.cpp 2013-10-22 00:18:03 UTC (rev 157766)
@@ -35,7 +35,7 @@
#include "IDBKeyRange.h"
#include "IDBObjectStoreBackendLevelDB.h"
#include "IDBTransactionBackendLevelDB.h"
-#include "IDBTransactionCoordinatorLevelDB.h"
+#include "IDBTransactionCoordinator.h"
#include "Logging.h"
#include "SharedBuffer.h"
#include <wtf/TemporaryChange.h>
@@ -55,7 +55,7 @@
, m_metadata(name, InvalidId, 0, InvalidId)
, m_identifier(uniqueIdentifier)
, m_factory(factory)
- , m_transactionCoordinator(IDBTransactionCoordinatorLevelDB::create())
+ , m_transactionCoordinator(IDBTransactionCoordinator::create())
, m_closingConnection(false)
{
ASSERT(!m_metadata.name.isNull());
Modified: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.h (157765 => 157766)
--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.h 2013-10-21 23:55:17 UTC (rev 157765)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBDatabaseBackendLevelDB.h 2013-10-22 00:18:03 UTC (rev 157766)
@@ -41,7 +41,7 @@
class IDBDatabase;
class IDBFactoryBackendInterface;
class IDBTransactionBackendInterface;
-class IDBTransactionCoordinatorLevelDB;
+class IDBTransactionCoordinator;
class IDBDatabaseBackendLevelDB : public IDBDatabaseBackendInterface {
public:
@@ -74,7 +74,7 @@
virtual void createIndex(int64_t transactionId, int64_t objectStoreId, int64_t indexId, const String& name, const IDBKeyPath&, bool unique, bool multiEntry);
virtual void deleteIndex(int64_t transactionId, int64_t objectStoreId, int64_t indexId);
- IDBTransactionCoordinatorLevelDB* transactionCoordinator() const { return m_transactionCoordinator.get(); }
+ IDBTransactionCoordinator* transactionCoordinator() const { return m_transactionCoordinator.get(); }
void transactionStarted(IDBTransactionBackendInterface*);
void transactionFinished(IDBTransactionBackendInterface*);
void transactionFinishedAndCompleteFired(IDBTransactionBackendInterface*);
@@ -110,7 +110,7 @@
// This might not need to be a RefPtr since the factory's lifetime is that of the page group, but it's better to be conservitive than sorry.
RefPtr<IDBFactoryBackendInterface> m_factory;
- OwnPtr<IDBTransactionCoordinatorLevelDB> m_transactionCoordinator;
+ OwnPtr<IDBTransactionCoordinator> m_transactionCoordinator;
RefPtr<IDBTransactionBackendInterface> m_runningVersionChangeTransaction;
typedef HashMap<int64_t, IDBTransactionBackendInterface*> TransactionMap;
Modified: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp (157765 => 157766)
--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp 2013-10-21 23:55:17 UTC (rev 157765)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp 2013-10-22 00:18:03 UTC (rev 157766)
@@ -34,7 +34,7 @@
#include "IDBDatabaseBackendLevelDB.h"
#include "IDBDatabaseException.h"
#include "IDBTransactionBackendLevelDB.h"
-#include "IDBTransactionCoordinatorLevelDB.h"
+#include "IDBTransactionCoordinator.h"
#include "Logging.h"
#include "SecurityOrigin.h"
Modified: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionBackendLevelDB.cpp (157765 => 157766)
--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionBackendLevelDB.cpp 2013-10-21 23:55:17 UTC (rev 157765)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionBackendLevelDB.cpp 2013-10-22 00:18:03 UTC (rev 157766)
@@ -35,7 +35,7 @@
#include "IDBDatabaseException.h"
#include "IDBKeyRange.h"
#include "IDBTransactionBackendLevelDBOperations.h"
-#include "IDBTransactionCoordinatorLevelDB.h"
+#include "IDBTransactionCoordinator.h"
#include "Logging.h"
namespace WebCore {
Modified: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionBackendLevelDB.h (157765 => 157766)
--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionBackendLevelDB.h 2013-10-21 23:55:17 UTC (rev 157765)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionBackendLevelDB.h 2013-10-22 00:18:03 UTC (rev 157766)
@@ -44,7 +44,7 @@
class IDBCursorBackendLevelDB;
class IDBDatabaseCallbacks;
-class IDBTransactionBackendLevelDB : public IDBTransactionBackendInterface {
+class IDBTransactionBackendLevelDB FINAL : public IDBTransactionBackendInterface {
public:
static PassRefPtr<IDBTransactionBackendLevelDB> create(IDBDatabaseBackendLevelDB*, int64_t transactionId, PassRefPtr<IDBDatabaseCallbacks>, const Vector<int64_t>& objectStoreIds, IndexedDB::TransactionMode);
virtual ~IDBTransactionBackendLevelDB();
@@ -59,9 +59,9 @@
virtual void perform() = 0;
};
- void run();
+ virtual void run() OVERRIDE;
virtual IndexedDB::TransactionMode mode() const OVERRIDE FINAL { return m_mode; }
- const HashSet<int64_t>& scope() const { return m_objectStoreIds; }
+ const HashSet<int64_t>& scope() const OVERRIDE { return m_objectStoreIds; }
void scheduleTask(PassOwnPtr<Operation> task, PassOwnPtr<Operation> abortTask = nullptr) { scheduleTask(IDBDatabaseBackendInterface::NormalTask, task, abortTask); }
void scheduleTask(IDBDatabaseBackendInterface::TaskType, PassOwnPtr<Operation>, PassOwnPtr<Operation> abortTask = nullptr);
void registerOpenCursor(IDBCursorBackendLevelDB*);
Deleted: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionCoordinatorLevelDB.cpp (157765 => 157766)
--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionCoordinatorLevelDB.cpp 2013-10-21 23:55:17 UTC (rev 157765)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionCoordinatorLevelDB.cpp 2013-10-22 00:18:03 UTC (rev 157766)
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2010 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:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE OR ITS 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 "IDBTransactionCoordinatorLevelDB.h"
-
-#if ENABLE(INDEXED_DATABASE) && USE(LEVELDB)
-
-#include "IDBDatabaseBackendLevelDB.h"
-#include "IDBDatabaseCallbacks.h"
-#include "IDBTransactionBackendLevelDB.h"
-
-namespace WebCore {
-
-PassOwnPtr<IDBTransactionCoordinatorLevelDB> IDBTransactionCoordinatorLevelDB::create()
-{
- return adoptPtr(new IDBTransactionCoordinatorLevelDB());
-}
-
-IDBTransactionCoordinatorLevelDB::IDBTransactionCoordinatorLevelDB()
-{
-}
-
-IDBTransactionCoordinatorLevelDB::~IDBTransactionCoordinatorLevelDB()
-{
-}
-
-void IDBTransactionCoordinatorLevelDB::didCreateTransaction(IDBTransactionBackendLevelDB* transaction)
-{
- ASSERT(!m_transactions.contains(transaction));
- m_transactions.add(transaction, transaction);
-}
-
-void IDBTransactionCoordinatorLevelDB::didStartTransaction(IDBTransactionBackendLevelDB* transaction)
-{
- ASSERT(m_transactions.contains(transaction));
-
- m_queuedTransactions.add(transaction);
- processStartedTransactions();
-}
-
-void IDBTransactionCoordinatorLevelDB::didFinishTransaction(IDBTransactionBackendLevelDB* transaction)
-{
- ASSERT(m_transactions.contains(transaction));
-
- if (m_queuedTransactions.contains(transaction)) {
- ASSERT(!m_startedTransactions.contains(transaction));
- m_queuedTransactions.remove(transaction);
- } else if (m_startedTransactions.contains(transaction))
- m_startedTransactions.remove(transaction);
-
- m_transactions.remove(transaction);
-
- processStartedTransactions();
-}
-
-#ifndef NDEBUG
-// Verifies internal consistiency while returning whether anything is found.
-bool IDBTransactionCoordinatorLevelDB::isActive(IDBTransactionBackendLevelDB* transaction)
-{
- bool found = false;
- if (m_queuedTransactions.contains(transaction))
- found = true;
- if (m_startedTransactions.contains(transaction)) {
- ASSERT(!found);
- found = true;
- }
- ASSERT(found == m_transactions.contains(transaction));
- return found;
-}
-#endif
-
-void IDBTransactionCoordinatorLevelDB::processStartedTransactions()
-{
- if (m_queuedTransactions.isEmpty())
- return;
-
- ASSERT(m_startedTransactions.isEmpty() || (*m_startedTransactions.begin())->mode() != IndexedDB::TransactionVersionChange);
-
- ListHashSet<IDBTransactionBackendLevelDB*>::const_iterator it = m_queuedTransactions.begin();
- while (it != m_queuedTransactions.end()) {
- IDBTransactionBackendLevelDB* transaction = *it;
- ++it;
- if (canRunTransaction(transaction)) {
- m_queuedTransactions.remove(transaction);
- m_startedTransactions.add(transaction);
- transaction->run();
- }
- }
-}
-
-static bool doScopesOverlap(const HashSet<int64_t>& scope1, const HashSet<int64_t>& scope2)
-{
- for (HashSet<int64_t>::const_iterator it = scope1.begin(); it != scope1.end(); ++it) {
- if (scope2.contains(*it))
- return true;
- }
- return false;
-}
-
-bool IDBTransactionCoordinatorLevelDB::canRunTransaction(IDBTransactionBackendLevelDB* transaction)
-{
- ASSERT(m_queuedTransactions.contains(transaction));
- switch (transaction->mode()) {
- case IndexedDB::TransactionVersionChange:
- ASSERT(m_queuedTransactions.size() == 1);
- ASSERT(m_startedTransactions.isEmpty());
- return true;
-
- case IndexedDB::TransactionReadOnly:
- return true;
-
- case IndexedDB::TransactionReadWrite:
- for (HashSet<IDBTransactionBackendLevelDB*>::const_iterator it = m_startedTransactions.begin(); it != m_startedTransactions.end(); ++it) {
- if ((*it)->mode() == IndexedDB::TransactionReadWrite && doScopesOverlap(transaction->scope(), (*it)->scope()))
- return false;
- }
- for (ListHashSet<IDBTransactionBackendLevelDB*>::const_iterator it = m_queuedTransactions.begin(); *it != transaction; ++it) {
- ASSERT(it != m_queuedTransactions.end());
- if ((*it)->mode() == IndexedDB::TransactionReadWrite && doScopesOverlap(transaction->scope(), (*it)->scope()))
- return false;
- }
- return true;
- }
- ASSERT_NOT_REACHED();
- return false;
-}
-
-};
-
-#endif // ENABLE(INDEXED_DATABASE) && USE(LEVELDB)
Deleted: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionCoordinatorLevelDB.h (157765 => 157766)
--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionCoordinatorLevelDB.h 2013-10-21 23:55:17 UTC (rev 157765)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBTransactionCoordinatorLevelDB.h 2013-10-22 00:18:03 UTC (rev 157766)
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2010 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:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE OR ITS 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 IDBTransactionCoordinatorLevelDB_h
-#define IDBTransactionCoordinatorLevelDB_h
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include <wtf/HashMap.h>
-#include <wtf/ListHashSet.h>
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-class IDBTransactionBackendLevelDB;
-
-// Transactions are executed in the order the were created.
-class IDBTransactionCoordinatorLevelDB {
-public:
- static PassOwnPtr<IDBTransactionCoordinatorLevelDB> create();
- virtual ~IDBTransactionCoordinatorLevelDB();
-
- // Called by transactions as they start and finish.
- void didCreateTransaction(IDBTransactionBackendLevelDB*);
- void didStartTransaction(IDBTransactionBackendLevelDB*);
- void didFinishTransaction(IDBTransactionBackendLevelDB*);
-
-#ifndef NDEBUG
- bool isActive(IDBTransactionBackendLevelDB*);
-#endif
-
-private:
- IDBTransactionCoordinatorLevelDB();
-
- void processStartedTransactions();
- bool canRunTransaction(IDBTransactionBackendLevelDB*);
-
- // This is just an efficient way to keep references to all transactions.
- HashMap<IDBTransactionBackendLevelDB*, RefPtr<IDBTransactionBackendLevelDB> > m_transactions;
- // Transactions in different states are grouped below.
- ListHashSet<IDBTransactionBackendLevelDB*> m_queuedTransactions;
- HashSet<IDBTransactionBackendLevelDB*> m_startedTransactions;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
-
-#endif // IDBTransactionCoordinatorLevelDB_h
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (157765 => 157766)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-10-21 23:55:17 UTC (rev 157765)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-10-22 00:18:03 UTC (rev 157766)
@@ -1811,6 +1811,8 @@
51E3F9D60DA05E1D00250911 /* JSStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51E3F9D40DA05E1D00250911 /* JSStorage.cpp */; };
51E4143416A6596300C633C7 /* ResourceHandleTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E4143216A6595100C633C7 /* ResourceHandleTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
51E6821016387302003BBF3C /* LoaderStrategy.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E6820F16387302003BBF3C /* LoaderStrategy.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 51EAC5671815ED3E004F1BA4 /* IDBTransactionCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51EAC5651815ED3E004F1BA4 /* IDBTransactionCoordinator.cpp */; };
+ 51EAC5681815ED3E004F1BA4 /* IDBTransactionCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 51EAC5661815ED3E004F1BA4 /* IDBTransactionCoordinator.h */; settings = {ATTRIBUTES = (Private, ); }; };
51EC92650CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51EC925D0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp */; };
51F6E0A31811D2520058A00A /* IDBTransactionBackendInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F6E08F1811D2520058A00A /* IDBTransactionBackendInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
51FA2D78152132B300C1BA0B /* DOMWindowExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 517FBA18151AA71B00B57959 /* DOMWindowExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -8409,6 +8411,8 @@
51E3F9D50DA05E1D00250911 /* JSStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStorage.h; sourceTree = "<group>"; };
51E4143216A6595100C633C7 /* ResourceHandleTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceHandleTypes.h; sourceTree = "<group>"; };
51E6820F16387302003BBF3C /* LoaderStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoaderStrategy.h; sourceTree = "<group>"; };
+ 51EAC5651815ED3E004F1BA4 /* IDBTransactionCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBTransactionCoordinator.cpp; sourceTree = "<group>"; };
+ 51EAC5661815ED3E004F1BA4 /* IDBTransactionCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBTransactionCoordinator.h; sourceTree = "<group>"; };
51EC925D0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomSQLStatementErrorCallback.cpp; sourceTree = "<group>"; };
51F6A3D50663BF04004D2919 /* HTMLCanvasElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLCanvasElement.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
51F6A3D60663BF04004D2919 /* HTMLCanvasElement.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HTMLCanvasElement.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
@@ -16756,6 +16760,8 @@
51D719A5181106E00016DC51 /* IDBTransaction.h */,
51D719A6181106E00016DC51 /* IDBTransaction.idl */,
51F6E08F1811D2520058A00A /* IDBTransactionBackendInterface.h */,
+ 51EAC5651815ED3E004F1BA4 /* IDBTransactionCoordinator.cpp */,
+ 51EAC5661815ED3E004F1BA4 /* IDBTransactionCoordinator.h */,
51D719AB181106E00016DC51 /* IDBVersionChangeEvent.cpp */,
51D719AC181106E00016DC51 /* IDBVersionChangeEvent.h */,
51D719AD181106E00016DC51 /* IDBVersionChangeEvent.idl */,
@@ -22828,6 +22834,7 @@
2E2D99CE10E2BBDA00496337 /* JSBlob.h in Headers */,
1449E24C107D4A8400B5793F /* JSCallbackData.h in Headers */,
65DF323A09D1DE65000BE325 /* JSCanvasGradient.h in Headers */,
+ 51EAC5681815ED3E004F1BA4 /* IDBTransactionCoordinator.h in Headers */,
65DF323C09D1DE65000BE325 /* JSCanvasPattern.h in Headers */,
65DF323C09D1DE65001BE325 /* JSCanvasProxy.h in Headers */,
E4D58EB517B4DBDC00CBDCA8 /* StyleResolveForDocument.h in Headers */,
@@ -26357,6 +26364,7 @@
1AE82FEC0CAB07EE002237AE /* JSSQLResultSet.cpp in Sources */,
1AFE11990CBFFCC4003017FA /* JSSQLResultSetRowList.cpp in Sources */,
51DCE8020CAC9F1C00488358 /* JSSQLResultSetRowListCustom.cpp in Sources */,
+ 51EAC5671815ED3E004F1BA4 /* IDBTransactionCoordinator.cpp in Sources */,
B59DD6A611902A62007E9684 /* JSSQLStatementCallback.cpp in Sources */,
B59DD6AA11902A71007E9684 /* JSSQLStatementErrorCallback.cpp in Sources */,
514C76380CE9225E007EF3CD /* JSSQLTransaction.cpp in Sources */,