Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4504)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java

Issue 2713433002: remove unnecessary thread hopping when updating Download notifications (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java b/chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java
index de1d292fdc8e4b5e6d990abcd70b9847ce4fcd63..5b6a2766b718475f25b0f1f4935af1841e8379d5 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/SystemDownloadNotifier.java
@@ -111,7 +111,7 @@ public class SystemDownloadNotifier implements DownloadNotifier {
void handlePendingNotifications() {
if (mPendingNotifications.isEmpty()) return;
for (PendingNotificationInfo info : mPendingNotifications) {
- updateDownloadNotificationOnUiThread(info);
+ updateDownloadNotification(info);
}
mPendingNotifications.clear();
}
@@ -227,25 +227,12 @@ public class SystemDownloadNotifier implements DownloadNotifier {
}
/**
- * Helper method to schedule download notification updates, can be called on any thread.
+ * Helper method to schedule download notification updates.
* @param info Pending notification information to be handled.
*/
- private void updateDownloadNotification(final PendingNotificationInfo notificationInfo) {
- ThreadUtils.postOnUiThread(new Runnable() {
- @Override
- public void run() {
- updateDownloadNotificationOnUiThread(notificationInfo);
- }
- });
- }
-
- /**
- * Updates the download notification on UI thread if the notification service is started.
- * Otherwise, wait for the notification service to become ready.
- * @param info Pending notification information to be handled.
- */
- private void updateDownloadNotificationOnUiThread(
- final PendingNotificationInfo notificationInfo) {
+ @VisibleForTesting
+ void updateDownloadNotification(final PendingNotificationInfo notificationInfo) {
+ assert ThreadUtils.runningOnUiThread();
startAndBindToServiceIfNeeded();
final DownloadInfo info = notificationInfo.downloadInfo;
if (notificationInfo.type == DOWNLOAD_NOTIFICATION_TYPE_PROGRESS) {

Powered by Google App Engine
This is Rietveld 408576698