Commit 5a1ce3d4 authored by Kenichi Ishibashi's avatar Kenichi Ishibashi Committed by Chromium LUCI CQ

Allow ServiceWorkerResourceReader::ReadData() to return empty handle

Before this CL there was a mojo message validation error as a response
of ReadData() is defined as non-nullable data pipe handle but
ServiceWorkerResourceReaderImpl could return an empty handle when
creating a data pipe fails.

Allow a null handle since there isn't nothing for
ServiceWorkerResourceReaderImpl to do anything other than returning an
empty data pipe handle when creating a data pipe fails.

Bug: 1156082
Change-Id: I1761db595bcc30665d0dcdf5c417f8f6dbcc173b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2631817Reviewed-by: default avatarMakoto Shimazu <shimazu@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Kinuko Yasuda <kinuko@chromium.org>
Auto-Submit: Kenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844440}
parent c656a27f
......@@ -81,10 +81,11 @@ interface ServiceWorkerResourceReader {
(int32 status,
network.mojom.URLResponseHead? response_head,
mojo_base.mojom.BigBuffer? metadata);
// Reads the content of the resource associated with this reader.
// Reads the content of the resource associated with this reader. `pipe`
// can be empty when creating a data pipe fails.
ReadData(int64 size,
pending_remote<ServiceWorkerDataPipeStateNotifier> notifier) =>
(handle<data_pipe_consumer> pipe);
(handle<data_pipe_consumer>? pipe);
};
// An interface that writes a service worker script (resource) to storage.
......
......@@ -739,6 +739,13 @@ class ServiceWorkerCacheWriter::DataPipeReader
}
void OnReadData(mojo::ScopedDataPipeConsumerHandle data) {
// An invalid handle can be returned when creating a data pipe fails on the
// other side of the endpoint.
if (!data) {
owner_->AsyncDoLoop(net::ERR_FAILED);
return;
}
data_ = std::move(data);
watcher_.Watch(data_.get(),
MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED,
......
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