Commit 6a685432 authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Download auto resumption: Don't schedule task when feature is disabled.

Don't schedule auto resumption in native task when the feature is
disabled. Also adds a check in
AutoResumptionHandler::ResumeDownloadImmediately.

Bug: NONE
Change-Id: I03eff855fcd8674f32d4a3d5205114de01aa3bf1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2250563Reviewed-by: default avatarShakti Sahu <shaktisahu@chromium.org>
Commit-Queue: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779468}
parent 7701a26f
......@@ -11,6 +11,8 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.TimeUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.chrome.browser.flags.CachedFeatureFlags;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.components.background_task_scheduler.BackgroundTaskScheduler;
import org.chromium.components.background_task_scheduler.BackgroundTaskSchedulerFactory;
import org.chromium.components.background_task_scheduler.TaskIds;
......@@ -66,8 +68,10 @@ public class DownloadTaskScheduler {
TimeUtils.SECONDS_PER_MINUTE * 5, TimeUtils.SECONDS_PER_MINUTE * 10);
scheduleTask(DownloadTaskType.CLEANUP_TASK, false, false, 0,
TimeUtils.SECONDS_PER_HOUR * 12, TimeUtils.SECONDS_PER_HOUR * 24);
scheduleTask(DownloadTaskType.DOWNLOAD_AUTO_RESUMPTION_TASK, false, false, 0,
TimeUtils.SECONDS_PER_MINUTE * 5, TimeUtils.SECONDS_PER_DAY);
if (CachedFeatureFlags.isEnabled(ChromeFeatureList.DOWNLOADS_AUTO_RESUMPTION_NATIVE)) {
scheduleTask(DownloadTaskType.DOWNLOAD_AUTO_RESUMPTION_TASK, false, false, 0,
TimeUtils.SECONDS_PER_MINUTE * 5, TimeUtils.SECONDS_PER_DAY);
}
}
private static int getTaskId(@DownloadTaskType int taskType) {
......
......@@ -174,6 +174,9 @@ void AutoResumptionHandler::OnDownloadDestroyed(download::DownloadItem* item) {
}
void AutoResumptionHandler::ResumeDownloadImmediately() {
if (!config_->is_auto_resumption_enabled_in_native)
return;
for (auto* download : std::move(downloads_to_retry_)) {
if (SatisfiesNetworkRequirements(download))
download->Resume(false);
......
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