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, ...@@ -123,7 +123,9 @@ IDBRequest* IDBCursor::update(ScriptState* script_state,
IDBObjectStore* object_store = EffectiveObjectStore(); IDBObjectStore* object_store = EffectiveObjectStore();
return object_store->DoPut(script_state, mojom::IDBPutMode::CursorUpdate, return object_store->DoPut(script_state, mojom::IDBPutMode::CursorUpdate,
IDBRequest::Source::FromIDBCursor(this), value, 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) { void IDBCursor::advance(unsigned count, ExceptionState& exception_state) {
......
...@@ -102,7 +102,7 @@ class MODULES_EXPORT IDBObjectStore final : public ScriptWrappable { ...@@ -102,7 +102,7 @@ class MODULES_EXPORT IDBObjectStore final : public ScriptWrappable {
const ScriptValue& key, const ScriptValue& key,
ExceptionState&); ExceptionState&);
IDBRequest* put(ScriptState*, const ScriptValue& value, ExceptionState&); IDBRequest* put(ScriptState*, const ScriptValue& value, ExceptionState&);
HeapVector<Member<IDBRequest>> putAll(ScriptState*, IDBRequest* putAll(ScriptState*,
const HeapVector<ScriptValue>& values, const HeapVector<ScriptValue>& values,
ExceptionState&); ExceptionState&);
IDBRequest* put(ScriptState*, IDBRequest* put(ScriptState*,
...@@ -131,7 +131,9 @@ class MODULES_EXPORT IDBObjectStore final : public ScriptWrappable { ...@@ -131,7 +131,9 @@ class MODULES_EXPORT IDBObjectStore final : public ScriptWrappable {
const IDBRequest::Source&, const IDBRequest::Source&,
const ScriptValue&, const ScriptValue&,
const IDBKey*, const IDBKey*,
ExceptionState&); ExceptionState&,
std::unique_ptr<WebIDBCallbacks> optional_custom_callback,
Vector<scoped_refptr<BlobDataHandle>>* blob_handles_out);
// Used internally and by InspectorIndexedDBAgent: // Used internally and by InspectorIndexedDBAgent:
IDBRequest* openCursor( IDBRequest* openCursor(
...@@ -207,7 +209,9 @@ class MODULES_EXPORT IDBObjectStore final : public ScriptWrappable { ...@@ -207,7 +209,9 @@ class MODULES_EXPORT IDBObjectStore final : public ScriptWrappable {
mojom::IDBPutMode, mojom::IDBPutMode,
const ScriptValue&, const ScriptValue&,
const ScriptValue& key_value, 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; int64_t FindIndexId(const String& name) const;
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
MeasureAs=IndexedDBWrite, MeasureAs=IndexedDBWrite,
RaisesException, RaisesException,
RuntimeEnabled=IDBPutAll RuntimeEnabled=IDBPutAll
] sequence<IDBRequest> putAll(sequence<any> values); ] IDBRequest putAll(sequence<any> values);
[CallWith=ScriptState, MeasureAs=IndexedDBWrite, NewObject, RaisesException] [CallWith=ScriptState, MeasureAs=IndexedDBWrite, NewObject, RaisesException]
IDBRequest add(any value, optional any key); IDBRequest add(any value, optional any key);
......
...@@ -345,7 +345,7 @@ void IDBRequest::HandleResponse(int64_t value_or_old_version) { ...@@ -345,7 +345,7 @@ void IDBRequest::HandleResponse(int64_t value_or_old_version) {
} }
void IDBRequest::HandleResponse() { void IDBRequest::HandleResponse() {
DCHECK(transit_blob_handles_.IsEmpty()); transit_blob_handles_.clear();
if (!transaction_ || !transaction_->HasQueuedResults()) if (!transaction_ || !transaction_->HasQueuedResults())
return EnqueueResponse(); return EnqueueResponse();
transaction_->EnqueueResult(std::make_unique<IDBRequestQueueItem>( transaction_->EnqueueResult(std::make_unique<IDBRequestQueueItem>(
......
...@@ -3,23 +3,24 @@ ...@@ -3,23 +3,24 @@
promise_test(async testCase => { promise_test(async testCase => {
const db = await createDatabase(testCase, db => { const db = await createDatabase(testCase, db => {
const store = createBooksStore(testCase, db); const store = createBooksStore(testCase, db);
});
const txn = db.transaction(['books'], 'readwrite');
const objectStore = txn.objectStore('books');
let values = [ let values = [
{isbn: 'one', title: 'title1'}, {isbn: 'one', title: 'title1'},
{isbn: 'two', title: 'title2'}, {isbn: 'two', title: 'title2'},
{isbn: 'three', title: 'title3'} {isbn: 'three', title: 'title3'}
]; ];
const putAllRequests = store.putAll(values); let putAllRequest = objectStore.putAll(values);
putAllRequests.forEach(async request => { await promiseForRequest(testCase, putAllRequest);
await promiseForRequest(testCase, request);
});
});
const txn = db.transaction(['books'], 'readonly');
const objectStore = txn.objectStore('books');
const getRequest1 = objectStore.get('one');
const getRequest2 = objectStore.get('two');
const getRequest3 = objectStore.get('three');
await promiseForTransaction(testCase, txn); 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( assert_array_equals(
[getRequest1.result.title, [getRequest1.result.title,
getRequest2.result.title, getRequest2.result.title,
......
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