Commit c534ca72 authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Download: Rename DownloadController.DownloadNotificationService.

We have DownloadController.DownloadNotificationService and
DownloadNotificationService.java.

Rename DownloadController.DownloadNotificationService to
DownloadController.Observer. So people will not feel it's related to
notification.

Bug: 922929
Change-Id: I171b2d2840765425b1737abca44ec24035fcc506
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2057492Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Commit-Queue: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742438}
parent f553530c
...@@ -29,15 +29,13 @@ import org.chromium.ui.base.PermissionCallback; ...@@ -29,15 +29,13 @@ import org.chromium.ui.base.PermissionCallback;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
/** /**
* Java counterpart of android DownloadController. * Java counterpart of android DownloadController. Owned by native.
*
* Its a singleton class instantiated by the C++ DownloadController.
*/ */
public class DownloadController { public class DownloadController {
/** /**
* Class for notifying the application that download has completed. * Class for notifying download events to other classes.
*/ */
public interface DownloadNotificationService { public interface Observer {
/** /**
* Notify the host application that a download is finished. * Notify the host application that a download is finished.
* @param downloadInfo Information about the completed download. * @param downloadInfo Information about the completed download.
...@@ -64,14 +62,14 @@ public class DownloadController { ...@@ -64,14 +62,14 @@ public class DownloadController {
void onDownloadInterrupted(final DownloadInfo downloadInfo, boolean isAutoResumable); void onDownloadInterrupted(final DownloadInfo downloadInfo, boolean isAutoResumable);
} }
private static DownloadNotificationService sDownloadNotificationService; private static Observer sObserver;
public static void setDownloadNotificationService(DownloadNotificationService service) { public static void setDownloadNotificationService(Observer observer) {
if (ChromeFeatureList.isEnabled(ChromeFeatureList.DOWNLOAD_OFFLINE_CONTENT_PROVIDER)) { if (ChromeFeatureList.isEnabled(ChromeFeatureList.DOWNLOAD_OFFLINE_CONTENT_PROVIDER)) {
return; return;
} }
sDownloadNotificationService = service; sObserver = observer;
} }
/** /**
...@@ -84,8 +82,8 @@ public class DownloadController { ...@@ -84,8 +82,8 @@ public class DownloadController {
MediaStoreHelper.addImageToGalleryOnSDCard( MediaStoreHelper.addImageToGalleryOnSDCard(
downloadInfo.getFilePath(), downloadInfo.getMimeType()); downloadInfo.getFilePath(), downloadInfo.getMimeType());
if (sDownloadNotificationService == null) return; if (sObserver == null) return;
sDownloadNotificationService.onDownloadCompleted(downloadInfo); sObserver.onDownloadCompleted(downloadInfo);
} }
/** /**
...@@ -94,8 +92,8 @@ public class DownloadController { ...@@ -94,8 +92,8 @@ public class DownloadController {
*/ */
@CalledByNative @CalledByNative
private static void onDownloadInterrupted(DownloadInfo downloadInfo, boolean isAutoResumable) { private static void onDownloadInterrupted(DownloadInfo downloadInfo, boolean isAutoResumable) {
if (sDownloadNotificationService == null) return; if (sObserver == null) return;
sDownloadNotificationService.onDownloadInterrupted(downloadInfo, isAutoResumable); sObserver.onDownloadInterrupted(downloadInfo, isAutoResumable);
} }
/** /**
...@@ -103,8 +101,8 @@ public class DownloadController { ...@@ -103,8 +101,8 @@ public class DownloadController {
*/ */
@CalledByNative @CalledByNative
private static void onDownloadCancelled(DownloadInfo downloadInfo) { private static void onDownloadCancelled(DownloadInfo downloadInfo) {
if (sDownloadNotificationService == null) return; if (sObserver == null) return;
sDownloadNotificationService.onDownloadCancelled(downloadInfo); sObserver.onDownloadCancelled(downloadInfo);
} }
/** /**
...@@ -113,8 +111,8 @@ public class DownloadController { ...@@ -113,8 +111,8 @@ public class DownloadController {
*/ */
@CalledByNative @CalledByNative
private static void onDownloadUpdated(DownloadInfo downloadInfo) { private static void onDownloadUpdated(DownloadInfo downloadInfo) {
if (sDownloadNotificationService == null) return; if (sObserver == null) return;
sDownloadNotificationService.onDownloadUpdated(downloadInfo); sObserver.onDownloadUpdated(downloadInfo);
} }
......
...@@ -77,14 +77,14 @@ import java.util.Set; ...@@ -77,14 +77,14 @@ import java.util.Set;
import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.RejectedExecutionException;
/** /**
* Chrome implementation of the {@link DownloadController.DownloadNotificationService} interface. * Chrome implementation of the {@link DownloadController.Observer} interface.
* This class is responsible for keeping track of which downloads are in progress. It generates * This class is responsible for keeping track of which downloads are in progress. It generates
* updates for progress of downloads and handles cleaning up of interrupted progress notifications. * updates for progress of downloads and handles cleaning up of interrupted progress notifications.
* TODO(qinmin): move BroadcastReceiver inheritance into DownloadManagerBridge, as it * TODO(qinmin): move BroadcastReceiver inheritance into DownloadManagerBridge, as it
* handles all Android DownloadManager interactions. And DownloadManagerService should not know * handles all Android DownloadManager interactions. And DownloadManagerService should not know
* download Id issued by Android DownloadManager. * download Id issued by Android DownloadManager.
*/ */
public class DownloadManagerService implements DownloadController.DownloadNotificationService, public class DownloadManagerService implements DownloadController.Observer,
NetworkChangeNotifierAutoDetect.Observer, NetworkChangeNotifierAutoDetect.Observer,
DownloadServiceDelegate, ProfileManager.Observer { DownloadServiceDelegate, ProfileManager.Observer {
private static final String TAG = "DownloadService"; private static final String TAG = "DownloadService";
......
...@@ -51,8 +51,7 @@ public class MHTMLPageTest implements CustomMainActivityStart { ...@@ -51,8 +51,7 @@ public class MHTMLPageTest implements CustomMainActivityStart {
private EmbeddedTestServer mTestServer; private EmbeddedTestServer mTestServer;
private static class TestDownloadNotificationService private static class TestDownloadNotificationService implements DownloadController.Observer {
implements DownloadController.DownloadNotificationService {
private Semaphore mSemaphore; private Semaphore mSemaphore;
TestDownloadNotificationService(Semaphore semaphore) { TestDownloadNotificationService(Semaphore semaphore) {
......
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