Skip to content

Commit

Permalink
Reapply "IDB: direct reads for blobs"
Browse files Browse the repository at this point in the history
This relands commit 60632268eadd3051d4ec88d62292b160682f8a56.

Difference to original: added support for AsDataPipeGetter and
extended blob-contenttype.any.js WPT to cover this case.

Original change's description:
> IDB: direct reads for blobs
>
> For the standard case of a page reading IDB data from the blob store,
> don't go through the blob registry on the i/o thread and instead
> connect the IDB bucket thread directly to the renderer.
>
> In some other (rarer) cases the blob registry is still used. This
> is accomplished by *additionally* registering a blob with
> BlobStorageContext using the same UUID, which is necessary for:
>
> * WriteBlobToFile(), which does lookup by UUID
> * loading data for a blob:// URL, i.e. mojom::Blob::Load, which is
>   thunked through to the registry blob because implementation is non-
>   trivial
>
> Bug: 373684390
> Change-Id: I9235f23303e4e6a05bf12a8acff32a5fb4e2a565
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6113789
> Commit-Queue: Evan Stade <[email protected]>
> Reviewed-by: Steve Becker <[email protected]>
> Cr-Commit-Position: refs/heads/main@{#1400627}

Bug: 373684390
Change-Id: Ie555cf4b583b862d306c43e3e4be76e957ea6c5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6138579
Reviewed-by: Steve Becker <[email protected]>
Commit-Queue: Evan Stade <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1401872}
  • Loading branch information
Evan Stade authored and chromium-wpt-export-bot committed Jan 3, 2025
1 parent 1187770 commit 277b6ec
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions IndexedDB/blob-contenttype.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,39 @@ indexeddb_test(
tx.objectStore('store').put(blob, 'key');

tx.oncomplete = t.step_func(function() {
var tx = db.transaction('store', 'readonly', {durability: 'relaxed'});
tx.objectStore('store').get('key').onsuccess = t.step_func(function(e) {
var tx = db.transaction('store', 'readonly', {durability: 'relaxed'});
tx.objectStore('store').get('key').onsuccess =
t.step_func(function(e) {
var result = e.target.result;
assert_equals(result.type, type, 'Blob type should survive round-trip');

// Test createObjectURL i.e. a blob:// URL.
var url = URL.createObjectURL(result);
var xhr = new XMLHttpRequest(), async = true;
xhr.open('GET', url, async);
xhr.send();
xhr.onreadystatechange = t.step_func(function() {
if (xhr.readyState !== XMLHttpRequest.DONE)
return;
assert_equals(xhr.getResponseHeader('Content-Type'), type,
'Blob type should be preserved when fetched');
if (xhr.readyState !== XMLHttpRequest.DONE)
return;
assert_equals(
xhr.getResponseHeader('Content-Type'), type,
'Blob type should be preserved when fetched');

// Test POSTing blob in request.
var xhr2 = new XMLHttpRequest();
xhr2.open('POST', '../xhr/resources/content.py', true);
xhr2.send(result);

xhr2.onreadystatechange = t.step_func(function() {
if (xhr2.readyState !== XMLHttpRequest.DONE)
return;
assert_equals(xhr2.status, 200);
assert_equals(xhr2.getResponseHeader('X-Request-Content-Type'), type);
assert_equals(xhr2.response, 'mulderscully');
t.done();
});
});
});
});
});
},
'Ensure that content type round trips when reading blob data'
Expand Down

0 comments on commit 277b6ec

Please sign in to comment.