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

Issue 1484093002: Allowing multiple SaveItems to have same URLs. (Closed)

Created:
5 years ago by Łukasz Anforowicz
Modified:
5 years ago
CC:
chromium-reviews, asanka, darin-cc_chromium.org, rginda+watch_chromium.org, loading-reviews_chromium.org, jam, Randy Smith (Not in Mondays), site-isolation-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@nested-frames-more-involved-fix
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Allowing multiple SaveItems to have same URLs. Creating a SaveItem for each frame. =================================== This CL causes SavePackage to create a separate SaveItem for each frame (by splitting FindOrCreatePendingSaveItem method into CreatePendingSaveItem and CreatePendingSaveItemDeduplicatingByUrl and using the latter only for savable resources, but not for frames). The change above means that URL is not anymore a good identifier of SaveItems and consequently requires introducing save_item_id. This code path is exercised by a new test in save_page_browsertest.cc that saves a page with subframes that have the same URL, but different content. At this point the test only ensures that we no longer crash in this scenario - follow-up CLs are needed to actually preserve contents of the frames in this scenario. Using save_item_id instead of save_id and/or url. ================================================= Before this CL, content::SaveItem didn't have its own id: - In some places (i.e. SavePackage::SaveFailed) SaveItems were identified by their URL. Using URL as an identifier is wrong (because 2 frames can have the same URI, but their content can diverge at runtime - see the new frames-runtime-changes.htm test being added in this CL). - In other places (i.e. SavePackage::LookupItemInProcessBySaveId) SaveItems (*) were identified by |save_id|. The problem with |save_id| was that it was generated (with help of SaveFileManager::GetNextId)) *after* creation of SaveItem and consequently there was a period when a SaveItem didn't have an id. In addition to the need to use URLs as an id, this also meant having to introduce SaveFileManager::RegisterStartingRequest to track requests that don't yet have an id. Note that |save_id| was used to identify more than SaveItems - it was also used as an identifier for SaveFile and other things that SaveFileManager tracked, but ultimately SaveItem is the first unique object associated with a file writing request tracked by SaveFileManager, so we can use save_item_id in place of save_id. After this CL: - content::SaveItem gets its own id (spelled save_item_id) that replaces save_id + can be used instead of URL to identify a SaveItem. Consequently: - We no longer need SavePackage::SaveFailed and SaveFileManager::OnErrorFinished (for the no-longer-applicable cases where there is no save_id yet). In their place we can just use SavePackage::SaveFinished and SaveFileManager::OnSaveFinished. - We on longer need SaveFileManager::RegisterStartingRequest and other methods types and fields used to maintain a map from (URL + contents_id) into SavePackage. Now SaveFileManager::packages_ can always be used (because now it uses always valid save_item_id, instead of lazily created save_id). Other changes ============= SavePackage should call SaveFileManager::SaveFinished once per frame (i.e. the number_of_frames_pending_response == 0 would only be true if we already called SaveFinished for all frames - therefore the 2nd call to SaveFinished is redundant and can be removed). This ensures that all DCHECKs in SaveFileManager work as expected. BUG=106364 Committed: https://crrev.com/870cf11e7b1548dabca2c0deb62e346568ea4e8b Cr-Commit-Position: refs/heads/master@{#364125}

Patch Set 1 #

Patch Set 2 : Rebasing... #

Total comments: 15

Patch Set 3 : Rebasing... #

Total comments: 4

Patch Set 4 : Addressed CR feedback from Randy. #

Patch Set 5 : Extra DCHECK + comment tweak. #

Patch Set 6 : Rebasing... #

Unified diffs Side-by-side diffs Delta from patch set Stats (+309 lines, -493 lines) Patch
M chrome/browser/download/save_page_browsertest.cc View 1 2 3 4 1 chunk +14 lines, -3 lines 0 comments Download
M content/browser/download/save_file.h View 1 chunk +1 line, -1 line 0 comments Download
M content/browser/download/save_file_manager.h View 1 8 chunks +25 lines, -67 lines 0 comments Download
M content/browser/download/save_file_manager.cc View 1 15 chunks +66 lines, -181 lines 0 comments Download
M content/browser/download/save_file_resource_handler.h View 1 2 chunks +2 lines, -1 line 0 comments Download
M content/browser/download/save_file_resource_handler.cc View 1 4 chunks +9 lines, -16 lines 0 comments Download
M content/browser/download/save_item.h View 3 chunks +3 lines, -5 lines 0 comments Download
M content/browser/download/save_item.cc View 1 2 3 3 chunks +22 lines, -25 lines 0 comments Download
M content/browser/download/save_package.h View 1 2 3 5 chunks +20 lines, -12 lines 0 comments Download
M content/browser/download/save_package.cc View 1 2 3 4 5 18 chunks +91 lines, -158 lines 0 comments Download
M content/browser/download/save_types.h View 1 4 chunks +22 lines, -8 lines 0 comments Download
M content/browser/download/save_types.cc View 1 1 chunk +30 lines, -14 lines 0 comments Download
M content/browser/loader/resource_dispatcher_host_impl.h View 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/loader/resource_dispatcher_host_impl.cc View 1 2 3 4 5 2 chunks +3 lines, -2 lines 0 comments Download

Messages

Total messages: 16 (5 generated)
Łukasz Anforowicz
Randy, could you please take a look?
5 years ago (2015-11-30 23:57:38 UTC) #2
Randy Smith (Not in Mondays)
Wow. This is goodness; thank you. I spent some time groking it, but didn't find ...
5 years ago (2015-12-03 20:58:28 UTC) #3
Łukasz Anforowicz
Randy, could you please take another look? https://codereview.chromium.org/1484093002/diff/20001/content/browser/download/save_item.cc File content/browser/download/save_item.cc (right): https://codereview.chromium.org/1484093002/diff/20001/content/browser/download/save_item.cc#newcode95 content/browser/download/save_item.cc:95: // c) ...
5 years ago (2015-12-04 21:16:45 UTC) #4
Łukasz Anforowicz
https://codereview.chromium.org/1484093002/diff/20001/content/browser/download/save_package.cc File content/browser/download/save_package.cc (right): https://codereview.chromium.org/1484093002/diff/20001/content/browser/download/save_package.cc#newcode1158 content/browser/download/save_package.cc:1158: // (in case of duplicated URIs). On 2015/12/04 21:16:45, ...
5 years ago (2015-12-04 21:21:06 UTC) #5
Randy Smith (Not in Mondays)
LGTM (below are suggestions or suggestion/nits). https://codereview.chromium.org/1484093002/diff/20001/content/browser/download/save_package.cc File content/browser/download/save_package.cc (left): https://codereview.chromium.org/1484093002/diff/20001/content/browser/download/save_package.cc#oldcode1157 content/browser/download/save_package.cc:1157: // SaveItems. On ...
5 years ago (2015-12-07 19:57:15 UTC) #6
Łukasz Anforowicz
Thanks for reviewing. https://codereview.chromium.org/1484093002/diff/20001/content/browser/download/save_package.cc File content/browser/download/save_package.cc (right): https://codereview.chromium.org/1484093002/diff/20001/content/browser/download/save_package.cc#newcode1158 content/browser/download/save_package.cc:1158: // (in case of duplicated URIs). ...
5 years ago (2015-12-07 20:32:32 UTC) #7
Łukasz Anforowicz
+mmenke@ - I plan to add you to TBR and land after rebasing (changes under ...
5 years ago (2015-12-09 17:13:54 UTC) #9
mmenke
On 2015/12/09 17:13:54, Łukasz Anforowicz wrote: > +mmenke@ - I plan to add you to ...
5 years ago (2015-12-09 17:18:50 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1484093002/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1484093002/100001
5 years ago (2015-12-09 17:59:21 UTC) #13
commit-bot: I haz the power
Committed patchset #6 (id:100001)
5 years ago (2015-12-09 19:25:33 UTC) #14
commit-bot: I haz the power
5 years ago (2015-12-09 19:26:55 UTC) #16
Message was sent while issue was closed.
Patchset 6 (id:??) landed as
https://crrev.com/870cf11e7b1548dabca2c0deb62e346568ea4e8b
Cr-Commit-Position: refs/heads/master@{#364125}

Powered by Google App Engine
This is Rietveld 408576698