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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappRegistry.java

Issue 2206953002: Use mojo for WebappRegistry. Base URL: https://chromium.googlesource.com/chromium/src.git@java-interface-registry
Patch Set: Created 4 years, 4 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/webapps/WebappRegistry.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappRegistry.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappRegistry.java
index 32ad44cdb8759514636a2e4f3440e8ef1f6ff6a4..41bbc3e8ba7eecc6f251c17d04ba31c2428d9f2b 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappRegistry.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappRegistry.java
@@ -12,7 +12,8 @@ import android.os.AsyncTask;
import org.chromium.base.ThreadUtils;
import org.chromium.base.VisibleForTesting;
-import org.chromium.base.annotations.CalledByNative;
+import org.chromium.mojo.system.MojoException;
+import org.chromium.shell.InterfaceFactory;
import java.util.Collections;
import java.util.HashSet;
@@ -28,8 +29,7 @@ import java.util.concurrent.TimeUnit;
* is similarily impossible to track pre-registry era web apps (this case is not a problem anyway
* as these web apps have no external data to cleanup).
*/
-public class WebappRegistry {
-
+public class WebappRegistry implements org.chromium.mojom.chrome.WebappRegistry {
static final String REGISTRY_FILE_NAME = "webapp_registry";
static final String KEY_WEBAPP_SET = "webapp_set";
static final String KEY_LAST_CLEANUP = "last_cleanup";
@@ -40,6 +40,8 @@ public class WebappRegistry {
/** Represents a period of 13 weeks in milliseconds */
static final long WEBAPP_UNOPENED_CLEANUP_DURATION = TimeUnit.DAYS.toMillis(13L * 7L);
+ private final Context mContext;
+
/**
* Called when a retrieval of the set of stored web app IDs occurs.
*/
@@ -255,12 +257,12 @@ public class WebappRegistry {
}.execute();
}
- @CalledByNative
- static void unregisterAllWebapps(Context context, final long callbackPointer) {
- unregisterAllWebapps(context, new Runnable() {
+ @Override
+ public void unregisterAllWebapps(final UnregisterAllWebappsResponse response) {
+ unregisterAllWebapps(mContext, new Runnable() {
@Override
public void run() {
- nativeOnWebappsUnregistered(callbackPointer);
+ response.call();
}
});
}
@@ -288,12 +290,12 @@ public class WebappRegistry {
}.execute();
}
- @CalledByNative
- static void clearWebappHistory(Context context, final long callbackPointer) {
- clearWebappHistory(context, new Runnable() {
+ @Override
+ public void clearWebappHistory(final ClearWebappHistoryResponse response) {
+ clearWebappHistory(mContext, new Runnable() {
@Override
public void run() {
- nativeOnClearedWebappHistory(callbackPointer);
+ response.call();
}
});
}
@@ -308,9 +310,32 @@ public class WebappRegistry {
preferences.getStringSet(KEY_WEBAPP_SET, Collections.<String>emptySet()));
}
- private WebappRegistry() {
+ private WebappRegistry(Context context) {
+ mContext = context;
}
- private static native void nativeOnWebappsUnregistered(long callbackPointer);
- private static native void nativeOnClearedWebappHistory(long callbackPointer);
+ @Override
+ public void close() {}
+
+ /**
+ * Called when the Mojo connection encounters an error.
+ */
+ @Override
+ public void onConnectionError(MojoException e) {}
+
+ /**
+ * A factory for WebappRegistry.
+ */
+ public static class Factory
+ implements InterfaceFactory<org.chromium.mojom.chrome.WebappRegistry> {
+ private final Context mContext;
+ public Factory(Context context) {
+ mContext = context;
+ }
+
+ @Override
+ public org.chromium.mojom.chrome.WebappRegistry createImpl() {
+ return new WebappRegistry(mContext);
+ }
+ }
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/mojo/ChromeInterfaceRegistrar.java ('k') | chrome/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698