summaryrefslogtreecommitdiffstats
path: root/WebCore/storage/IDBObjectStore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/storage/IDBObjectStore.cpp')
-rw-r--r--WebCore/storage/IDBObjectStore.cpp64
1 files changed, 38 insertions, 26 deletions
diff --git a/WebCore/storage/IDBObjectStore.cpp b/WebCore/storage/IDBObjectStore.cpp
index 4c5cf34..c30243e 100644
--- a/WebCore/storage/IDBObjectStore.cpp
+++ b/WebCore/storage/IDBObjectStore.cpp
@@ -43,6 +43,8 @@ IDBObjectStore::IDBObjectStore(PassRefPtr<IDBObjectStoreBackendInterface> idbObj
: m_objectStore(idbObjectStore)
, m_transaction(transaction)
{
+ ASSERT(m_objectStore);
+ ASSERT(m_transaction);
// We pass a reference to this object before it can be adopted.
relaxAdoptionRequirement();
}
@@ -62,61 +64,71 @@ PassRefPtr<DOMStringList> IDBObjectStore::indexNames() const
return m_objectStore->indexNames();
}
-PassRefPtr<IDBRequest> IDBObjectStore::get(ScriptExecutionContext* context, PassRefPtr<IDBKey> key)
+PassRefPtr<IDBRequest> IDBObjectStore::get(ScriptExecutionContext* context, PassRefPtr<IDBKey> key, ExceptionCode& ec)
{
RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
- m_objectStore->get(key, request, m_transaction.get());
+ m_objectStore->get(key, request, m_transaction.get(), ec);
+ if (ec)
+ return 0;
return request.release();
}
-PassRefPtr<IDBRequest> IDBObjectStore::add(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key)
+PassRefPtr<IDBRequest> IDBObjectStore::add(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key, ExceptionCode& ec)
{
- RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this));
- m_objectStore->put(value, key, true, request);
+ RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
+ m_objectStore->put(value, key, true, request, m_transaction.get(), ec);
+ if (ec)
+ return 0;
return request;
}
-PassRefPtr<IDBRequest> IDBObjectStore::put(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key)
+PassRefPtr<IDBRequest> IDBObjectStore::put(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key, ExceptionCode& ec)
{
- RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this));
- m_objectStore->put(value, key, false, request);
+ RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
+ m_objectStore->put(value, key, false, request, m_transaction.get(), ec);
+ if (ec)
+ return 0;
return request;
}
-PassRefPtr<IDBRequest> IDBObjectStore::remove(ScriptExecutionContext* context, PassRefPtr<IDBKey> key)
+PassRefPtr<IDBRequest> IDBObjectStore::remove(ScriptExecutionContext* context, PassRefPtr<IDBKey> key, ExceptionCode& ec)
{
- RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this));
- m_objectStore->remove(key, request);
+ RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
+ m_objectStore->remove(key, request, m_transaction.get(), ec);
+ if (ec)
+ return 0;
return request;
}
-PassRefPtr<IDBRequest> IDBObjectStore::createIndex(ScriptExecutionContext* context, const String& name, const String& keyPath, bool unique)
+PassRefPtr<IDBIndex> IDBObjectStore::createIndex(const String& name, const String& keyPath, bool unique, ExceptionCode& ec)
{
- RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this));
- m_objectStore->createIndex(name, keyPath, unique, request);
- return request;
+ RefPtr<IDBIndexBackendInterface> index = m_objectStore->createIndex(name, keyPath, unique, m_transaction.get(), ec);
+ ASSERT(!index != !ec); // If we didn't get an index, we should have gotten an exception code. And vice versa.
+ if (!index)
+ return 0;
+ return IDBIndex::create(index.release(), m_transaction.get());
}
-PassRefPtr<IDBIndex> IDBObjectStore::index(const String& name)
+PassRefPtr<IDBIndex> IDBObjectStore::index(const String& name, ExceptionCode& ec)
{
- // FIXME: If this is null, we should raise a NOT_FOUND_ERR.
- RefPtr<IDBIndexBackendInterface> index = m_objectStore->index(name);
+ RefPtr<IDBIndexBackendInterface> index = m_objectStore->index(name, ec);
+ ASSERT(!index != !ec); // If we didn't get an index, we should have gotten an exception code. And vice versa.
if (!index)
return 0;
- return IDBIndex::create(index.release());
+ return IDBIndex::create(index.release(), m_transaction.get());
}
-PassRefPtr<IDBRequest> IDBObjectStore::removeIndex(ScriptExecutionContext* context, const String& name)
+void IDBObjectStore::removeIndex(const String& name, ExceptionCode& ec)
{
- RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this));
- m_objectStore->removeIndex(name, request);
- return request;
+ m_objectStore->removeIndex(name, m_transaction.get(), ec);
}
-PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> range, unsigned short direction)
+PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> range, unsigned short direction, ExceptionCode& ec)
{
- RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this));
- m_objectStore->openCursor(range, direction, request);
+ RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
+ m_objectStore->openCursor(range, direction, request, m_transaction.get(), ec);
+ if (ec)
+ return 0;
return request.release();
}