Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (159358 => 159359)
--- trunk/Source/WebCore/CMakeLists.txt 2013-11-15 22:22:30 UTC (rev 159358)
+++ trunk/Source/WebCore/CMakeLists.txt 2013-11-15 22:24:14 UTC (rev 159359)
@@ -798,7 +798,6 @@
Modules/indexeddb/IDBFactory.cpp
Modules/indexeddb/IDBFactoryBackendInterface.cpp
Modules/indexeddb/IDBIndex.cpp
- Modules/indexeddb/IDBIndexWriter.cpp
Modules/indexeddb/IDBKey.cpp
Modules/indexeddb/IDBKeyPath.cpp
Modules/indexeddb/IDBKeyRange.cpp
@@ -818,6 +817,7 @@
Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp
Modules/indexeddb/leveldb/IDBBackingStoreTransactionLevelDB.cpp
Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp
+ Modules/indexeddb/leveldb/IDBIndexWriterLevelDB.cpp
Modules/indexeddb/leveldb/IDBLevelDBCoding.cpp
Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp
Modified: trunk/Source/WebCore/ChangeLog (159358 => 159359)
--- trunk/Source/WebCore/ChangeLog 2013-11-15 22:22:30 UTC (rev 159358)
+++ trunk/Source/WebCore/ChangeLog 2013-11-15 22:24:14 UTC (rev 159359)
@@ -1,3 +1,35 @@
+2013-11-15 Brady Eidson <beid...@apple.com>
+
+ Make IDBIndexWriter a LevelDB specific concept
+ https://bugs.webkit.org/show_bug.cgi?id=124434
+
+ Reviewed by Tim Horton.
+
+ This includes renaming the class and moving it into the leveldb subdirectory.
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * WebCore.xcodeproj/project.pbxproj:
+
+ * Modules/indexeddb/IDBBackingStoreInterface.h:
+ * Modules/indexeddb/IDBTransactionBackendOperations.cpp:
+
+ * Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp:
+ (WebCore::IDBBackingStoreLevelDB::makeIndexWriters):
+ * Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h:
+
+ * Modules/indexeddb/leveldb/IDBIndexWriterLevelDB.cpp: Renamed from Source/WebCore/Modules/indexeddb/IDBIndexWriter.cpp.
+ (WebCore::IDBIndexWriterLevelDB::IDBIndexWriterLevelDB):
+ (WebCore::IDBIndexWriterLevelDB::writeIndexKeys):
+ (WebCore::IDBIndexWriterLevelDB::verifyIndexKeys):
+ (WebCore::IDBIndexWriterLevelDB::addingKeyAllowed):
+ * Modules/indexeddb/leveldb/IDBIndexWriterLevelDB.h: Renamed from Source/WebCore/Modules/indexeddb/IDBIndexWriter.h.
+ (WebCore::IDBIndexWriterLevelDB::create):
+
+ * Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp:
+ (WebCore::IDBServerConnectionLevelDB::setIndexKeys):
+ (WebCore::IDBServerConnectionLevelDB::put):
+
2013-11-15 Alexandru Chiculita <ach...@adobe.com>
Web Inspector: DOM.performSearch should accept a list of context nodes
Modified: trunk/Source/WebCore/GNUmakefile.list.am (159358 => 159359)
--- trunk/Source/WebCore/GNUmakefile.list.am 2013-11-15 22:22:30 UTC (rev 159358)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2013-11-15 22:24:14 UTC (rev 159359)
@@ -1796,6 +1796,8 @@
Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h \
Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreTransactionLevelDB.cpp \
Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreTransactionLevelDB.h \
+ Source/WebCore/Modules/indexeddb/leveldb/IDBIndexWriterLevelDB.cpp \
+ Source/WebCore/Modules/indexeddb/leveldb/IDBIndexWriterLevelDB.h \
Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp \
Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.h \
Source/WebCore/Modules/indexeddb/IDBCallbacks.h \
@@ -1826,8 +1828,6 @@
Source/WebCore/Modules/indexeddb/IDBHistograms.h \
Source/WebCore/Modules/indexeddb/IDBIndex.cpp \
Source/WebCore/Modules/indexeddb/IDBIndex.h \
- Source/WebCore/Modules/indexeddb/IDBIndexWriter.cpp \
- Source/WebCore/Modules/indexeddb/IDBIndexWriter.h \
Source/WebCore/Modules/indexeddb/IDBKey.cpp \
Source/WebCore/Modules/indexeddb/IDBKey.h \
Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp \
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBBackingStoreInterface.h (159358 => 159359)
--- trunk/Source/WebCore/Modules/indexeddb/IDBBackingStoreInterface.h 2013-11-15 22:22:30 UTC (rev 159358)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBBackingStoreInterface.h 2013-11-15 22:24:14 UTC (rev 159359)
@@ -41,7 +41,7 @@
namespace WebCore {
-class IDBIndexWriter;
+class IDBIndexWriterLevelDB;
class IDBKey;
class IDBKeyPath;
class IDBKeyRange;
@@ -91,7 +91,7 @@
virtual bool getKeyGeneratorCurrentNumber(IDBBackingStoreTransactionInterface&, int64_t databaseId, int64_t objectStoreId, int64_t& keyGeneratorCurrentNumber) = 0;
virtual bool maybeUpdateKeyGeneratorCurrentNumber(IDBBackingStoreTransactionInterface&, int64_t databaseId, int64_t objectStoreId, int64_t newState, bool checkCurrent) = 0;
- virtual bool makeIndexWriters(int64_t transactionID, int64_t databaseId, const IDBObjectStoreMetadata&, IDBKey& primaryKey, bool keyWasGenerated, const Vector<int64_t>& indexIds, const Vector<Vector<RefPtr<IDBKey>>>&, Vector<RefPtr<IDBIndexWriter>>& indexWriters, String* errorMessage, bool& completed) = 0;
+ virtual bool makeIndexWriters(int64_t transactionID, int64_t databaseId, const IDBObjectStoreMetadata&, IDBKey& primaryKey, bool keyWasGenerated, const Vector<int64_t>& indexIds, const Vector<Vector<RefPtr<IDBKey>>>&, Vector<RefPtr<IDBIndexWriterLevelDB>>& indexWriters, String* errorMessage, bool& completed) = 0;
virtual PassRefPtr<IDBKey> generateKey(IDBTransactionBackend&, int64_t databaseId, int64_t objectStoreId) = 0;
virtual bool updateKeyGenerator(IDBTransactionBackend&, int64_t databaseId, int64_t objectStoreId, const IDBKey&, bool checkCurrent) = 0;
Deleted: trunk/Source/WebCore/Modules/indexeddb/IDBIndexWriter.cpp (159358 => 159359)
--- trunk/Source/WebCore/Modules/indexeddb/IDBIndexWriter.cpp 2013-11-15 22:22:30 UTC (rev 159358)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBIndexWriter.cpp 2013-11-15 22:24:14 UTC (rev 159359)
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- * 2013 Apple 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 INC. 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 INC. 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 "IDBIndexWriter.h"
-
-#include "IDBKey.h"
-#include <wtf/text/CString.h>
-
-#if ENABLE(INDEXED_DATABASE)
-
-namespace WebCore {
-
-IDBIndexWriter::IDBIndexWriter(const IDBIndexMetadata& metadata, const IndexKeys& keys)
- : m_indexMetadata(metadata)
- , m_indexKeys(keys)
-{
-}
-
-void IDBIndexWriter::writeIndexKeys(const IDBRecordIdentifier* recordIdentifier, IDBBackingStoreInterface& backingStore, IDBBackingStoreTransactionInterface& transaction, int64_t databaseId, int64_t objectStoreId) const
-{
- ASSERT(recordIdentifier);
- int64_t indexId = m_indexMetadata.id;
- for (size_t i = 0; i < m_indexKeys.size(); ++i) {
- bool ok = backingStore.putIndexDataForRecord(transaction, databaseId, objectStoreId, indexId, *(m_indexKeys)[i].get(), recordIdentifier);
- // This should have already been verified as a valid write during verifyIndexKeys.
- ASSERT_UNUSED(ok, ok);
- }
-}
-
-bool IDBIndexWriter::verifyIndexKeys(IDBBackingStoreInterface& backingStore, IDBBackingStoreTransactionInterface& transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, bool& canAddKeys, const IDBKey* primaryKey, String* errorMessage) const
-{
- canAddKeys = false;
- for (size_t i = 0; i < m_indexKeys.size(); ++i) {
- bool ok = addingKeyAllowed(backingStore, transaction, databaseId, objectStoreId, indexId, (m_indexKeys)[i].get(), primaryKey, canAddKeys);
- if (!ok)
- return false;
- if (!canAddKeys) {
- if (errorMessage)
- *errorMessage = String::format("Unable to add key to index '%s': at least one key does not satisfy the uniqueness requirements.", m_indexMetadata.name.utf8().data());
- return true;
- }
- }
- canAddKeys = true;
- return true;
-}
-
-bool IDBIndexWriter::addingKeyAllowed(IDBBackingStoreInterface& backingStore, IDBBackingStoreTransactionInterface& transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey* indexKey, const IDBKey* primaryKey, bool& allowed) const
-{
- allowed = false;
- if (!m_indexMetadata.unique) {
- allowed = true;
- return true;
- }
-
- RefPtr<IDBKey> foundPrimaryKey;
- bool found = false;
- bool ok = backingStore.keyExistsInIndex(transaction, databaseId, objectStoreId, indexId, *indexKey, foundPrimaryKey, found);
- if (!ok)
- return false;
- if (!found || (primaryKey && foundPrimaryKey->isEqual(primaryKey)))
- allowed = true;
- return true;
-}
-
-
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
Deleted: trunk/Source/WebCore/Modules/indexeddb/IDBIndexWriter.h (159358 => 159359)
--- trunk/Source/WebCore/Modules/indexeddb/IDBIndexWriter.h 2013-11-15 22:22:30 UTC (rev 159358)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBIndexWriter.h 2013-11-15 22:24:14 UTC (rev 159359)
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- * 2013 Apple 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 INC. 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 INC. 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 IDBIndexWriter_h
-#define IDBIndexWriter_h
-
-#include "IDBBackingStoreInterface.h"
-#include "IDBDatabaseBackend.h"
-#include "IDBMetadata.h"
-#include <wtf/RefCounted.h>
-
-#if ENABLE(INDEXED_DATABASE)
-
-namespace WebCore {
-
-typedef Vector<RefPtr<IDBKey>> IndexKeys;
-
-class IDBIndexWriter : public RefCounted<IDBIndexWriter> {
-public:
- static PassRefPtr<IDBIndexWriter> create(const IDBIndexMetadata& indexMetadata, const IndexKeys& indexKeys)
- {
- return adoptRef(new IDBIndexWriter(indexMetadata, indexKeys));
- }
-
- bool verifyIndexKeys(IDBBackingStoreInterface&, IDBBackingStoreTransactionInterface&, int64_t databaseId, int64_t objectStoreId, int64_t indexId, bool& canAddKeys, const IDBKey* primaryKey = 0, String* errorMessage = 0) const WARN_UNUSED_RETURN;
-
- void writeIndexKeys(const IDBRecordIdentifier*, IDBBackingStoreInterface&, IDBBackingStoreTransactionInterface&, int64_t databaseId, int64_t objectStoreId) const;
-
-private:
- IDBIndexWriter(const IDBIndexMetadata&, const IndexKeys&);
-
- bool addingKeyAllowed(IDBBackingStoreInterface&, IDBBackingStoreTransactionInterface&, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey* indexKey, const IDBKey* primaryKey, bool& allowed) const WARN_UNUSED_RETURN;
-
- const IDBIndexMetadata m_indexMetadata;
- IndexKeys m_indexKeys;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
-#endif // IDBIndexWriter_h
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.cpp (159358 => 159359)
--- trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.cpp 2013-11-15 22:22:30 UTC (rev 159358)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.cpp 2013-11-15 22:24:14 UTC (rev 159359)
@@ -28,7 +28,6 @@
#include "IDBCursorBackend.h"
#include "IDBDatabaseCallbacks.h"
-#include "IDBIndexWriter.h"
#include "IDBKeyRange.h"
#include "IDBRecordIdentifier.h"
#include "IDBServerConnection.h"
Modified: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp (159358 => 159359)
--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp 2013-11-15 22:22:30 UTC (rev 159358)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.cpp 2013-11-15 22:24:14 UTC (rev 159359)
@@ -32,7 +32,7 @@
#include "HistogramSupport.h"
#include "IDBBackingStoreCursorLevelDB.h"
#include "IDBBackingStoreTransactionLevelDB.h"
-#include "IDBIndexWriter.h"
+#include "IDBIndexWriterLevelDB.h"
#include "IDBKey.h"
#include "IDBKeyPath.h"
#include "IDBKeyRange.h"
@@ -1383,7 +1383,7 @@
}
-bool IDBBackingStoreLevelDB::makeIndexWriters(int64_t transactionID, int64_t databaseID, const IDBObjectStoreMetadata& objectStore, IDBKey& primaryKey, bool keyWasGenerated, const Vector<int64_t>& indexIDs, const Vector<IndexKeys>& indexKeys, Vector<RefPtr<IDBIndexWriter>>& indexWriters, String* errorMessage, bool& completed)
+bool IDBBackingStoreLevelDB::makeIndexWriters(int64_t transactionID, int64_t databaseID, const IDBObjectStoreMetadata& objectStore, IDBKey& primaryKey, bool keyWasGenerated, const Vector<int64_t>& indexIDs, const Vector<IndexKeys>& indexKeys, Vector<RefPtr<IDBIndexWriterLevelDB>>& indexWriters, String* errorMessage, bool& completed)
{
ASSERT(indexIDs.size() == indexKeys.size());
completed = false;
@@ -1400,7 +1400,7 @@
if (keyWasGenerated && (index.keyPath == objectStore.keyPath))
keys.append(&primaryKey);
- RefPtr<IDBIndexWriter> indexWriter = IDBIndexWriter::create(index, keys);
+ RefPtr<IDBIndexWriterLevelDB> indexWriter = IDBIndexWriterLevelDB::create(index, keys);
bool canAddKeys = false;
ASSERT(m_backingStoreTransactions.contains(transactionID));
bool backingStoreSuccess = indexWriter->verifyIndexKeys(*this, *m_backingStoreTransactions.get(transactionID), databaseID, objectStore.id, index.id, canAddKeys, &primaryKey, errorMessage);
Modified: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h (159358 => 159359)
--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h 2013-11-15 22:22:30 UTC (rev 159358)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBBackingStoreLevelDB.h 2013-11-15 22:24:14 UTC (rev 159359)
@@ -101,7 +101,7 @@
virtual PassRefPtr<IDBBackingStoreCursorInterface> openIndexKeyCursor(IDBBackingStoreTransactionInterface&, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IndexedDB::CursorDirection) OVERRIDE;
virtual PassRefPtr<IDBBackingStoreCursorInterface> openIndexCursor(IDBBackingStoreTransactionInterface&, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IndexedDB::CursorDirection) OVERRIDE;
- virtual bool makeIndexWriters(int64_t transactionID, int64_t databaseId, const IDBObjectStoreMetadata&, IDBKey& primaryKey, bool keyWasGenerated, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&, Vector<RefPtr<IDBIndexWriter>>& indexWriters, String* errorMessage, bool& completed) OVERRIDE WARN_UNUSED_RETURN;
+ virtual bool makeIndexWriters(int64_t transactionID, int64_t databaseId, const IDBObjectStoreMetadata&, IDBKey& primaryKey, bool keyWasGenerated, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&, Vector<RefPtr<IDBIndexWriterLevelDB>>& indexWriters, String* errorMessage, bool& completed) OVERRIDE WARN_UNUSED_RETURN;
virtual PassRefPtr<IDBKey> generateKey(IDBTransactionBackend&, int64_t databaseId, int64_t objectStoreId) OVERRIDE;
virtual bool updateKeyGenerator(IDBTransactionBackend&, int64_t databaseId, int64_t objectStoreId, const IDBKey&, bool checkCurrent) OVERRIDE;
Copied: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBIndexWriterLevelDB.cpp (from rev 159358, trunk/Source/WebCore/Modules/indexeddb/IDBIndexWriter.cpp) (0 => 159359)
--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBIndexWriterLevelDB.cpp (rev 0)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBIndexWriterLevelDB.cpp 2013-11-15 22:24:14 UTC (rev 159359)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ * 2013 Apple 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 INC. 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 INC. 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 "IDBIndexWriterLevelDB.h"
+
+#include "IDBKey.h"
+#include <wtf/text/CString.h>
+
+#if ENABLE(INDEXED_DATABASE)
+#if USE(LEVELDB)
+
+namespace WebCore {
+
+IDBIndexWriterLevelDB::IDBIndexWriterLevelDB(const IDBIndexMetadata& metadata, const IndexKeys& keys)
+ : m_indexMetadata(metadata)
+ , m_indexKeys(keys)
+{
+}
+
+void IDBIndexWriterLevelDB::writeIndexKeys(const IDBRecordIdentifier* recordIdentifier, IDBBackingStoreInterface& backingStore, IDBBackingStoreTransactionInterface& transaction, int64_t databaseId, int64_t objectStoreId) const
+{
+ ASSERT(recordIdentifier);
+ int64_t indexId = m_indexMetadata.id;
+ for (size_t i = 0; i < m_indexKeys.size(); ++i) {
+ bool ok = backingStore.putIndexDataForRecord(transaction, databaseId, objectStoreId, indexId, *(m_indexKeys)[i].get(), recordIdentifier);
+ // This should have already been verified as a valid write during verifyIndexKeys.
+ ASSERT_UNUSED(ok, ok);
+ }
+}
+
+bool IDBIndexWriterLevelDB::verifyIndexKeys(IDBBackingStoreInterface& backingStore, IDBBackingStoreTransactionInterface& transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, bool& canAddKeys, const IDBKey* primaryKey, String* errorMessage) const
+{
+ canAddKeys = false;
+ for (size_t i = 0; i < m_indexKeys.size(); ++i) {
+ bool ok = addingKeyAllowed(backingStore, transaction, databaseId, objectStoreId, indexId, (m_indexKeys)[i].get(), primaryKey, canAddKeys);
+ if (!ok)
+ return false;
+ if (!canAddKeys) {
+ if (errorMessage)
+ *errorMessage = String::format("Unable to add key to index '%s': at least one key does not satisfy the uniqueness requirements.", m_indexMetadata.name.utf8().data());
+ return true;
+ }
+ }
+ canAddKeys = true;
+ return true;
+}
+
+bool IDBIndexWriterLevelDB::addingKeyAllowed(IDBBackingStoreInterface& backingStore, IDBBackingStoreTransactionInterface& transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey* indexKey, const IDBKey* primaryKey, bool& allowed) const
+{
+ allowed = false;
+ if (!m_indexMetadata.unique) {
+ allowed = true;
+ return true;
+ }
+
+ RefPtr<IDBKey> foundPrimaryKey;
+ bool found = false;
+ bool ok = backingStore.keyExistsInIndex(transaction, databaseId, objectStoreId, indexId, *indexKey, foundPrimaryKey, found);
+ if (!ok)
+ return false;
+ if (!found || (primaryKey && foundPrimaryKey->isEqual(primaryKey)))
+ allowed = true;
+ return true;
+}
+
+
+} // namespace WebCore
+
+#endif // USE(LEVELDB)
+#endif // ENABLE(INDEXED_DATABASE)
Copied: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBIndexWriterLevelDB.h (from rev 159358, trunk/Source/WebCore/Modules/indexeddb/IDBIndexWriter.h) (0 => 159359)
--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBIndexWriterLevelDB.h (rev 0)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBIndexWriterLevelDB.h 2013-11-15 22:24:14 UTC (rev 159359)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ * 2013 Apple 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 INC. 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 INC. 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 IDBIndexWriterLevelDB_h
+#define IDBIndexWriterLevelDB_h
+
+#include "IDBBackingStoreInterface.h"
+#include "IDBDatabaseBackend.h"
+#include "IDBMetadata.h"
+#include <wtf/RefCounted.h>
+
+#if ENABLE(INDEXED_DATABASE)
+#if USE(LEVELDB)
+
+namespace WebCore {
+
+typedef Vector<RefPtr<IDBKey>> IndexKeys;
+
+class IDBIndexWriterLevelDB : public RefCounted<IDBIndexWriterLevelDB> {
+public:
+ static PassRefPtr<IDBIndexWriterLevelDB> create(const IDBIndexMetadata& indexMetadata, const IndexKeys& indexKeys)
+ {
+ return adoptRef(new IDBIndexWriterLevelDB(indexMetadata, indexKeys));
+ }
+
+ bool verifyIndexKeys(IDBBackingStoreInterface&, IDBBackingStoreTransactionInterface&, int64_t databaseId, int64_t objectStoreId, int64_t indexId, bool& canAddKeys, const IDBKey* primaryKey = 0, String* errorMessage = 0) const WARN_UNUSED_RETURN;
+
+ void writeIndexKeys(const IDBRecordIdentifier*, IDBBackingStoreInterface&, IDBBackingStoreTransactionInterface&, int64_t databaseId, int64_t objectStoreId) const;
+
+private:
+ IDBIndexWriterLevelDB(const IDBIndexMetadata&, const IndexKeys&);
+
+ bool addingKeyAllowed(IDBBackingStoreInterface&, IDBBackingStoreTransactionInterface&, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey* indexKey, const IDBKey* primaryKey, bool& allowed) const WARN_UNUSED_RETURN;
+
+ const IDBIndexMetadata m_indexMetadata;
+ IndexKeys m_indexKeys;
+};
+
+} // namespace WebCore
+
+#endif // #if USE(LEVELDB)
+#endif // ENABLE(INDEXED_DATABASE)
+#endif // IDBIndexWriterLevelDB_h
Modified: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp (159358 => 159359)
--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp 2013-11-15 22:22:30 UTC (rev 159358)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp 2013-11-15 22:24:14 UTC (rev 159359)
@@ -32,7 +32,7 @@
#include "IDBBackingStoreLevelDB.h"
#include "IDBBackingStoreTransactionLevelDB.h"
#include "IDBCursorBackend.h"
-#include "IDBIndexWriter.h"
+#include "IDBIndexWriterLevelDB.h"
#include <wtf/MainThread.h>
#define ASYNC_COMPLETION_CALLBACK(callback, arg) \
@@ -162,7 +162,7 @@
return;
}
- Vector<RefPtr<IDBIndexWriter>> indexWriters;
+ Vector<RefPtr<IDBIndexWriterLevelDB>> indexWriters;
String errorMessage;
bool obeysConstraints = false;
@@ -181,7 +181,7 @@
}
for (size_t i = 0; i < indexWriters.size(); ++i) {
- IDBIndexWriter* indexWriter = indexWriters[i].get();
+ IDBIndexWriterLevelDB* indexWriter = indexWriters[i].get();
indexWriter->writeIndexKeys(recordIdentifier.get(), *m_backingStore, *backingStoreTransaction, databaseID, objectStoreID);
}
@@ -378,7 +378,7 @@
}
}
- Vector<RefPtr<IDBIndexWriter>> indexWriters;
+ Vector<RefPtr<IDBIndexWriterLevelDB>> indexWriters;
String errorMessage;
bool obeysConstraints = false;
bool backingStoreSuccess = m_backingStore->makeIndexWriters(transaction.id(), transaction.database().id(), operation.objectStore(), *key, keyWasGenerated, operation.indexIDs(), operation.indexKeys(), indexWriters, &errorMessage, obeysConstraints);
@@ -402,7 +402,7 @@
}
for (size_t i = 0; i < indexWriters.size(); ++i) {
- IDBIndexWriter* indexWriter = indexWriters[i].get();
+ IDBIndexWriterLevelDB* indexWriter = indexWriters[i].get();
indexWriter->writeIndexKeys(recordIdentifier.get(), *m_backingStore, *backingStoreTransaction, transaction.database().id(), operation.objectStore().id);
}
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (159358 => 159359)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-11-15 22:22:30 UTC (rev 159358)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-11-15 22:24:14 UTC (rev 159359)
@@ -1647,6 +1647,8 @@
50E18CDA16F9285800C65486 /* StyleCustomFilterProgramCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 50E18CD716F9285800C65486 /* StyleCustomFilterProgramCache.h */; };
510184690B08602A004A825F /* CachedPage.h in Headers */ = {isa = PBXBuildFile; fileRef = 510184670B08602A004A825F /* CachedPage.h */; settings = {ATTRIBUTES = (Private, ); }; };
5101846A0B08602A004A825F /* CachedPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510184680B08602A004A825F /* CachedPage.cpp */; };
+ 510194401836D20800925523 /* IDBIndexWriterLevelDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5101943E1836D20800925523 /* IDBIndexWriterLevelDB.cpp */; };
+ 510194411836D20800925523 /* IDBIndexWriterLevelDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 5101943F1836D20800925523 /* IDBIndexWriterLevelDB.h */; };
51059DDD1820B17600DFF9B1 /* IDBTransactionBackendOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51059DD91820B17600DFF9B1 /* IDBTransactionBackendOperations.cpp */; };
51059DDE1820B17600DFF9B1 /* IDBTransactionBackendOperations.h in Headers */ = {isa = PBXBuildFile; fileRef = 51059DDA1820B17600DFF9B1 /* IDBTransactionBackendOperations.h */; };
510A326F18318431003C5326 /* IDBServerConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 510A326E18318431003C5326 /* IDBServerConnection.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -1657,8 +1659,6 @@
510D4A36103165EE0049EA54 /* SocketStreamHandleBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510D4A30103165EE0049EA54 /* SocketStreamHandleBase.cpp */; };
510D4A37103165EE0049EA54 /* SocketStreamHandleBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 510D4A31103165EE0049EA54 /* SocketStreamHandleBase.h */; };
510D4A38103165EE0049EA54 /* SocketStreamHandleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 510D4A32103165EE0049EA54 /* SocketStreamHandleClient.h */; };
- 510EC42A18170C7500C897D6 /* IDBIndexWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510EC42818170C7500C897D6 /* IDBIndexWriter.cpp */; };
- 510EC42B18170C7500C897D6 /* IDBIndexWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 510EC42918170C7500C897D6 /* IDBIndexWriter.h */; };
5112935F3D54B4B52FAF973F /* InspectorHeapProfilerAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 511293613D6DB4B52FAF973F /* InspectorHeapProfilerAgent.cpp */; };
511293603D60B4B52FAF973F /* InspectorHeapProfilerAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 511293623D85B4B52FAF973F /* InspectorHeapProfilerAgent.h */; };
511EF2C017F0FD3500E4FA16 /* JSIDBAny.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 511EF2A817F0FC4800E4FA16 /* JSIDBAny.cpp */; };
@@ -8346,6 +8346,8 @@
50E18CD716F9285800C65486 /* StyleCustomFilterProgramCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleCustomFilterProgramCache.h; path = style/StyleCustomFilterProgramCache.h; sourceTree = "<group>"; };
510184670B08602A004A825F /* CachedPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedPage.h; sourceTree = "<group>"; };
510184680B08602A004A825F /* CachedPage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedPage.cpp; sourceTree = "<group>"; };
+ 5101943E1836D20800925523 /* IDBIndexWriterLevelDB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBIndexWriterLevelDB.cpp; sourceTree = "<group>"; };
+ 5101943F1836D20800925523 /* IDBIndexWriterLevelDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBIndexWriterLevelDB.h; sourceTree = "<group>"; };
51059DD91820B17600DFF9B1 /* IDBTransactionBackendOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBTransactionBackendOperations.cpp; sourceTree = "<group>"; };
51059DDA1820B17600DFF9B1 /* IDBTransactionBackendOperations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBTransactionBackendOperations.h; sourceTree = "<group>"; };
510A326E18318431003C5326 /* IDBServerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBServerConnection.h; sourceTree = "<group>"; };
@@ -8356,8 +8358,6 @@
510D4A30103165EE0049EA54 /* SocketStreamHandleBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketStreamHandleBase.cpp; sourceTree = "<group>"; };
510D4A31103165EE0049EA54 /* SocketStreamHandleBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketStreamHandleBase.h; sourceTree = "<group>"; };
510D4A32103165EE0049EA54 /* SocketStreamHandleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketStreamHandleClient.h; sourceTree = "<group>"; };
- 510EC42818170C7500C897D6 /* IDBIndexWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBIndexWriter.cpp; sourceTree = "<group>"; };
- 510EC42918170C7500C897D6 /* IDBIndexWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBIndexWriter.h; sourceTree = "<group>"; };
511293613D6DB4B52FAF973F /* InspectorHeapProfilerAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorHeapProfilerAgent.cpp; sourceTree = "<group>"; };
511293623D85B4B52FAF973F /* InspectorHeapProfilerAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorHeapProfilerAgent.h; sourceTree = "<group>"; };
511EF2A817F0FC4800E4FA16 /* JSIDBAny.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSIDBAny.cpp; sourceTree = "<group>"; };
@@ -15159,6 +15159,8 @@
51660ABF1828C84600074CAD /* IDBBackingStoreTransactionLevelDB.h */,
51660AB21828BB8200074CAD /* IDBFactoryBackendLevelDB.cpp */,
51660AB31828BB8200074CAD /* IDBFactoryBackendLevelDB.h */,
+ 5101943E1836D20800925523 /* IDBIndexWriterLevelDB.cpp */,
+ 5101943F1836D20800925523 /* IDBIndexWriterLevelDB.h */,
51660AB41828BB8200074CAD /* IDBLevelDBCoding.cpp */,
51660AB51828BB8200074CAD /* IDBLevelDBCoding.h */,
5164ED41183208C700EA8FF1 /* IDBServerConnectionLevelDB.cpp */,
@@ -17023,8 +17025,6 @@
51D7198E181106E00016DC51 /* IDBIndex.cpp */,
51D7198F181106E00016DC51 /* IDBIndex.h */,
51D71990181106E00016DC51 /* IDBIndex.idl */,
- 510EC42818170C7500C897D6 /* IDBIndexWriter.cpp */,
- 510EC42918170C7500C897D6 /* IDBIndexWriter.h */,
51D71991181106E00016DC51 /* IDBKey.cpp */,
51D71992181106E00016DC51 /* IDBKey.h */,
51D71993181106E00016DC51 /* IDBKeyPath.cpp */,
@@ -23906,6 +23906,7 @@
935207BE09BD410A00F2038D /* LocalizedStrings.h in Headers */,
BCE1C41B0D982980003B02F2 /* Location.h in Headers */,
A8239E0109B3CF8A00B60641 /* Logging.h in Headers */,
+ 510194411836D20800925523 /* IDBIndexWriterLevelDB.h in Headers */,
9BA273F4172206BB0097CE47 /* LogicalSelectionOffsetCaches.h in Headers */,
E187056316E54A0D00585E97 /* MainThreadTask.h in Headers */,
1A8F6BC60DB55CDC001DB794 /* ManifestParser.h in Headers */,
@@ -24711,7 +24712,6 @@
B2227A180D00BF220071B782 /* SVGFontFaceFormatElement.h in Headers */,
B2227A1B0D00BF220071B782 /* SVGFontFaceNameElement.h in Headers */,
B2227A1E0D00BF220071B782 /* SVGFontFaceSrcElement.h in Headers */,
- 510EC42B18170C7500C897D6 /* IDBIndexWriter.h in Headers */,
B2227A210D00BF220071B782 /* SVGFontFaceUriElement.h in Headers */,
B2227A240D00BF220071B782 /* SVGForeignObjectElement.h in Headers */,
B2227A270D00BF220071B782 /* SVGGElement.h in Headers */,
@@ -26060,6 +26060,7 @@
A9C6E4EF0D745E38006442E9 /* DOMPluginArray.cpp in Sources */,
85F56A7B0A98CE3700ADB60A /* DOMProcessingInstruction.mm in Sources */,
BCC573360D695BBE006EF517 /* DOMProgressEvent.mm in Sources */,
+ 510194401836D20800925523 /* IDBIndexWriterLevelDB.cpp in Sources */,
8538F05C0AD722F1006A81D1 /* DOMRange.mm in Sources */,
858C38A80AA8F20400B187A4 /* DOMRect.mm in Sources */,
BCAEFCAE1016CE4A0040D34E /* DOMRGBColor.mm in Sources */,
@@ -27897,7 +27898,6 @@
B2227A050D00BF220071B782 /* SVGFETileElement.cpp in Sources */,
B2227A080D00BF220071B782 /* SVGFETurbulenceElement.cpp in Sources */,
845E72FB0FD2623900A87D79 /* SVGFilter.cpp in Sources */,
- 510EC42A18170C7500C897D6 /* IDBIndexWriter.cpp in Sources */,
081EBF3A0FD34F4100DA7559 /* SVGFilterBuilder.cpp in Sources */,
B2227A0B0D00BF220071B782 /* SVGFilterElement.cpp in Sources */,
B2227A0E0D00BF220071B782 /* SVGFilterPrimitiveStandardAttributes.cpp in Sources */,