summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/storage
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/storage')
-rw-r--r--Source/WebCore/storage/DatabaseTask.h6
-rw-r--r--Source/WebCore/storage/DatabaseTracker.h3
-rw-r--r--Source/WebCore/storage/IDBDatabase.cpp6
-rw-r--r--Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp51
-rw-r--r--Source/WebCore/storage/IDBObjectStoreBackendImpl.h2
-rw-r--r--Source/WebCore/storage/IDBPendingTransactionMonitor.h3
-rw-r--r--Source/WebCore/storage/LocalStorageTask.h3
-rw-r--r--Source/WebCore/storage/LocalStorageThread.h3
-rw-r--r--Source/WebCore/storage/OriginQuotaManager.h3
-rw-r--r--Source/WebCore/storage/OriginUsageRecord.h3
-rw-r--r--Source/WebCore/storage/SQLTransactionClient.h5
-rw-r--r--Source/WebCore/storage/SQLTransactionCoordinator.h4
-rw-r--r--Source/WebCore/storage/chromium/IDBFactoryBackendInterface.cpp6
-rw-r--r--Source/WebCore/storage/chromium/IDBKeyPathBackendImpl.cpp4
14 files changed, 74 insertions, 28 deletions
diff --git a/Source/WebCore/storage/DatabaseTask.h b/Source/WebCore/storage/DatabaseTask.h
index b61e465..e1df591 100644
--- a/Source/WebCore/storage/DatabaseTask.h
+++ b/Source/WebCore/storage/DatabaseTask.h
@@ -43,7 +43,8 @@ namespace WebCore {
// Can be used to wait until DatabaseTask is completed.
// Has to be passed into DatabaseTask::create to be associated with the task.
-class DatabaseTaskSynchronizer : public Noncopyable {
+class DatabaseTaskSynchronizer {
+ WTF_MAKE_NONCOPYABLE(DatabaseTaskSynchronizer);
public:
DatabaseTaskSynchronizer();
@@ -67,7 +68,8 @@ private:
#endif
};
-class DatabaseTask : public Noncopyable {
+class DatabaseTask {
+ WTF_MAKE_NONCOPYABLE(DatabaseTask); WTF_MAKE_FAST_ALLOCATED;
public:
virtual ~DatabaseTask();
diff --git a/Source/WebCore/storage/DatabaseTracker.h b/Source/WebCore/storage/DatabaseTracker.h
index 7145e6b..a1a5bdf 100644
--- a/Source/WebCore/storage/DatabaseTracker.h
+++ b/Source/WebCore/storage/DatabaseTracker.h
@@ -56,7 +56,8 @@ class DatabaseTrackerClient;
struct SecurityOriginTraits;
#endif // !PLATFORM(CHROMIUM)
-class DatabaseTracker : public Noncopyable {
+class DatabaseTracker {
+ WTF_MAKE_NONCOPYABLE(DatabaseTracker); WTF_MAKE_FAST_ALLOCATED;
public:
static void initializeTracker(const String& databasePath);
static DatabaseTracker& tracker();
diff --git a/Source/WebCore/storage/IDBDatabase.cpp b/Source/WebCore/storage/IDBDatabase.cpp
index 7a9141a..33f004b 100644
--- a/Source/WebCore/storage/IDBDatabase.cpp
+++ b/Source/WebCore/storage/IDBDatabase.cpp
@@ -73,12 +73,6 @@ PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co
options.getKeyBool("autoIncrement", autoIncrement);
// FIXME: Look up evictable and pass that on as well.
- if (autoIncrement) {
- // FIXME: Implement support for auto increment.
- ec = IDBDatabaseException::UNKNOWN_ERR;
- return 0;
- }
-
RefPtr<IDBObjectStoreBackendInterface> objectStore = m_backend->createObjectStore(name, keyPath, autoIncrement, m_setVersionTransaction.get(), ec);
if (!objectStore) {
ASSERT(ec);
diff --git a/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp b/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp
index 396f544..6b162ef 100644
--- a/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp
+++ b/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp
@@ -59,6 +59,7 @@ IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBSQLiteDatabase* database
, m_name(name)
, m_keyPath(keyPath)
, m_autoIncrement(autoIncrement)
+ , m_autoIncrementNumber(-1)
{
loadIndexes();
}
@@ -69,6 +70,7 @@ IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBSQLiteDatabase* database
, m_name(name)
, m_keyPath(keyPath)
, m_autoIncrement(autoIncrement)
+ , m_autoIncrementNumber(-1)
{
}
@@ -108,12 +110,12 @@ void IDBObjectStoreBackendImpl::getInternal(ScriptExecutionContext*, PassRefPtr<
bindWhereClause(query, objectStore->id(), key.get());
if (query.step() != SQLResultRow) {
- callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_FOUND_ERR, "Key does not exist in the object store."));
+ callbacks->onSuccess(SerializedScriptValue::undefinedValue());
return;
}
ASSERT((key->type() == IDBKey::StringType) != query.isColumnNull(0));
- // FIXME: Implement date.
+ ASSERT((key->type() == IDBKey::DateType) != query.isColumnNull(1));
ASSERT((key->type() == IDBKey::NumberType) != query.isColumnNull(2));
callbacks->onSuccess(SerializedScriptValue::createFromWire(query.getColumnText(3)));
@@ -200,22 +202,36 @@ void IDBObjectStoreBackendImpl::putInternal(ScriptExecutionContext*, PassRefPtr<
RefPtr<SerializedScriptValue> value = prpValue;
RefPtr<IDBKey> key = prpKey;
- // FIXME: Support auto-increment.
+ if (!objectStore->m_keyPath.isNull() && key) {
+ callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "A key was supplied for an objectStore that has a keyPath."));
+ return;
+ }
+
+ if (objectStore->autoIncrement() && key) {
+ callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "A key was supplied for an objectStore that is using auto increment."));
+ return;
+ }
+
+ if (objectStore->autoIncrement()) {
+ key = objectStore->genAutoIncrementKey();
- if (!objectStore->m_keyPath.isNull()) {
- if (key) {
- callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "A key was supplied for an objectStore that has a keyPath."));
+ if (!objectStore->m_keyPath.isNull()) {
+ // FIXME: Inject the generated key into the object.
+ callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Adding data to object stores with auto increment and in-line keys not yet supported."));
return;
}
+ } else if (!objectStore->m_keyPath.isNull()) {
key = fetchKeyFromKeyPath(value.get(), objectStore->m_keyPath);
+
if (!key) {
- callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "The key could not be fetched from the keyPath."));
+ callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "The key could not be fetched from the keyPath."));
return;
}
} else if (!key) {
callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "No key supplied."));
return;
}
+
if (key->type() == IDBKey::NullType) {
callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "NULL key is not allowed."));
return;
@@ -511,6 +527,27 @@ void IDBObjectStoreBackendImpl::addIndexToMap(ScriptExecutionContext*, PassRefPt
objectStore->m_indexes.set(indexPtr->name(), indexPtr);
}
+PassRefPtr<IDBKey> IDBObjectStoreBackendImpl::genAutoIncrementKey()
+{
+ if (m_autoIncrementNumber > 0)
+ return IDBKey::createNumber(m_autoIncrementNumber++);
+
+ String sql = "SELECT max(keyNumber) + 1 FROM ObjectStoreData WHERE objectStoreId = ? AND keyString IS NULL AND keyDate IS NULL";
+
+ SQLiteStatement query(sqliteDatabase(), sql);
+ bool ok = query.prepare() == SQLResultOk;
+ ASSERT_UNUSED(ok, ok);
+
+ query.bindInt64(1, id());
+
+ if (query.step() != SQLResultRow || query.isColumnNull(0))
+ m_autoIncrementNumber = 1;
+ else
+ m_autoIncrementNumber = static_cast<int>(query.getColumnDouble(0));
+
+ return IDBKey::createNumber(m_autoIncrementNumber++);
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/storage/IDBObjectStoreBackendImpl.h b/Source/WebCore/storage/IDBObjectStoreBackendImpl.h
index 2ab42f2..9fb1b7c 100644
--- a/Source/WebCore/storage/IDBObjectStoreBackendImpl.h
+++ b/Source/WebCore/storage/IDBObjectStoreBackendImpl.h
@@ -82,6 +82,7 @@ private:
void loadIndexes();
SQLiteDatabase& sqliteDatabase() const;
+ PassRefPtr<IDBKey> genAutoIncrementKey();
static void getInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks>);
static void putInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl>, PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key, bool addOnly, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBTransactionBackendInterface>);
@@ -103,6 +104,7 @@ private:
typedef HashMap<String, RefPtr<IDBIndexBackendImpl> > IndexMap;
IndexMap m_indexes;
+ int m_autoIncrementNumber;
};
} // namespace WebCore
diff --git a/Source/WebCore/storage/IDBPendingTransactionMonitor.h b/Source/WebCore/storage/IDBPendingTransactionMonitor.h
index 783a731..5bc6acd 100644
--- a/Source/WebCore/storage/IDBPendingTransactionMonitor.h
+++ b/Source/WebCore/storage/IDBPendingTransactionMonitor.h
@@ -44,7 +44,8 @@ class IDBTransactionBackendInterface;
// FIXME: move the vector of transactions to TLS. Keeping it static
// will not work once we add support for workers. Another possible
// solution is to keep the vector in the ScriptExecutionContext.
-class IDBPendingTransactionMonitor : public Noncopyable {
+class IDBPendingTransactionMonitor {
+ WTF_MAKE_NONCOPYABLE(IDBPendingTransactionMonitor);
public:
static void addPendingTransaction(IDBTransactionBackendInterface*);
static void removePendingTransaction(IDBTransactionBackendInterface*);
diff --git a/Source/WebCore/storage/LocalStorageTask.h b/Source/WebCore/storage/LocalStorageTask.h
index a2e35ea..27a8eb5 100644
--- a/Source/WebCore/storage/LocalStorageTask.h
+++ b/Source/WebCore/storage/LocalStorageTask.h
@@ -37,7 +37,8 @@ namespace WebCore {
class LocalStorageThread;
// FIXME: Rename this class to StorageTask
- class LocalStorageTask : public Noncopyable {
+ class LocalStorageTask {
+ WTF_MAKE_NONCOPYABLE(LocalStorageTask); WTF_MAKE_FAST_ALLOCATED;
public:
enum Type { AreaImport, AreaSync, DeleteEmptyDatabase, TerminateThread };
diff --git a/Source/WebCore/storage/LocalStorageThread.h b/Source/WebCore/storage/LocalStorageThread.h
index 6f05911..a2c78c6 100644
--- a/Source/WebCore/storage/LocalStorageThread.h
+++ b/Source/WebCore/storage/LocalStorageThread.h
@@ -40,7 +40,8 @@ namespace WebCore {
class LocalStorageTask;
// FIXME: Rename this class to StorageThread
- class LocalStorageThread : public Noncopyable {
+ class LocalStorageThread {
+ WTF_MAKE_NONCOPYABLE(LocalStorageThread); WTF_MAKE_FAST_ALLOCATED;
public:
static PassOwnPtr<LocalStorageThread> create();
~LocalStorageThread();
diff --git a/Source/WebCore/storage/OriginQuotaManager.h b/Source/WebCore/storage/OriginQuotaManager.h
index ec9620c..82d7c74 100644
--- a/Source/WebCore/storage/OriginQuotaManager.h
+++ b/Source/WebCore/storage/OriginQuotaManager.h
@@ -41,7 +41,8 @@ namespace WebCore {
class AbstractDatabase;
class OriginUsageRecord;
-class OriginQuotaManager : public Noncopyable {
+class OriginQuotaManager {
+ WTF_MAKE_NONCOPYABLE(OriginQuotaManager); WTF_MAKE_FAST_ALLOCATED;
public:
OriginQuotaManager();
diff --git a/Source/WebCore/storage/OriginUsageRecord.h b/Source/WebCore/storage/OriginUsageRecord.h
index a830e68..7557eaa 100644
--- a/Source/WebCore/storage/OriginUsageRecord.h
+++ b/Source/WebCore/storage/OriginUsageRecord.h
@@ -39,7 +39,8 @@ namespace WebCore {
// Objects of this class can be used from multiple threads with external synchronization.
// String arguments are also supposed to be deeply copied by the caller when necessary.
-class OriginUsageRecord : public Noncopyable {
+class OriginUsageRecord {
+ WTF_MAKE_NONCOPYABLE(OriginUsageRecord); WTF_MAKE_FAST_ALLOCATED;
public:
OriginUsageRecord();
diff --git a/Source/WebCore/storage/SQLTransactionClient.h b/Source/WebCore/storage/SQLTransactionClient.h
index fed0657..3c5ec2d 100644
--- a/Source/WebCore/storage/SQLTransactionClient.h
+++ b/Source/WebCore/storage/SQLTransactionClient.h
@@ -33,6 +33,7 @@
#if ENABLE(DATABASE)
+#include <wtf/FastAllocBase.h>
#include <wtf/Noncopyable.h>
namespace WebCore {
@@ -41,8 +42,10 @@ class AbstractDatabase;
// A client to the SQLTransaction class. Allows SQLTransaction to notify interested
// parties that certain things have happened in a transaction.
-class SQLTransactionClient : public Noncopyable {
+class SQLTransactionClient {
+ WTF_MAKE_NONCOPYABLE(SQLTransactionClient); WTF_MAKE_FAST_ALLOCATED;
public:
+ SQLTransactionClient() { }
void didCommitWriteTransaction(AbstractDatabase*);
void didExecuteStatement(AbstractDatabase*);
bool didExceedQuota(AbstractDatabase*);
diff --git a/Source/WebCore/storage/SQLTransactionCoordinator.h b/Source/WebCore/storage/SQLTransactionCoordinator.h
index 94360c0..fd76782 100644
--- a/Source/WebCore/storage/SQLTransactionCoordinator.h
+++ b/Source/WebCore/storage/SQLTransactionCoordinator.h
@@ -43,8 +43,10 @@ namespace WebCore {
class SQLTransaction;
- class SQLTransactionCoordinator : public Noncopyable {
+ class SQLTransactionCoordinator {
+ WTF_MAKE_NONCOPYABLE(SQLTransactionCoordinator); WTF_MAKE_FAST_ALLOCATED;
public:
+ SQLTransactionCoordinator() { }
void acquireLock(SQLTransaction*);
void releaseLock(SQLTransaction*);
void shutdown();
diff --git a/Source/WebCore/storage/chromium/IDBFactoryBackendInterface.cpp b/Source/WebCore/storage/chromium/IDBFactoryBackendInterface.cpp
index c0fb444..92e9a7b 100644
--- a/Source/WebCore/storage/chromium/IDBFactoryBackendInterface.cpp
+++ b/Source/WebCore/storage/chromium/IDBFactoryBackendInterface.cpp
@@ -28,7 +28,7 @@
#include "config.h"
#include "IDBFactoryBackendInterface.h"
-#include "ChromiumBridge.h"
+#include "PlatformBridge.h"
#if ENABLE(INDEXED_DATABASE)
@@ -36,12 +36,12 @@ namespace WebCore {
PassRefPtr<IDBFactoryBackendInterface> IDBFactoryBackendInterface::create()
{
- return ChromiumBridge::idbFactory();
+ return PlatformBridge::idbFactory();
}
IDBFactoryBackendInterface::~IDBFactoryBackendInterface()
{
- ChromiumBridge::idbShutdown();
+ PlatformBridge::idbShutdown();
}
} // namespace WebCore
diff --git a/Source/WebCore/storage/chromium/IDBKeyPathBackendImpl.cpp b/Source/WebCore/storage/chromium/IDBKeyPathBackendImpl.cpp
index 0f10875..38b2983 100644
--- a/Source/WebCore/storage/chromium/IDBKeyPathBackendImpl.cpp
+++ b/Source/WebCore/storage/chromium/IDBKeyPathBackendImpl.cpp
@@ -28,13 +28,13 @@
#if ENABLE(INDEXED_DATABASE)
-#include "ChromiumBridge.h"
+#include "PlatformBridge.h"
namespace WebCore {
void IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue>, 0>& values, const String& keyPath, Vector<RefPtr<IDBKey>, 0>& keys)
{
- ChromiumBridge::createIDBKeysFromSerializedValuesAndKeyPath(values, keyPath, keys);
+ PlatformBridge::createIDBKeysFromSerializedValuesAndKeyPath(values, keyPath, keys);
}
} // namespace WebCore