Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Issue 148133007: [Downloads] Always call DM::StartDownload() for explicit downloads. (Closed)

Created:
6 years, 11 months ago by asanka
Modified:
4 years, 10 months ago
CC:
benjhayden+dwatch_chromium.org, chromium-reviews, Charlie Harrison, darin-cc_chromium.org, jam, joi+watch-content_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Downloads] Always call DM::StartDownload() for explicit downloads. Every explicitly initiated download should be represented in the UI with the exception of downloads which are hidden or downloads which were cancelled by the user or were blocked by a throttle. This is currently not true for downloads whose requests fail before a response is available (e.g. because of the hostname not being resolved) because the DownloadManager is only notified during DownloadResourceHandler::OnResponseStarted(). Failure to notify the DownloadManager results in no DownloadItem being created, and subsequently no UI being presented to the user. The current behavior is also non-ideal for downloads resumption. When a partial download request receives a HTTP 412 response, the current logic invokes DownloadManager::StartDownload() with no indication that the Content-* headers received do not apply to the desired entity. Therefore the DownloadItem's ETag and Last-Modified headers can be incorrectly reset after a pre-condition failure. This CL makes the following changes: - DownloadItem::Start() now consumes a DownloadCreateInfo since multiple requests can be associated with a single DownloadItem due to resumption. Each new request results in a Start() call. - DownloadResourceHandler invokes DownloadManager::StartDownload() even when no OnResponseStarted is received. The only exception is if the associated renderer goes away between the time the download request is sent and the time the response is received. - UrlDownloader always invokes DownloadManager::StartDownload() for all initiated download requests without exception. - DownloadItemImpl invokes the delegate and requests a filename whenever one is needed. - DownloadTargetDeterminer generates a valid filename even if the DownloadItem is not in-progress. - DownloadUrlParameters::OnStartedCallback could now receive a valid DownloadItem even when the request fails. - ResourceDispatcherHost::BeginDownload() is no longer a public API. All wannabe downloaders must now go through DownloadManager to initiate a download. - ResourceDispatcherHostImpl is no longer responsible for invoking OnStartedCallback or pass through download parameters. DownloadRequestCore attaches the data direcly to explicit downloads. Ideally, explicit download initiation would first start by creating a DownloadItem. We aren't quite there yet due to the fact that consumers of the download system make assumptions about the existence of a download item. I.e. the fallacy that the existence of a download item must mean that that download is a candidate to be presented to the UI or other consumers. Once these consumers are fixed, then we can move all explicit download request initiated into DownloadItem, thus simplifying much of this logic. BUG=7648 Committed: https://crrev.com/00b621f5126d538df488090c19175ee892a7161b Cr-Commit-Position: refs/heads/master@{#376487}

Patch Set 1 : #

Patch Set 2 : #

Total comments: 42

Patch Set 3 : Address comments. #

Patch Set 4 : Address comments. #

Patch Set 5 : Resurrect! #

Patch Set 6 : A few more tests. #

Patch Set 7 : Also handle failure paths from ResourceDispatcherHostImpl #

Patch Set 8 : Moar tests #

Patch Set 9 : #

Total comments: 51

Patch Set 10 : Resolve race with download target determination and address comments. #

Patch Set 11 : Deal with downloads that are blocked by throttles. #

Total comments: 14

Patch Set 12 : Ketchup with upstream. #

Total comments: 37

Patch Set 13 : #

Patch Set 14 : Ok fine. INTERRUPTED_PENDING_TARGET should map to IN_PROGRESS :-P #

Total comments: 3

Patch Set 15 : Address comments #

Total comments: 16

Patch Set 16 : Comment updates #

Total comments: 21

Patch Set 17 : Comments #

Total comments: 5

Patch Set 18 : restore OnStartedCallback behavior. #

Total comments: 4

Patch Set 19 : Fix typos #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1717 lines, -1157 lines) Patch
M chrome/browser/download/download_browsertest.cc View 1 2 3 4 5 6 8 chunks +176 lines, -266 lines 0 comments Download
M chrome/browser/download/download_target_determiner.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 5 chunks +8 lines, -11 lines 0 comments Download
M chrome/browser/download/download_target_determiner_unittest.cc View 1 2 3 4 5 6 7 8 9 2 chunks +9 lines, -8 lines 0 comments Download
M chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +35 lines, -8 lines 0 comments Download
M chrome/browser/extensions/webstore_installer.cc View 1 2 3 4 5 6 7 1 chunk +3 lines, -2 lines 0 comments Download
A chrome/test/data/downloads/download-anchor-attrib-400.html View 1 chunk +13 lines, -0 lines 0 comments Download
A chrome/test/data/downloads/download-anchor-attrib-404.html View 1 chunk +13 lines, -0 lines 0 comments Download
A chrome/test/data/downloads/download-anchor-attrib-name-not-resolved.html View 1 chunk +13 lines, -0 lines 0 comments Download
M content/browser/download/download_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 13 chunks +237 lines, -26 lines 0 comments Download
M content/browser/download/download_create_info.h View 1 2 3 4 5 6 7 8 9 5 chunks +29 lines, -19 lines 0 comments Download
M content/browser/download/download_create_info.cc View 1 2 3 4 5 6 7 8 9 2 chunks +4 lines, -6 lines 0 comments Download
M content/browser/download/download_file_factory.h View 1 2 3 2 chunks +4 lines, -2 lines 0 comments Download
M content/browser/download/download_file_factory.cc View 1 2 3 4 1 chunk +6 lines, -5 lines 0 comments Download
M content/browser/download/download_file_impl.h View 1 2 3 4 2 chunks +10 lines, -9 lines 0 comments Download
M content/browser/download/download_file_impl.cc View 1 2 3 4 1 chunk +6 lines, -5 lines 0 comments Download
M content/browser/download/download_file_unittest.cc View 1 2 3 4 2 chunks +12 lines, -11 lines 0 comments Download
M content/browser/download/download_item_impl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 11 chunks +43 lines, -23 lines 0 comments Download
M content/browser/download/download_item_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 39 chunks +160 lines, -107 lines 0 comments Download
M content/browser/download/download_item_impl_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 28 chunks +185 lines, -56 lines 0 comments Download
M content/browser/download/download_manager_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 4 chunks +59 lines, -94 lines 0 comments Download
M content/browser/download/download_manager_impl_unittest.cc View 1 2 3 4 6 chunks +21 lines, -17 lines 0 comments Download
M content/browser/download/download_request_core.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 5 chunks +53 lines, -26 lines 0 comments Download
M content/browser/download/download_request_core.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 9 chunks +381 lines, -130 lines 0 comments Download
M content/browser/download/download_resource_handler.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +8 lines, -17 lines 0 comments Download
M content/browser/download/download_resource_handler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 6 chunks +39 lines, -54 lines 0 comments Download
M content/browser/download/drag_download_file.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +2 lines, -2 lines 0 comments Download
M content/browser/download/url_downloader.h View 1 2 3 4 5 6 3 chunks +25 lines, -23 lines 0 comments Download
M content/browser/download/url_downloader.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 5 chunks +32 lines, -72 lines 0 comments Download
M content/browser/loader/mime_type_resource_handler.cc View 1 2 3 4 5 6 1 chunk +3 lines, -7 lines 0 comments Download
M content/browser/loader/mime_type_resource_handler_unittest.cc View 1 2 3 4 5 6 1 chunk +1 line, -4 lines 0 comments Download
M content/browser/loader/resource_dispatcher_host_impl.h View 1 2 3 4 5 6 7 8 9 3 chunks +10 lines, -17 lines 0 comments Download
M content/browser/loader/resource_dispatcher_host_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 6 chunks +11 lines, -52 lines 0 comments Download
M content/browser/loader/resource_dispatcher_host_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +1 line, -5 lines 0 comments Download
M content/public/browser/download_url_parameters.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +70 lines, -16 lines 0 comments Download
M content/public/browser/resource_dispatcher_host.h View 1 2 3 4 5 6 7 8 9 3 chunks +1 line, -28 lines 0 comments Download
M content/public/test/test_download_request_handler.cc View 1 2 3 4 6 chunks +8 lines, -7 lines 0 comments Download
M content/public/test/test_file_error_injector.cc View 1 2 3 4 5 chunks +26 lines, -22 lines 0 comments Download

Messages

Total messages: 53 (11 generated)
asanka
6 years, 10 months ago (2014-02-20 00:28:16 UTC) #1
Randy Smith (Not in Mondays)
A combination of nits and high-level state transition questions/concerns. If it's easier, you're free to ...
6 years, 9 months ago (2014-03-18 21:07:24 UTC) #2
asanka
On 2014/03/18 21:07:24, rdsmith wrote: > A combination of nits and high-level state transition questions/concerns. ...
6 years, 9 months ago (2014-03-19 20:37:00 UTC) #3
asanka
https://codereview.chromium.org/148133007/diff/420001/content/browser/download/download_item_impl.cc File content/browser/download/download_item_impl.cc (left): https://codereview.chromium.org/148133007/diff/420001/content/browser/download/download_item_impl.cc#oldcode1213 content/browser/download/download_item_impl.cc:1213: DCHECK(download_file_.get()); On 2014/03/18 21:07:28, rdsmith wrote: > Ok, I'm ...
6 years, 9 months ago (2014-03-19 20:37:06 UTC) #4
asanka
It's still possible for the OnStartedCallback to be invoked without a DownloadItem if RDH decides ...
6 years, 9 months ago (2014-03-20 14:09:14 UTC) #5
Randy Smith (Not in Mondays)
Quick response before an interview so that we can continue the discussion. Noting (mostly for ...
6 years, 9 months ago (2014-03-20 15:24:53 UTC) #6
Randy Smith (Not in Mondays)
Responding to that last point I missed. https://codereview.chromium.org/148133007/diff/420001/content/browser/download/download_item_impl.cc File content/browser/download/download_item_impl.cc (left): https://codereview.chromium.org/148133007/diff/420001/content/browser/download/download_item_impl.cc#oldcode1706 content/browser/download/download_item_impl.cc:1706: weak_ptr_factory_.GetWeakPtr())); On ...
6 years, 9 months ago (2014-03-20 18:04:45 UTC) #7
asanka
On 2014/03/20 18:04:45, rdsmith wrote: > Responding to that last point I missed. > > ...
6 years, 9 months ago (2014-03-21 19:10:30 UTC) #8
Randy Smith (Not in Mondays)
On 2014/03/21 19:10:30, asanka wrote: > On 2014/03/20 18:04:45, rdsmith wrote: > > Responding to ...
6 years, 9 months ago (2014-03-24 18:17:07 UTC) #9
asanka
I resurrected this CL because it was quite necessary for fixing download resumption in the ...
4 years, 10 months ago (2016-02-03 03:00:46 UTC) #13
asanka
On 2016/02/03 03:00:46, asanka wrote: > I resurrected this CL because it was quite necessary ...
4 years, 10 months ago (2016-02-03 14:59:00 UTC) #14
Randy Smith (Not in Mondays)
I apologize; I've gotten my mind about halfway around this CL in concept, so you're ...
4 years, 10 months ago (2016-02-05 00:51:41 UTC) #15
Randy Smith (Not in Mondays)
I got most of the way through a second, medium level pass, but I have ...
4 years, 10 months ago (2016-02-10 21:48:46 UTC) #16
asanka
https://codereview.chromium.org/148133007/diff/580001/content/browser/download/download_create_info.cc File content/browser/download/download_create_info.cc (right): https://codereview.chromium.org/148133007/diff/580001/content/browser/download/download_create_info.cc#newcode24 content/browser/download/download_create_info.cc:24: total_bytes(0) {} On 2016/02/10 21:48:45, Randy Smith - Not ...
4 years, 10 months ago (2016-02-11 03:43:07 UTC) #17
asanka
On 2016/02/05 00:51:41, Randy Smith - Not in Fridays wrote: > > * I wasn't ...
4 years, 10 months ago (2016-02-11 03:46:46 UTC) #18
asanka
On 2016/02/10 21:48:46, Randy Smith - Not in Fridays wrote: > I got most of ...
4 years, 10 months ago (2016-02-11 03:48:56 UTC) #19
asanka
On 2016/02/11 03:48:56, asanka wrote: > On 2016/02/10 21:48:46, Randy Smith - Not in Fridays ...
4 years, 10 months ago (2016-02-11 16:16:17 UTC) #20
Randy Smith (Not in Mondays)
Ok, this counts as a review where I feel like I understand the CL to ...
4 years, 10 months ago (2016-02-11 22:08:09 UTC) #22
asanka
https://codereview.chromium.org/148133007/diff/420001/content/browser/download/download_item_impl.cc File content/browser/download/download_item_impl.cc (left): https://codereview.chromium.org/148133007/diff/420001/content/browser/download/download_item_impl.cc#oldcode1446 content/browser/download/download_item_impl.cc:1446: if (state_ == IN_PROGRESS_INTERNAL) { On 2014/03/20 15:24:54, Randy ...
4 years, 10 months ago (2016-02-11 23:57:25 UTC) #23
asanka
https://codereview.chromium.org/148133007/diff/640001/content/browser/download/download_browsertest.cc File content/browser/download/download_browsertest.cc (right): https://codereview.chromium.org/148133007/diff/640001/content/browser/download/download_browsertest.cc#newcode1675 content/browser/download/download_browsertest.cc:1675: ResumingRequestBlockedByThrottle) { I switched to always using UrlDownloader for ...
4 years, 10 months ago (2016-02-12 16:06:50 UTC) #24
asanka
Adding owners: benjhayden: chrome/.../downloads_api.cc chrome/.../downloads_api_browsertest.cc sky: chrome/browser/extensions/webstore_installer.cc content/public/browser/download_url_parameters.h content/public/browser/resource_dispatcher_host.h content/public/test/test_download_request_handler.cc content/public/test/test_file_error_injector.cc davidben: content/browser/loader/mime_type_resource_handler.cc content/browser/loader/mime_type_resource_handler_unittest.cc content/browser/loader/resource_dispatcher_host_impl.cc ...
4 years, 10 months ago (2016-02-12 16:20:29 UTC) #28
sky
I'm not an owner of content/public. The other parts you wanted me to look at ...
4 years, 10 months ago (2016-02-12 16:35:57 UTC) #29
Randy Smith (Not in Mondays)
Quick responses with some pings on comments I don't see responses to. https://codereview.chromium.org/148133007/diff/580001/content/browser/download/download_item_impl.h File content/browser/download/download_item_impl.h ...
4 years, 10 months ago (2016-02-12 18:01:19 UTC) #30
asanka
https://codereview.chromium.org/148133007/diff/580001/content/browser/download/download_manager_impl.cc File content/browser/download/download_manager_impl.cc (right): https://codereview.chromium.org/148133007/diff/580001/content/browser/download/download_manager_impl.cc#newcode363 content/browser/download/download_manager_impl.cc:363: DCHECK(stream.get()); On 2016/02/12 18:01:18, Randy Smith - Not in ...
4 years, 10 months ago (2016-02-12 18:31:47 UTC) #31
Randy Smith (Not in Mondays)
Some further quick responses (I hadn't seen your responses to the old PS comments previously). ...
4 years, 10 months ago (2016-02-12 18:58:11 UTC) #32
Randy Smith (Not in Mondays)
Sending out an intermediate set of comments because of the potential blocker in the new ...
4 years, 10 months ago (2016-02-12 19:10:28 UTC) #33
asanka
https://codereview.chromium.org/148133007/diff/700001/content/browser/download/download_item_impl.cc File content/browser/download/download_item_impl.cc (right): https://codereview.chromium.org/148133007/diff/700001/content/browser/download/download_item_impl.cc#newcode1334 content/browser/download/download_item_impl.cc:1334: // in an underminate state after invoking observers. On ...
4 years, 10 months ago (2016-02-12 19:30:35 UTC) #34
asanka
https://codereview.chromium.org/148133007/diff/420001/content/browser/download/download_item_impl.cc File content/browser/download/download_item_impl.cc (left): https://codereview.chromium.org/148133007/diff/420001/content/browser/download/download_item_impl.cc#oldcode1446 content/browser/download/download_item_impl.cc:1446: if (state_ == IN_PROGRESS_INTERNAL) { On 2016/02/12 18:58:10, Randy ...
4 years, 10 months ago (2016-02-12 20:52:29 UTC) #35
Randy Smith (Not in Mondays)
Ok, fully detailed review of everything non-test. https://codereview.chromium.org/148133007/diff/700001/content/browser/download/download_item_impl.cc File content/browser/download/download_item_impl.cc (right): https://codereview.chromium.org/148133007/diff/700001/content/browser/download/download_item_impl.cc#newcode367 content/browser/download/download_item_impl.cc:367: case INTERRUPTED_TARGET_PENDING_INTERNAL: ...
4 years, 10 months ago (2016-02-12 21:57:20 UTC) #36
Randy Smith (Not in Mondays)
A couple of test notes and questions. https://codereview.chromium.org/148133007/diff/720001/content/browser/download/download_browsertest.cc File content/browser/download/download_browsertest.cc (right): https://codereview.chromium.org/148133007/diff/720001/content/browser/download/download_browsertest.cc#newcode2032 content/browser/download/download_browsertest.cc:2032: // DownloadItem ...
4 years, 10 months ago (2016-02-12 22:09:23 UTC) #37
asanka
https://codereview.chromium.org/148133007/diff/700001/content/browser/download/download_item_impl.cc File content/browser/download/download_item_impl.cc (right): https://codereview.chromium.org/148133007/diff/700001/content/browser/download/download_item_impl.cc#newcode367 content/browser/download/download_item_impl.cc:367: case INTERRUPTED_TARGET_PENDING_INTERNAL: On 2016/02/12 21:57:19, Randy Smith - Not ...
4 years, 10 months ago (2016-02-12 23:34:48 UTC) #38
benjhayden
https://codereview.chromium.org/148133007/diff/740001/chrome/browser/extensions/api/downloads/downloads_api.cc File chrome/browser/extensions/api/downloads/downloads_api.cc (right): https://codereview.chromium.org/148133007/diff/740001/chrome/browser/extensions/api/downloads/downloads_api.cc#newcode1058 chrome/browser/extensions/api/downloads/downloads_api.cc:1058: error_ = content::DownloadInterruptReasonToString(interrupt_reason); Let me see if I'm reading ...
4 years, 10 months ago (2016-02-13 00:07:32 UTC) #39
Randy Smith (Not in Mondays)
LGTM; use of comments below up to you (I do think the state transition comments ...
4 years, 10 months ago (2016-02-13 00:16:31 UTC) #40
Randy Smith (Not in Mondays)
https://codereview.chromium.org/148133007/diff/740001/chrome/browser/extensions/api/downloads/downloads_api.cc File chrome/browser/extensions/api/downloads/downloads_api.cc (right): https://codereview.chromium.org/148133007/diff/740001/chrome/browser/extensions/api/downloads/downloads_api.cc#newcode1058 chrome/browser/extensions/api/downloads/downloads_api.cc:1058: error_ = content::DownloadInterruptReasonToString(interrupt_reason); On 2016/02/13 00:07:32, benjhayden_chromium wrote: > ...
4 years, 10 months ago (2016-02-13 00:19:29 UTC) #41
asanka
https://codereview.chromium.org/148133007/diff/740001/chrome/browser/extensions/api/downloads/downloads_api.cc File chrome/browser/extensions/api/downloads/downloads_api.cc (right): https://codereview.chromium.org/148133007/diff/740001/chrome/browser/extensions/api/downloads/downloads_api.cc#newcode1058 chrome/browser/extensions/api/downloads/downloads_api.cc:1058: error_ = content::DownloadInterruptReasonToString(interrupt_reason); On 2016/02/13 00:19:29, Randy Smith - ...
4 years, 10 months ago (2016-02-13 00:57:36 UTC) #42
asanka
I restored the OnStartedCallback semantics. We are now returning a valid download item and an ...
4 years, 10 months ago (2016-02-13 01:27:21 UTC) #43
benjhayden
Thanks! downloads_api_browsertest changes lgtm downloads_api non-changes lgtm :-)
4 years, 10 months ago (2016-02-16 17:50:21 UTC) #44
davidben
content lgtm, but I didn't look at content/browser/download. Assuming rdsmith took care of that and ...
4 years, 10 months ago (2016-02-17 01:09:04 UTC) #45
asanka
Thanks everyone! https://codereview.chromium.org/148133007/diff/760001/content/public/browser/download_url_parameters.h File content/public/browser/download_url_parameters.h (right): https://codereview.chromium.org/148133007/diff/760001/content/public/browser/download_url_parameters.h#newcode45 content/public/browser/download_url_parameters.h:45: // downlaod request. For new downloads, this ...
4 years, 10 months ago (2016-02-19 17:06:09 UTC) #46
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/148133007/780001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/148133007/780001
4 years, 10 months ago (2016-02-19 17:08:53 UTC) #49
commit-bot: I haz the power
Committed patchset #19 (id:780001)
4 years, 10 months ago (2016-02-19 18:09:36 UTC) #51
commit-bot: I haz the power
4 years, 10 months ago (2016-02-19 18:11:05 UTC) #53
Message was sent while issue was closed.
Patchset 19 (id:??) landed as
https://crrev.com/00b621f5126d538df488090c19175ee892a7161b
Cr-Commit-Position: refs/heads/master@{#376487}

Powered by Google App Engine
This is Rietveld 408576698