Commit b52abae3 authored by Min Qin's avatar Min Qin Committed by Commit Bot

Fixed a reentrance issue in DownloadManagerImpl::PostInitialization().

DownloadManagerImpl::PostInitialization() is called twice, one by history db,
one by download db.
If History db is initialized first, it will call OnHistoryQueryComplete() and
set load_history_downloads_cb_. If download db is ready later, it calls
PostInitialization() and executes load_history_downloads_cb_ immediately.
Since load_history_downloads_cb_ calls PostInitialization() again, we got an reentrance
issue.

BUG=900417

Change-Id: Ie89146f9bd7d30ca955601c7288e0f33c2e9e11b
Reviewed-on: https://chromium-review.googlesource.com/c/1309218Reviewed-by: default avatarShakti Sahu <shaktisahu@chromium.org>
Commit-Queue: Min Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604386}
parent a796aea5
......@@ -1012,8 +1012,11 @@ void DownloadManagerImpl::PostInitialization(
break;
case DOWNLOAD_INITIALIZATION_DEPENDENCY_IN_PROGRESS_CACHE:
in_progress_cache_initialized_ = true;
if (load_history_downloads_cb_)
std::move(load_history_downloads_cb_).Run();
// Post a task to load downloads from history db.
if (load_history_downloads_cb_) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, std::move(load_history_downloads_cb_));
}
break;
case DOWNLOAD_INITIALIZATION_DEPENDENCY_NONE:
default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment