Skip to content

Commit 964eb46

Browse files
AboutURLLoader: check for data pipe creation.
The class mojo::DataPipe shouldn't be used. In its constructor, it CHECKs the data pipe is created. It can fails when system resources are insufficient. This CL replaces the mojo::DataPipe and handles the insuficient resource case. Note: No crash reports has been received so far because this URLLoader is not used often enough. Bug: 911652 Change-Id: I09e9ec7cf883a3682466e528b6010fe326916400 Reviewed-on: https://chromium-review.googlesource.com/c/1355124 Commit-Queue: Arthur Sonzogni <[email protected]> Reviewed-by: Camille Lamy <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#613562}(cherry picked from commit 7d47a55) Reviewed-on: https://chromium-review.googlesource.com/c/1361873 Reviewed-by: Arthur Sonzogni <[email protected]> Cr-Commit-Position: refs/branch-heads/3626@{#68} Cr-Branched-From: d897fb1-refs/heads/master@{#612437}
1 parent 84a3578 commit 964eb46

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

content/browser/loader/navigation_url_loader_impl.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,18 @@ class AboutURLLoaderFactory : public network::mojom::URLLoaderFactory {
358358
network::ResourceResponseHead response_head;
359359
response_head.mime_type = "text/html";
360360
client->OnReceiveResponse(response_head);
361-
// The response's body is empty, so this data pipe will not be filled.
362-
mojo::DataPipe pipe;
363-
client->OnStartLoadingResponseBody(std::move(pipe.consumer_handle));
361+
362+
// Create a data pipe for transmitting the empty response. The |producer|
363+
// doesn't add any data.
364+
mojo::ScopedDataPipeProducerHandle producer;
365+
mojo::ScopedDataPipeConsumerHandle consumer;
366+
if (CreateDataPipe(nullptr, &producer, &consumer) != MOJO_RESULT_OK) {
367+
client->OnComplete(
368+
network::URLLoaderCompletionStatus(net::ERR_INSUFFICIENT_RESOURCES));
369+
return;
370+
}
371+
372+
client->OnStartLoadingResponseBody(std::move(consumer));
364373
client->OnComplete(network::URLLoaderCompletionStatus(net::OK));
365374
}
366375

0 commit comments

Comments
 (0)