New issue
Advanced search Search tips

Issue 863949 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Sep 5
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

Blocked on:
issue 825878

Blocking:
issue 863939



Sign in to add a comment

In-memory download service does not properly populate the response URL chain & headers

Project Member Reported by peter@chromium.org, Jul 16

Issue description

I've got a download::Client that uses the URL chain and response headers provided to the OnDownloadStarted() method.

https://cs.chromium.org/chromium/src/components/download/public/background_service/client.h?q=OnDownloadStarted&sq=package:chromium&dr=CSs&l=91

When I use a service created by download::BuildDownloadService(), this method is called with valid values for the |url_chain| and |headers| arguments.

When I use a service created by download::BuildInMemoryDownloadService(), both arguments are empty and thus invalid.

Could the in-memory download service be amended to provide them? :)
 
Blocking: 863939
Owner: xingliu@chromium.org
I can add those, SimpleUrlLoader now expose the response headers. url_chain is added in Oct.2017, I probably missed that.


Status: Assigned (was: Available)
Status: Started (was: Assigned)
Project Member

Comment 5 by bugdroid1@chromium.org, Jul 19

Status: Fixed (was: Started)
I don't think this is fixed, I'm still getting the same issue.

OnResponseStarted, which sets the headers (https://cs.chromium.org/chromium/src/components/download/internal/background_service/in_memory_download.cc?g=0&l=204)
is being called after the client is notified (https://cs.chromium.org/chromium/src/components/download/internal/background_service/in_memory_download_driver.cc?g=0&l=111).
Cc: rayankans@chromium.org
Status: Started (was: Fixed)
Good catch, this should be called after getting server response to match non incognito download.
Hi, is there any URL that we can test background fetch?
Blocking: 825878
Hey, you can use https://rayankans.github.io/bgf/bgf.html (but you will need to build chrome from head for it to work)

You will also need to enable this flag: chrome://flags/#enable-experimental-web-platform-features
Blockedon: 825878
Blocking: -825878
Thanks.
Test website has been moved to https://kanslulz.co.uk/bgf
Currently I have a CL for this https://chromium-review.googlesource.com/c/chromium/src/+/1171594, but some webkit layout test for background fetch will fail and hit a DCHECK.

This is probably due to BackgroundFetchDelegateProxy::OnDownloadComplete can be called without BackgroundFetchDelegateProxy::Core::OnDownloadStarted if the request fails at the very beginning on Mac with this fix.

Having OnDownloadStarted being called before OnDownloadComplete seems like a reasonable contract to me. 

Are you planning to fix that or do you think some changes need to be made from our end?
Currently OnDownloadStarted is triggered by network::SimpleURLLoader(SimpleURLLoader::SetOnResponseStartedCallback), we just plumb this event.

Let me try to remove the DCHECK hit in BackgroundFetchCrossOriginFilter to see if that works.
OnDownloadStarted is supposed to call after we get the server response, so if the connection is dropped before response kicked in, the network layer will directly call OnResponseComplete with an error code. I feel this is slightly better than tweaking the call contract in download service layer or background fetch layer.
per #17, I just double checked the download code path for normal profile, it seems we actually tweaked the call contract in 
https://cs.chromium.org/chromium/src/content/browser/download/download_request_core.cc?type=cs&g=0&l=431
https://cs.chromium.org/chromium/src/components/download/internal/common/download_response_handler.cc?type=cs&q=download_response&g=0&l=218

Probably do the same thing in InMemoryDownload is the correct fix for this.
Status: Fixed (was: Started)
Just confirmed this is working. Thanks!
Project Member

Comment 22 by bugdroid1@chromium.org, Sep 5

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8d9f363ef54cf1debdade0ac5e84b497c0e814c6

commit 8d9f363ef54cf1debdade0ac5e84b497c0e814c6
Author: Xing Liu <xingliu@chromium.org>
Date: Wed Sep 05 17:27:42 2018

Background download: Propagate OnDownloadCreated after server response.

In the download backend used by incognito mode in background download
service, OnDownloadCreated is called before receiving the server
response, that the URL chain and the server response headers are not
correctly propagate to clients.

TBR=peter@chromium.org

Bug:  863949 
Change-Id: Ic5f4dabe1c312a8c949bfb5edbc4e17e3e1081be
Reviewed-on: https://chromium-review.googlesource.com/1171594
Commit-Queue: Xing Liu <xingliu@chromium.org>
Reviewed-by: Rayan Kanso <rayankans@chromium.org>
Reviewed-by: Shakti Sahu <shaktisahu@chromium.org>
Reviewed-by: Min Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588914}
[modify] https://crrev.com/8d9f363ef54cf1debdade0ac5e84b497c0e814c6/components/download/internal/background_service/in_memory_download.cc
[modify] https://crrev.com/8d9f363ef54cf1debdade0ac5e84b497c0e814c6/components/download/internal/background_service/in_memory_download.h
[modify] https://crrev.com/8d9f363ef54cf1debdade0ac5e84b497c0e814c6/components/download/internal/background_service/in_memory_download_driver.cc
[modify] https://crrev.com/8d9f363ef54cf1debdade0ac5e84b497c0e814c6/components/download/internal/background_service/in_memory_download_driver.h
[modify] https://crrev.com/8d9f363ef54cf1debdade0ac5e84b497c0e814c6/components/download/internal/background_service/in_memory_download_driver_unittest.cc
[modify] https://crrev.com/8d9f363ef54cf1debdade0ac5e84b497c0e814c6/components/download/internal/background_service/in_memory_download_unittest.cc
[modify] https://crrev.com/8d9f363ef54cf1debdade0ac5e84b497c0e814c6/content/shell/browser/layout_test/layout_test_background_fetch_delegate.cc

Sign in to add a comment