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

Issue 7847027: DownloadId (Closed)

Created:
9 years, 3 months ago by benjhayden
Modified:
9 years, 3 months ago
CC:
chromium-reviews, achuith+watch_chromium.org, Paweł Hajdan Jr., jam, joi+watch-content_chromium.org, rginda+watch_chromium.org, darin-cc_chromium.org, rdsmith+dwatch_chromium.org, brettw-cc_chromium.org
Visibility:
Public.

Description

Retry r100017. This time, prevent a potential shutdown race by moving the call to DownloadManager.Shutdown() from ExitedOffTheRecordMode() to ~OTRProfileImpl() to match ProfileImpl and guarantee that Shutdown() is called. Make a new integer field in sql::MetaTable (a per-profile db) containing a counter for the next download id, so that this id is unique across sessions. This id will allow us to merge download id with db_handle and merge most/all of the maps in DownloadManager in future CLs. Make DownloadManager read this field to initialize its next_id_ counter in Init(). Put a fine-grained mutex in DownloadManager::GetNextId() so that it can be called directly from any thread. Define a thunk wrapping DM::GNI() to be passed around between threads to guard against other threads calling any other DM methods. This thunk owns a scoped_refptr<DM> to manage life-time issues. This pattern is implemented for DM elsewhere. Store this thunk in ResourceContext to be called by ResourceDispatchHost/DownloadThrottlingResourceHandler on the IO thread. Pass the returned DownloadId into DownloadResourceHandler. The alternative way to obtain ids on the IO thread is to jump over to the UI thread and back. This way would add significant latency to a critical path. GetNextId() should be fast and easily accessible from any thread. Now that ids are per-profile, define a class DownloadId containing a per-profile id and an indication of which profile, currently the DownloadManager*. DownloadIds are hashable, comparable, globally unique, not persistent, and are used by DownloadFileManager. When the download is added to the history, MetaTable.next_download_id will be set to the new download's id +1 if that number is greater than MT.next_download_id. Increasing this counter at the same time as the download is added to the db prevents the counter from desyncing from the db, which was the primary concern re storing the counter in the BrowserPrefs. Owners: Randy: downloads/* (no change from 7776012) (Done) John: content/browser/{renderer_host/,resource_context.}* (no change from 7776012) (Done) Will, Miranda: profiles/* (small bugfix) Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=102149

Patch Set 1 : 7776012 verbatim #

Total comments: 2

Patch Set 2 : merge, move DM Shutdown to ~OTRProfileImpl #

Total comments: 2

Patch Set 3 : merge, rm ExitedOffTheRecordMode #

Patch Set 4 : merge #

Patch Set 5 : merge #

Patch Set 6 : merge #

Unified diffs Side-by-side diffs Delta from patch set Stats (+404 lines, -128 lines) Patch
M chrome/browser/download/chrome_download_manager_delegate.cc View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M chrome/browser/download/download_history.h View 1 chunk +5 lines, -0 lines 0 comments Download
M chrome/browser/download/download_history.cc View 1 chunk +11 lines, -0 lines 0 comments Download
M chrome/browser/download/download_manager_unittest.cc View 3 chunks +4 lines, -3 lines 0 comments Download
M chrome/browser/download/download_throttling_resource_handler.cc View 1 chunk +4 lines, -0 lines 0 comments Download
M chrome/browser/download/download_util.h View 1 chunk +0 lines, -1 line 0 comments Download
M chrome/browser/extensions/extension_downloads_api.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/extensions/extension_downloads_api.cc View 1 2 3 1 chunk +3 lines, -2 lines 0 comments Download
M chrome/browser/history/download_database.h View 1 2 3 4 3 chunks +7 lines, -1 line 0 comments Download
M chrome/browser/history/download_database.cc View 1 2 3 4 3 chunks +11 lines, -1 line 0 comments Download
M chrome/browser/history/history.h View 1 2 3 1 chunk +7 lines, -0 lines 0 comments Download
M chrome/browser/history/history.cc View 1 2 3 4 1 chunk +7 lines, -0 lines 0 comments Download
M chrome/browser/history/history_backend.h View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M chrome/browser/history/history_backend.cc View 1 2 3 1 chunk +11 lines, -0 lines 0 comments Download
M chrome/browser/history/history_marshaling.h View 1 chunk +5 lines, -0 lines 0 comments Download
M chrome/browser/profiles/off_the_record_profile_impl.h View 1 2 3 1 chunk +0 lines, -1 line 0 comments Download
M chrome/browser/profiles/off_the_record_profile_impl.cc View 1 2 3 2 chunks +10 lines, -12 lines 0 comments Download
M chrome/browser/profiles/profile_io_data.h View 2 chunks +2 lines, -0 lines 0 comments Download
M chrome/browser/profiles/profile_io_data.cc View 3 chunks +4 lines, -1 line 0 comments Download
M content/browser/download/download_file_manager.h View 1 2 3 4 chunks +11 lines, -16 lines 0 comments Download
M content/browser/download/download_file_manager.cc View 20 chunks +50 lines, -51 lines 0 comments Download
A content/browser/download/download_id.h View 1 2 3 1 chunk +89 lines, -0 lines 0 comments Download
A content/browser/download/download_id.cc View 1 chunk +9 lines, -0 lines 0 comments Download
M content/browser/download/download_item.h View 1 2 3 3 chunks +3 lines, -1 line 0 comments Download
M content/browser/download/download_item.cc View 1 2 3 5 chunks +11 lines, -7 lines 0 comments Download
M content/browser/download/download_manager.h View 1 2 3 5 chunks +28 lines, -0 lines 0 comments Download
M content/browser/download/download_manager.cc View 1 2 3 4 5 chunks +41 lines, -8 lines 0 comments Download
M content/browser/download/download_resource_handler.h View 1 2 3 4 chunks +4 lines, -2 lines 0 comments Download
M content/browser/download/download_resource_handler.cc View 1 2 3 6 chunks +13 lines, -6 lines 0 comments Download
M content/browser/download/save_package.cc View 1 1 chunk +1 line, -4 lines 0 comments Download
M content/browser/renderer_host/buffered_resource_handler.cc View 1 2 3 2 chunks +4 lines, -0 lines 0 comments Download
M content/browser/renderer_host/resource_dispatcher_host.cc View 1 2 3 5 chunks +12 lines, -10 lines 0 comments Download
M content/browser/renderer_host/resource_dispatcher_host_unittest.cc View 5 4 chunks +12 lines, -0 lines 0 comments Download
M content/browser/resource_context.h View 1 2 3 3 chunks +7 lines, -0 lines 0 comments Download
M content/browser/resource_context.cc View 1 1 chunk +12 lines, -0 lines 0 comments Download
M content/content_browser.gypi View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 14 (0 generated)
benjhayden
Hi Will, Retrying 7776012/r100017. It was reverted because of the stack trace below. It appears ...
9 years, 3 months ago (2011-09-09 14:24:51 UTC) #1
benjhayden
Hi Pawel, I'm hunting down a possible race in OffTheRecordProfileImpl wrt DownloadManager creation, destruction, and ...
9 years, 3 months ago (2011-09-09 18:57:22 UTC) #2
Randy Smith (Not in Mondays)
Quick note while we're tracking down the larger issues. http://codereview.chromium.org/7847027/diff/34/content/browser/download/download_manager.cc File content/browser/download/download_manager.cc (right): http://codereview.chromium.org/7847027/diff/34/content/browser/download/download_manager.cc#newcode140 content/browser/download/download_manager.cc:140: ...
9 years, 3 months ago (2011-09-09 20:55:59 UTC) #3
benjhayden
Pawels says the he doesn't know who null'd the dm in eotrm or why, he ...
9 years, 3 months ago (2011-09-09 21:13:32 UTC) #4
willchan no longer on Chromium
Sounds fine to me. Let me know when it's ready for review (is it already?). ...
9 years, 3 months ago (2011-09-09 21:14:25 UTC) #5
benjhayden
Hi again, Miranda, Randy and I would appreciate your thoughts on this change to off_the_record_profile_impl.cc ...
9 years, 3 months ago (2011-09-12 20:58:36 UTC) #6
willchan no longer on Chromium
LGTM http://codereview.chromium.org/7847027/diff/17001/chrome/browser/profiles/off_the_record_profile_impl.cc File chrome/browser/profiles/off_the_record_profile_impl.cc (right): http://codereview.chromium.org/7847027/diff/17001/chrome/browser/profiles/off_the_record_profile_impl.cc#newcode535 chrome/browser/profiles/off_the_record_profile_impl.cc:535: virtual void ExitedOffTheRecordMode() { Can we get rid ...
9 years, 3 months ago (2011-09-12 22:09:41 UTC) #7
Miranda Callahan
On 2011/09/12 22:09:41, willchan wrote: > LGTM > > http://codereview.chromium.org/7847027/diff/17001/chrome/browser/profiles/off_the_record_profile_impl.cc > File chrome/browser/profiles/off_the_record_profile_impl.cc (right): > ...
9 years, 3 months ago (2011-09-13 08:51:43 UTC) #8
Miranda Callahan
On 2011/09/13 08:51:43, Miranda Callahan wrote: > On 2011/09/12 22:09:41, willchan wrote: > > LGTM ...
9 years, 3 months ago (2011-09-13 08:51:59 UTC) #9
benjhayden
http://codereview.chromium.org/7847027/diff/17001/chrome/browser/profiles/off_the_record_profile_impl.cc File chrome/browser/profiles/off_the_record_profile_impl.cc (right): http://codereview.chromium.org/7847027/diff/17001/chrome/browser/profiles/off_the_record_profile_impl.cc#newcode535 chrome/browser/profiles/off_the_record_profile_impl.cc:535: virtual void ExitedOffTheRecordMode() { On 2011/09/12 22:09:41, willchan wrote: ...
9 years, 3 months ago (2011-09-14 19:25:42 UTC) #10
benjhayden
Hi, John, would you mind rubber-stamping this? It's a reland of 7776012 (aka 7237034) with ...
9 years, 3 months ago (2011-09-19 17:55:06 UTC) #11
jam
rubberstamp lgtm
9 years, 3 months ago (2011-09-19 18:26:54 UTC) #12
commit-bot: I haz the power
Can't apply patch for file chrome/browser/history/download_database.h. While running patch -p1 --forward --force; patching file chrome/browser/history/download_database.h ...
9 years, 3 months ago (2011-09-19 21:15:03 UTC) #13
commit-bot: I haz the power
9 years, 3 months ago (2011-09-21 19:32:05 UTC) #14
Change committed as 102149

Powered by Google App Engine
This is Rietveld 408576698