• Min Qin's avatar
    Fix a crash when resuming an in-progress download before history is loaded · 2f28f8b4
    Min Qin authored
    If a download is interrupted in a terminal state, the information
    will be written to both history DB and in-progress DB. And the in-progress
    DB info will later be erased when download history is loaded. However,
    if Chrome crashes during the write, history DB could contain more recent
    information. If the same download is resumed in reduced mode later, loading
    the history DB could delete that download, causing Chrome to delete the
    DownloadFile object on UI thread while it is reading data on download
    task runner.
    This CL fixes the issue by:
    1. Force in-progress DB to write download information immediately if
    a download is in a terminal state.
    2. If a download is in terminal state in history DB and an in-progress
    DB version is already in-progress, ignore the history DB version and
    request it to be deleted. This matches the existing behavior if only
    history DB is used. (If only history DB is used, a crash before download
    terminal state is written to disk will make the download to be able to
    resume, even if a failed notification is already shown).
    
    BUG=1009839
    
    Change-Id: Ic8621754e4961f665f3d42452a4e3794cbbc82bf
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1898647
    Commit-Queue: Min Qin <qinmin@chromium.org>
    Reviewed-by: default avatarXing Liu <xingliu@chromium.org>
    Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#713998}
    2f28f8b4
download_db_cache.cc 7.65 KB