Commit 87fe6786 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Update OnPendingDownloadsLoaded to use existing coordinator .

Prior to crrev.com/c/2270077, |OnPendingDownloadsLoaded| always
eventually used |original_coordinator_|.

The code is updated to perform the same behavior, and ensure there exist
a non-OffTheRecord coordinator when the function is called.

OnPendingDownloadsLoaded

Bug: 1106324, 1099577
Change-Id: Ie6f8a4c727d481eb1b3a946b1de4b0a2a02c70bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2302992
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Auto-Submit: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarXing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789845}
parent 681a19fb
......@@ -673,11 +673,13 @@ download::DownloadItem* DownloadManagerService::GetDownload(
void DownloadManagerService::OnPendingDownloadsLoaded() {
is_pending_downloads_loaded_ = true;
ProfileKey* profile_key = use_existing_profile_key_for_testing_
? coordinators_.begin()->first
: ProfileManager::GetActiveUserProfile()
->GetOriginalProfile()
->GetProfileKey();
auto result =
std::find_if(coordinators_.begin(), coordinators_.end(),
[](const auto& it) { return !it.first->IsOffTheRecord(); });
CHECK(result != coordinators_.end())
<< "A non-OffTheRecord coordinator should exist when "
"OnPendingDownloadsLoaded is triggered.";
ProfileKey* profile_key = result->first;
// Kick-off the auto-resumption handler.
content::DownloadManager::DownloadVector all_items;
......@@ -810,7 +812,6 @@ void DownloadManagerService::CreateInterruptedDownloadForTest(
download::InProgressDownloadManager* in_progress_manager =
DownloadManagerUtils::GetInProgressDownloadManager(
ProfileKeyStartupAccessor::GetInstance()->profile_key());
UseExistingProfileKeyForTesting();
std::vector<GURL> url_chain;
url_chain.emplace_back(ConvertJavaStringToUTF8(env, jurl));
base::FilePath target_path(ConvertJavaStringToUTF8(env, jtarget_path));
......
......@@ -201,10 +201,6 @@ class DownloadManagerService
const JavaParamRef<jstring>& jdownload_guid,
jboolean download_started);
void UseExistingProfileKeyForTesting() {
use_existing_profile_key_for_testing_ = true;
}
private:
// For testing.
friend class DownloadManagerServiceTest;
......@@ -298,8 +294,6 @@ class DownloadManagerService
ScopedObserver<Profile, ProfileObserver> observed_profiles_{this};
bool use_existing_profile_key_for_testing_{false};
std::map<ProfileKey*, download::SimpleDownloadManagerCoordinator*>
coordinators_;
......
......@@ -37,7 +37,6 @@ class DownloadManagerServiceTest : public testing::Test {
this, &DownloadManagerServiceTest::GetDownloadByGuid));
coordinator_.SetSimpleDownloadManager(&manager_, false);
service_->UpdateCoordinator(&coordinator_, profile_.GetProfileKey());
service_->UseExistingProfileKeyForTesting();
}
void OnResumptionDone(bool success) {
......
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