Commit 351b4764 authored by Marijn Kruisselbrink's avatar Marijn Kruisselbrink Committed by Commit Bot

Add download_to_file DCHECKs to a bunch of URLLoaderFactories.

These factories don't support download_to_file anyway, so make sure
nobody is trying to call them with download_to_file set to true.

Also fix the one place where download_to_file was set to true despite
the code not actually expecting the callbacks that that should result
in, if download_to_file would have been implemented.

Bug: 791702
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: I2f31d2a45c59ba4b15e92cfe18718ed4eb69847b
Reviewed-on: https://chromium-review.googlesource.com/957708Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542869}
parent 288f5a81
......@@ -71,6 +71,7 @@ void BlobURLLoaderFactory::CreateLoaderAndStart(
const network::ResourceRequest& request,
network::mojom::URLLoaderClientPtr client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) {
DCHECK(!request.download_to_file);
DCHECK_CURRENTLY_ON(BrowserThread::IO);
std::unique_ptr<storage::BlobDataHandle> blob_handle;
if (blob_storage_context_) {
......
......@@ -142,7 +142,6 @@ std::unique_ptr<network::ResourceRequest> CreateResourceRequest(
request->site_for_cookies = params->url();
request->referrer = params->referrer();
request->referrer_policy = params->referrer_policy();
request->download_to_file = true;
request->allow_download = true;
request->is_main_frame = true;
......
......@@ -630,6 +630,7 @@ void FileURLLoaderFactory::CreateLoaderAndStart(
const network::ResourceRequest& request,
network::mojom::URLLoaderClientPtr client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) {
DCHECK(!request.download_to_file);
base::FilePath file_path;
const bool is_file = net::FileURLToFilePath(request.url, &file_path);
if (is_file && file_path.EndsWithSeparator() && file_path.IsAbsolute()) {
......
......@@ -243,6 +243,7 @@ class WebUIURLLoaderFactory : public network::mojom::URLLoaderFactory,
const net::MutableNetworkTrafficAnnotationTag&
traffic_annotation) override {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(!request.download_to_file);
if (request.url.scheme() != scheme_) {
DVLOG(1) << "Bad scheme: " << request.url.scheme();
......
......@@ -765,6 +765,7 @@ class ExtensionURLLoaderFactory : public network::mojom::URLLoaderFactory {
const net::MutableNetworkTrafficAnnotationTag&
traffic_annotation) override {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(!request.download_to_file);
const content::RenderProcessHost* process_host = frame_host_->GetProcess();
BrowserContext* browser_context = process_host->GetBrowserContext();
......
......@@ -148,6 +148,8 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE) ResourceRequest {
// If true, then the response body will be downloaded to a file and the path
// to that file will be provided in ResponseInfo::download_file_path.
// Deprecated and not supported by the network service code.
// TODO(mek): Remove this flag once all usage of it is gone (XHR and PPAPI).
bool download_to_file = false;
// True if the request can work after the fetch group is terminated.
......
......@@ -41,6 +41,7 @@ void URLLoaderFactory::CreateLoaderAndStart(
const ResourceRequest& url_request,
mojom::URLLoaderClientPtr client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) {
DCHECK(!url_request.download_to_file);
bool report_raw_headers = false;
if (url_request.report_raw_headers) {
const NetworkService* service = context_->network_service();
......
......@@ -29,6 +29,7 @@ void BlobURLLoaderFactory::CreateLoaderAndStart(
bindings_.ReportBadMessage("Invalid URL when attempting to fetch Blob");
return;
}
DCHECK(!request.download_to_file);
BlobURLLoader::CreateAndStart(
std::move(loader), request, std::move(client),
handle_ ? std::make_unique<BlobDataHandle>(*handle_) : nullptr);
......
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