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

Unified Diff: third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp

Issue 1407883002: Add new experimental IDBObjectStore.getKey(query) API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 4 years, 4 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
Index: third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp
index 2f035a201a6dd6e53b3f691d8f07dbd57a52a8e3..ec21129359299443b6d05625de0b5fe9d3132d97 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp
@@ -114,7 +114,39 @@ IDBRequest* IDBObjectStore::get(ScriptState* scriptState, const ScriptValue& key
}
IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
- backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, keyRange, false, WebIDBCallbacksImpl::create(request).release());
+ backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, keyRange, false /* keyOnly */, WebIDBCallbacksImpl::create(request).release());
+ return request;
+}
+
+IDBRequest* IDBObjectStore::getKey(ScriptState* scriptState, const ScriptValue& key, ExceptionState& exceptionState)
+{
+ IDB_TRACE("IDBObjectStore::getKey");
+ if (isDeleted()) {
+ exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectStoreDeletedErrorMessage);
+ return nullptr;
+ }
+ if (m_transaction->isFinished() || m_transaction->isFinishing()) {
+ exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
+ return nullptr;
+ }
+ if (!m_transaction->isActive()) {
+ exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage);
+ return nullptr;
+ }
+ IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecutionContext(), key, exceptionState);
+ if (exceptionState.hadException())
+ return nullptr;
+ if (!keyRange) {
+ exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRangeErrorMessage);
+ return nullptr;
+ }
+ if (!backendDB()) {
+ exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databaseClosedErrorMessage);
+ return nullptr;
+ }
+
+ IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
+ backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, keyRange, true /* keyOnly */, WebIDBCallbacksImpl::create(request).release());
return request;
}

Powered by Google App Engine
This is Rietveld 408576698