Commit 659a1753 authored by Numfor Mbiziwo-Tiapo's avatar Numfor Mbiziwo-Tiapo Committed by Commit Bot

Update putAll to return an array of keys

This change makes putAll return an array of the inserted keys on a
successful insertion

Change-Id: I6157019646e78d31f1d2277942afffaec43774d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2352829
Commit-Queue: Olivier Yiptong <oyiptong@chromium.org>
Reviewed-by: default avatarOlivier Yiptong <oyiptong@chromium.org>
Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798107}
parent 0deade48
......@@ -1325,6 +1325,7 @@ Status IndexedDBDatabase::PutAllOperation(
DCHECK(put_param->key->IsValid());
}
std::vector<blink::IndexedDBKey> keys;
for (auto& put_param : params) {
std::vector<std::unique_ptr<IndexWriter>> index_writers;
base::string16 error_message;
......@@ -1375,15 +1376,14 @@ Status IndexedDBDatabase::PutAllOperation(
if (!s.ok())
return s;
}
keys.push_back(*put_param->key);
}
{
IDB_TRACE1("IndexedDBDatabase::PutAllOperation.Callbacks", "txn.id",
transaction->id());
std::move(callback).Run(
blink::mojom::IDBTransactionPutAllResult::NewErrorResult(
blink::mojom::IDBError::New(blink::mojom::IDBException::kNoError,
base::string16())));
blink::mojom::IDBTransactionPutAllResult::NewKeys(std::move(keys)));
}
for (auto& put_param : params) {
FilterObservation(transaction, object_store_id,
......
......@@ -137,15 +137,18 @@ void WebIDBTransactionImpl::PutAll(int64_t object_store_id,
void WebIDBTransactionImpl::PutAllCallback(
std::unique_ptr<WebIDBCallbacks> callbacks,
mojom::blink::IDBTransactionPutAllResultPtr result) {
DCHECK(result->is_error_result());
if (result->get_error_result()->error_code ==
blink::mojom::IDBException::kNoError) {
callbacks->Success();
} else {
if (result->is_error_result()) {
callbacks->Error(result->get_error_result()->error_code,
std::move(result->get_error_result()->error_message));
callbacks.reset();
return;
}
if (result->is_keys()) {
callbacks->SuccessKey(IDBKey::CreateArray(std::move(result->get_keys())));
callbacks.reset();
return;
}
callbacks.reset();
}
void WebIDBTransactionImpl::Commit(int64_t num_errors_handled) {
......
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