Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1439)

Unified Diff: Source/modules/indexeddb/IDBIndex.cpp

Issue 128683004: Refactor IDBIndex::get/getKey (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/indexeddb/IDBIndex.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/indexeddb/IDBIndex.cpp
diff --git a/Source/modules/indexeddb/IDBIndex.cpp b/Source/modules/indexeddb/IDBIndex.cpp
index fad31a9ab8d8887d71ee64e4892fd1fc50010ac2..2ec9aa1c3099acf214ea43b0eda243e15e684b61 100644
--- a/Source/modules/indexeddb/IDBIndex.cpp
+++ b/Source/modules/indexeddb/IDBIndex.cpp
@@ -155,35 +155,17 @@ PassRefPtr<IDBRequest> IDBIndex::openKeyCursor(ExecutionContext* context, const
PassRefPtr<IDBRequest> IDBIndex::get(ExecutionContext* context, const ScriptValue& key, ExceptionState& exceptionState)
{
IDB_TRACE("IDBIndex::get");
- if (isDeleted()) {
- exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDeletedErrorMessage);
- return 0;
- }
- if (m_transaction->isFinished()) {
- exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
- return 0;
- }
- if (!m_transaction->isActive()) {
- exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage);
- return 0;
- }
-
- RefPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(context, key, exceptionState);
- if (exceptionState.hadException())
- return 0;
- if (!keyRange) {
- exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRangeErrorMessage);
- return 0;
- }
-
- RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
- backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange.release(), false, WebIDBCallbacksImpl::create(request).leakPtr());
- return request;
+ return getInternal(context, key, exceptionState, false);
}
PassRefPtr<IDBRequest> IDBIndex::getKey(ExecutionContext* context, const ScriptValue& key, ExceptionState& exceptionState)
{
IDB_TRACE("IDBIndex::getKey");
+ return getInternal(context, key, exceptionState, true);
+}
+
+PassRefPtr<IDBRequest> IDBIndex::getInternal(ExecutionContext* context, const ScriptValue& key, ExceptionState& exceptionState, bool keyOnly)
+{
if (isDeleted()) {
exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDeletedErrorMessage);
return 0;
@@ -206,7 +188,7 @@ PassRefPtr<IDBRequest> IDBIndex::getKey(ExecutionContext* context, const ScriptV
}
RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
- backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange.release(), true, WebIDBCallbacksImpl::create(request).leakPtr());
+ backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange.release(), keyOnly, WebIDBCallbacksImpl::create(request).leakPtr());
return request;
}
« no previous file with comments | « Source/modules/indexeddb/IDBIndex.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698