Commit 3138bdd6 authored by Shakti Sahu's avatar Shakti Sahu Committed by Commit Bot

The download infobar should only listen to active downloads

We recently noticed download infobar getting triggered unnecessarily
since it listens to every OnDownloadUpdated call. This CL changes it
to listen for only active downloads.

Bug: 1006961
Change-Id: Ief5e09f84446cc91b5cb0f63ec151f04b874bfdf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1818463Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Commit-Queue: Shakti Sahu <shaktisahu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699110}
parent d762124e
...@@ -372,6 +372,7 @@ public class DownloadManagerService ...@@ -372,6 +372,7 @@ public class DownloadManagerService
downloadItem.setSystemDownloadId( downloadItem.setSystemDownloadId(
DownloadManagerBridge.getDownloadIdForDownloadGuid(downloadInfo.getDownloadGuid())); DownloadManagerBridge.getDownloadIdForDownloadGuid(downloadInfo.getDownloadGuid()));
updateDownloadProgress(downloadItem, status); updateDownloadProgress(downloadItem, status);
updateDownloadInfoBar(downloadItem);
} }
@Override @Override
...@@ -382,6 +383,7 @@ public class DownloadManagerService ...@@ -382,6 +383,7 @@ public class DownloadManagerService
removeAutoResumableDownload(item.getId()); removeAutoResumableDownload(item.getId());
} }
updateDownloadProgress(item, DownloadStatus.IN_PROGRESS); updateDownloadProgress(item, DownloadStatus.IN_PROGRESS);
updateDownloadInfoBar(item);
scheduleUpdateIfNeeded(); scheduleUpdateIfNeeded();
} }
...@@ -390,6 +392,7 @@ public class DownloadManagerService ...@@ -390,6 +392,7 @@ public class DownloadManagerService
DownloadItem item = new DownloadItem(false, downloadInfo); DownloadItem item = new DownloadItem(false, downloadInfo);
removeAutoResumableDownload(item.getId()); removeAutoResumableDownload(item.getId());
updateDownloadProgress(new DownloadItem(false, downloadInfo), DownloadStatus.CANCELLED); updateDownloadProgress(new DownloadItem(false, downloadInfo), DownloadStatus.CANCELLED);
updateDownloadInfoBar(item);
} }
@Override @Override
...@@ -410,6 +413,7 @@ public class DownloadManagerService ...@@ -410,6 +413,7 @@ public class DownloadManagerService
UmaBackgroundDownload.INTERRUPTED, downloadInfo.getDownloadGuid()); UmaBackgroundDownload.INTERRUPTED, downloadInfo.getDownloadGuid());
} }
updateDownloadProgress(item, status); updateDownloadProgress(item, status);
updateDownloadInfoBar(item);
if (FeatureUtilities.isDownloadAutoResumptionEnabledInNative()) return; if (FeatureUtilities.isDownloadAutoResumptionEnabledInNative()) return;
DownloadProgress progress = mDownloadProgressMap.get(item.getId()); DownloadProgress progress = mDownloadProgressMap.get(item.getId());
...@@ -460,6 +464,12 @@ public class DownloadManagerService ...@@ -460,6 +464,12 @@ public class DownloadManagerService
} }
} }
private void updateDownloadInfoBar(DownloadItem item) {
DownloadInfoBarController infobarController =
getInfoBarController(item.getDownloadInfo().isOffTheRecord());
if (infobarController != null) infobarController.onDownloadItemUpdated(item);
}
/** /**
* Broadcast that a download was successful. * Broadcast that a download was successful.
* @param downloadInfo info about the download. * @param downloadInfo info about the download.
...@@ -1769,9 +1779,6 @@ public class DownloadManagerService ...@@ -1769,9 +1779,6 @@ public class DownloadManagerService
for (DownloadObserver adapter : mDownloadObservers) { for (DownloadObserver adapter : mDownloadObservers) {
adapter.onDownloadItemCreated(item); adapter.onDownloadItemCreated(item);
} }
DownloadInfoBarController infobarController =
getInfoBarController(item.getDownloadInfo().isOffTheRecord());
if (infobarController != null) infobarController.onDownloadItemUpdated(item);
} }
@CalledByNative @CalledByNative
...@@ -1779,10 +1786,6 @@ public class DownloadManagerService ...@@ -1779,10 +1786,6 @@ public class DownloadManagerService
for (DownloadObserver adapter : mDownloadObservers) { for (DownloadObserver adapter : mDownloadObservers) {
adapter.onDownloadItemUpdated(item); adapter.onDownloadItemUpdated(item);
} }
DownloadInfoBarController infobarController =
getInfoBarController(item.getDownloadInfo().isOffTheRecord());
if (infobarController != null) infobarController.onDownloadItemUpdated(item);
} }
@CalledByNative @CalledByNative
......
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