Commit 5d9a963d authored by Numfor Mbiziwo-Tiapo's avatar Numfor Mbiziwo-Tiapo Committed by Commit Bot

Reland "Updating the putAll implementation to return one request."

This is a reland of 051f1395

The perf test idb-put-all.html was failing because idb_request
HandleResponse was checking to never receive empty blob handles. Fixing
by clearing the blob handles instead of using a DCHECK.

Original change's description:
> Updating the putAll implementation to return one request.
>
> This change updates the existing putAll implementation to match
> the explainer more. It does not yet support the put-all-or-none
> behavior, but it does only return one request now.
>
> Design Doc:
> https://docs.google.com/document/d/1wawQ8Pl-Vi6GQN5-y2UVkcghipcOGg0WRAC0ZyBkezg/edit#
>
> Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1087927
>
> Change-Id: I2c5e9d2d71801eaab3c1c9e94a3968afb8d109b2
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2310110
> Commit-Queue: Numfor Mbiziwo-tiapo <nums@google.com>
> Commit-Queue: Daniel Murphy <dmurph@chromium.org>
> Reviewed-by: Daniel Murphy <dmurph@chromium.org>
> Reviewed-by: Olivier Yiptong <oyiptong@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#793656}

Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1087927
Change-Id: I26e977d2b307dde33a78fdb4869116a25c56dde7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2335633
Auto-Submit: Numfor Mbiziwo-tiapo <nums@google.com>
Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Reviewed-by: default avatarOlivier Yiptong <oyiptong@chromium.org>
Commit-Queue: Olivier Yiptong <oyiptong@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796141}
parent e367244d
......@@ -123,7 +123,9 @@ IDBRequest* IDBCursor::update(ScriptState* script_state,
IDBObjectStore* object_store = EffectiveObjectStore();
return object_store->DoPut(script_state, mojom::IDBPutMode::CursorUpdate,
IDBRequest::Source::FromIDBCursor(this), value,
IdbPrimaryKey(), exception_state);
IdbPrimaryKey(), exception_state,
/*optional_custom_callback=*/nullptr,
/*blob_handles_out=*/nullptr);
}
void IDBCursor::advance(unsigned count, ExceptionState& exception_state) {
......
......@@ -102,9 +102,9 @@ class MODULES_EXPORT IDBObjectStore final : public ScriptWrappable {
const ScriptValue& key,
ExceptionState&);
IDBRequest* put(ScriptState*, const ScriptValue& value, ExceptionState&);
HeapVector<Member<IDBRequest>> putAll(ScriptState*,
const HeapVector<ScriptValue>& values,
ExceptionState&);
IDBRequest* putAll(ScriptState*,
const HeapVector<ScriptValue>& values,
ExceptionState&);
IDBRequest* put(ScriptState*,
const ScriptValue& value,
const ScriptValue& key,
......@@ -131,7 +131,9 @@ class MODULES_EXPORT IDBObjectStore final : public ScriptWrappable {
const IDBRequest::Source&,
const ScriptValue&,
const IDBKey*,
ExceptionState&);
ExceptionState&,
std::unique_ptr<WebIDBCallbacks> optional_custom_callback,
Vector<scoped_refptr<BlobDataHandle>>* blob_handles_out);
// Used internally and by InspectorIndexedDBAgent:
IDBRequest* openCursor(
......@@ -207,7 +209,9 @@ class MODULES_EXPORT IDBObjectStore final : public ScriptWrappable {
mojom::IDBPutMode,
const ScriptValue&,
const ScriptValue& key_value,
ExceptionState&);
ExceptionState&,
std::unique_ptr<WebIDBCallbacks> optional_custom_callback,
Vector<scoped_refptr<BlobDataHandle>>* blob_handles_out);
int64_t FindIndexId(const String& name) const;
......
......@@ -42,7 +42,7 @@
MeasureAs=IndexedDBWrite,
RaisesException,
RuntimeEnabled=IDBPutAll
] sequence<IDBRequest> putAll(sequence<any> values);
] IDBRequest putAll(sequence<any> values);
[CallWith=ScriptState, MeasureAs=IndexedDBWrite, NewObject, RaisesException]
IDBRequest add(any value, optional any key);
......
......@@ -345,7 +345,7 @@ void IDBRequest::HandleResponse(int64_t value_or_old_version) {
}
void IDBRequest::HandleResponse() {
DCHECK(transit_blob_handles_.IsEmpty());
transit_blob_handles_.clear();
if (!transaction_ || !transaction_->HasQueuedResults())
return EnqueueResponse();
transaction_->EnqueueResult(std::make_unique<IDBRequestQueueItem>(
......
......@@ -3,23 +3,24 @@
promise_test(async testCase => {
const db = await createDatabase(testCase, db => {
const store = createBooksStore(testCase, db);
let values = [
{isbn: 'one', title: 'title1'},
{isbn: 'two', title: 'title2'},
{isbn: 'three', title: 'title3'}
];
const putAllRequests = store.putAll(values);
putAllRequests.forEach(async request => {
await promiseForRequest(testCase, request);
});
});
const txn = db.transaction(['books'], 'readonly');
const txn = db.transaction(['books'], 'readwrite');
const objectStore = txn.objectStore('books');
const getRequest1 = objectStore.get('one');
const getRequest2 = objectStore.get('two');
const getRequest3 = objectStore.get('three');
let values = [
{isbn: 'one', title: 'title1'},
{isbn: 'two', title: 'title2'},
{isbn: 'three', title: 'title3'}
];
let putAllRequest = objectStore.putAll(values);
await promiseForRequest(testCase, putAllRequest);
await promiseForTransaction(testCase, txn);
const txn2 = db.transaction(['books'], 'readonly');
const objectStore2 = txn2.objectStore('books');
const getRequest1 = objectStore2.get('one');
const getRequest2 = objectStore2.get('two');
const getRequest3 = objectStore2.get('three');
await promiseForTransaction(testCase, txn2);
assert_array_equals(
[getRequest1.result.title,
getRequest2.result.title,
......@@ -27,4 +28,4 @@ promise_test(async testCase => {
['title1', 'title2', 'title3'],
'All three retrieved titles should match those that were put.');
db.close();
}, 'Data can be successfully inputted into an object store using putAll.');
\ No newline at end of file
}, 'Data can be successfully inputted into an object store using putAll.');
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