Commit 75696ff6 authored by cmumford's avatar cmumford Committed by Commit bot

IndexedDB: Added IDBIndex.getAll() implementation.

This is the experimental IDBIndex.getAll implementation for
retrieving multiple values in a single request as proposed in
https://www.w3.org/2008/webapps/wiki/IndexedDatabaseFeatures

Mozilla's documentation for IDBIndex.getAll is at:
https://developer.mozilla.org/en-US/docs/Web/API/IDBIndex/getAll

In order to use run Chrome with: --enable-experimental-web-platform-features

BUG=457450

Review URL: https://codereview.chromium.org/1147433002

Cr-Commit-Position: refs/heads/master@{#330631}
parent 90b93417
...@@ -535,6 +535,7 @@ void IndexedDBDatabase::Abort(int64 transaction_id, ...@@ -535,6 +535,7 @@ void IndexedDBDatabase::Abort(int64 transaction_id,
void IndexedDBDatabase::GetAll(int64 transaction_id, void IndexedDBDatabase::GetAll(int64 transaction_id,
int64 object_store_id, int64 object_store_id,
int64 index_id,
scoped_ptr<IndexedDBKeyRange> key_range, scoped_ptr<IndexedDBKeyRange> key_range,
int64 max_count, int64 max_count,
scoped_refptr<IndexedDBCallbacks> callbacks) { scoped_refptr<IndexedDBCallbacks> callbacks) {
...@@ -548,7 +549,7 @@ void IndexedDBDatabase::GetAll(int64 transaction_id, ...@@ -548,7 +549,7 @@ void IndexedDBDatabase::GetAll(int64 transaction_id,
transaction->ScheduleTask( transaction->ScheduleTask(
base::Bind(&IndexedDBDatabase::GetAllOperation, this, object_store_id, base::Bind(&IndexedDBDatabase::GetAllOperation, this, object_store_id,
Passed(&key_range), max_count, callbacks)); index_id, Passed(&key_range), max_count, callbacks));
} }
void IndexedDBDatabase::Get(int64 transaction_id, void IndexedDBDatabase::Get(int64 transaction_id,
...@@ -739,6 +740,7 @@ void IndexedDBDatabase::GetOperation( ...@@ -739,6 +740,7 @@ void IndexedDBDatabase::GetOperation(
void IndexedDBDatabase::GetAllOperation( void IndexedDBDatabase::GetAllOperation(
int64 object_store_id, int64 object_store_id,
int64 index_id,
scoped_ptr<IndexedDBKeyRange> key_range, scoped_ptr<IndexedDBKeyRange> key_range,
int64 max_count, int64 max_count,
scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBCallbacks> callbacks,
...@@ -754,10 +756,19 @@ void IndexedDBDatabase::GetAllOperation( ...@@ -754,10 +756,19 @@ void IndexedDBDatabase::GetAllOperation(
leveldb::Status s; leveldb::Status s;
scoped_ptr<IndexedDBBackingStore::Cursor> cursor = scoped_ptr<IndexedDBBackingStore::Cursor> cursor;
backing_store_->OpenObjectStoreCursor(
transaction->BackingStoreTransaction(), id(), object_store_id, if (index_id == IndexedDBIndexMetadata::kInvalidId) {
*key_range, blink::WebIDBCursorDirectionNext, &s); // ObjectStore
cursor = backing_store_->OpenObjectStoreCursor(
transaction->BackingStoreTransaction(), id(), object_store_id,
*key_range, blink::WebIDBCursorDirectionNext, &s);
} else {
// Index
cursor = backing_store_->OpenIndexCursor(
transaction->BackingStoreTransaction(), id(), object_store_id, index_id,
*key_range, blink::WebIDBCursorDirectionNext, &s);
}
if (!s.ok()) { if (!s.ok()) {
DLOG(ERROR) << "Unable to open cursor operation: " << s.ToString(); DLOG(ERROR) << "Unable to open cursor operation: " << s.ToString();
......
...@@ -124,6 +124,7 @@ class CONTENT_EXPORT IndexedDBDatabase ...@@ -124,6 +124,7 @@ class CONTENT_EXPORT IndexedDBDatabase
scoped_refptr<IndexedDBCallbacks> callbacks); scoped_refptr<IndexedDBCallbacks> callbacks);
void GetAll(int64 transaction_id, void GetAll(int64 transaction_id,
int64 object_store_id, int64 object_store_id,
int64 index_id,
scoped_ptr<IndexedDBKeyRange> key_range, scoped_ptr<IndexedDBKeyRange> key_range,
int64 max_count, int64 max_count,
scoped_refptr<IndexedDBCallbacks> callbacks); scoped_refptr<IndexedDBCallbacks> callbacks);
...@@ -206,6 +207,7 @@ class CONTENT_EXPORT IndexedDBDatabase ...@@ -206,6 +207,7 @@ class CONTENT_EXPORT IndexedDBDatabase
scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBCallbacks> callbacks,
IndexedDBTransaction* transaction); IndexedDBTransaction* transaction);
void GetAllOperation(int64 object_store_id, void GetAllOperation(int64 object_store_id,
int64 index_id,
scoped_ptr<IndexedDBKeyRange> key_range, scoped_ptr<IndexedDBKeyRange> key_range,
int64 max_count, int64 max_count,
scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBCallbacks> callbacks,
......
...@@ -660,7 +660,7 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGetAll( ...@@ -660,7 +660,7 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGetAll(
parent_, params.ipc_thread_id, params.ipc_callbacks_id)); parent_, params.ipc_thread_id, params.ipc_callbacks_id));
connection->database()->GetAll( connection->database()->GetAll(
parent_->HostTransactionId(params.transaction_id), params.object_store_id, parent_->HostTransactionId(params.transaction_id), params.object_store_id,
make_scoped_ptr(new IndexedDBKeyRange(params.key_range)), params.index_id, make_scoped_ptr(new IndexedDBKeyRange(params.key_range)),
params.max_count, callbacks); params.max_count, callbacks);
} }
......
...@@ -329,6 +329,7 @@ void IndexedDBDispatcher::RequestIDBDatabaseGetAll( ...@@ -329,6 +329,7 @@ void IndexedDBDispatcher::RequestIDBDatabaseGetAll(
int32 ipc_database_id, int32 ipc_database_id,
int64 transaction_id, int64 transaction_id,
int64 object_store_id, int64 object_store_id,
int64 index_id,
const IndexedDBKeyRange& key_range, const IndexedDBKeyRange& key_range,
int64 max_count, int64 max_count,
WebIDBCallbacks* callbacks) { WebIDBCallbacks* callbacks) {
...@@ -338,6 +339,7 @@ void IndexedDBDispatcher::RequestIDBDatabaseGetAll( ...@@ -338,6 +339,7 @@ void IndexedDBDispatcher::RequestIDBDatabaseGetAll(
params.ipc_database_id = ipc_database_id; params.ipc_database_id = ipc_database_id;
params.transaction_id = transaction_id; params.transaction_id = transaction_id;
params.object_store_id = object_store_id; params.object_store_id = object_store_id;
params.index_id = index_id;
params.key_range = key_range; params.key_range = key_range;
params.max_count = max_count; params.max_count = max_count;
Send(new IndexedDBHostMsg_DatabaseGetAll(params)); Send(new IndexedDBHostMsg_DatabaseGetAll(params));
......
...@@ -132,6 +132,7 @@ class CONTENT_EXPORT IndexedDBDispatcher : public WorkerTaskRunner::Observer { ...@@ -132,6 +132,7 @@ class CONTENT_EXPORT IndexedDBDispatcher : public WorkerTaskRunner::Observer {
void RequestIDBDatabaseGetAll(int32 ipc_database_id, void RequestIDBDatabaseGetAll(int32 ipc_database_id,
int64 transaction_id, int64 transaction_id,
int64 object_store_id, int64 object_store_id,
int64 index_id,
const IndexedDBKeyRange& key_range, const IndexedDBKeyRange& key_range,
int64 max_count, int64 max_count,
blink::WebIDBCallbacks* callbacks); blink::WebIDBCallbacks* callbacks);
......
...@@ -122,15 +122,13 @@ void WebIDBDatabaseImpl::getAll(long long transaction_id, ...@@ -122,15 +122,13 @@ void WebIDBDatabaseImpl::getAll(long long transaction_id,
long long max_count, long long max_count,
bool key_only, bool key_only,
WebIDBCallbacks* callbacks) { WebIDBCallbacks* callbacks) {
// TODO(cmumford): Remove DCHECK's for index_id/key_only once IDBIndex.getAll // TODO(cmumford): Remove DCHECK for key_only once IDBIndex.getAllKeys is
// is implemented. // implemented.
static const int64 kInvalidId = -1;
DCHECK_EQ(kInvalidId, index_id);
DCHECK(!key_only); DCHECK(!key_only);
IndexedDBDispatcher* dispatcher = IndexedDBDispatcher* dispatcher =
IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get());
dispatcher->RequestIDBDatabaseGetAll( dispatcher->RequestIDBDatabaseGetAll(
ipc_database_id_, transaction_id, object_store_id, ipc_database_id_, transaction_id, object_store_id, index_id,
IndexedDBKeyRangeBuilder::Build(key_range), max_count, callbacks); IndexedDBKeyRangeBuilder::Build(key_range), max_count, callbacks);
} }
......
...@@ -136,6 +136,8 @@ IPC_STRUCT_BEGIN(IndexedDBHostMsg_DatabaseGetAll_Params) ...@@ -136,6 +136,8 @@ IPC_STRUCT_BEGIN(IndexedDBHostMsg_DatabaseGetAll_Params)
IPC_STRUCT_MEMBER(int64, transaction_id) IPC_STRUCT_MEMBER(int64, transaction_id)
// The object store's id. // The object store's id.
IPC_STRUCT_MEMBER(int64, object_store_id) IPC_STRUCT_MEMBER(int64, object_store_id)
// The index id.
IPC_STRUCT_MEMBER(int64, index_id)
// The serialized key range. // The serialized key range.
IPC_STRUCT_MEMBER(content::IndexedDBKeyRange, key_range) IPC_STRUCT_MEMBER(content::IndexedDBKeyRange, key_range)
// The max number of values to retrieve. // The max number of values to retrieve.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment