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

Side by Side Diff: Source/modules/indexeddb/IDBObjectStore.cpp

Issue 1164493003: IndexedDB: Implementation of IDBObjectStore.getAllKeys(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@idb-index-getallkeys-pt2
Patch Set: Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « Source/modules/indexeddb/IDBObjectStore.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 if (!backendDB()) { 148 if (!backendDB()) {
149 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 149 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
150 return 0; 150 return 0;
151 } 151 }
152 152
153 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get()); 153 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
154 backendDB()->getAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, range, maxCount, false, WebIDBCallbacksImpl::create(request).leakPtr()); 154 backendDB()->getAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, range, maxCount, false, WebIDBCallbacksImpl::create(request).leakPtr());
155 return request; 155 return request;
156 } 156 }
157 157
158 IDBRequest* IDBObjectStore::getAllKeys(ScriptState* scriptState, const ScriptVal ue& keyRange, ExceptionState& exceptionState)
159 {
160 return getAllKeys(scriptState, keyRange, std::numeric_limits<uint32_t>::max( ), exceptionState);
161 }
162
163 IDBRequest* IDBObjectStore::getAllKeys(ScriptState* scriptState, const ScriptVal ue& keyRange, unsigned long maxCount, ExceptionState& exceptionState)
164 {
165 IDB_TRACE("IDBObjectStore::getAll");
166 if (!maxCount) {
167 exceptionState.throwTypeError(IDBDatabase::notValidMaxCountErrorMessage) ;
168 return 0;
169 }
170 if (isDeleted()) {
171 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage);
172 return 0;
173 }
174 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
175 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage);
176 return 0;
177 }
178 if (!m_transaction->isActive()) {
179 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
180 return 0;
181 }
182 IDBKeyRange* range = IDBKeyRange::fromScriptValue(scriptState->executionCont ext(), keyRange, exceptionState);
183 if (exceptionState.hadException())
184 return 0;
185 if (!backendDB()) {
186 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
187 return 0;
188 }
189
190 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
191 backendDB()->getAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, range, maxCount, true, WebIDBCallbacksImpl::create(request).leakPtr());
192 return request;
193 }
194
158 static void generateIndexKeysForValue(v8::Isolate* isolate, const IDBIndexMetada ta& indexMetadata, const ScriptValue& objectValue, IDBObjectStore::IndexKeys* in dexKeys) 195 static void generateIndexKeysForValue(v8::Isolate* isolate, const IDBIndexMetada ta& indexMetadata, const ScriptValue& objectValue, IDBObjectStore::IndexKeys* in dexKeys)
159 { 196 {
160 ASSERT(indexKeys); 197 ASSERT(indexKeys);
161 NonThrowableExceptionState exceptionState; 198 NonThrowableExceptionState exceptionState;
162 IDBKey* indexKey = ScriptValue::to<IDBKey*>(isolate, objectValue, exceptionS tate, indexMetadata.keyPath); 199 IDBKey* indexKey = ScriptValue::to<IDBKey*>(isolate, objectValue, exceptionS tate, indexMetadata.keyPath);
163 200
164 if (!indexKey) 201 if (!indexKey)
165 return; 202 return;
166 203
167 if (!indexMetadata.multiEntry || indexKey->type() != IDBKey::ArrayType) { 204 if (!indexMetadata.multiEntry || indexKey->type() != IDBKey::ArrayType) {
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 } 744 }
708 return IDBIndexMetadata::InvalidId; 745 return IDBIndexMetadata::InvalidId;
709 } 746 }
710 747
711 WebIDBDatabase* IDBObjectStore::backendDB() const 748 WebIDBDatabase* IDBObjectStore::backendDB() const
712 { 749 {
713 return m_transaction->backendDB(); 750 return m_transaction->backendDB();
714 } 751 }
715 752
716 } // namespace blink 753 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBObjectStore.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698