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

Unified Diff: base/android/java/src/org/chromium/base/Callback.java

Issue 1996193003: Add support for calling the java Callback from native. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 7 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
« no previous file with comments | « base/android/callback_android.cc ('k') | base/base.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/java/src/org/chromium/base/Callback.java
diff --git a/base/android/java/src/org/chromium/base/Callback.java b/base/android/java/src/org/chromium/base/Callback.java
index 771871f379bc8cebc7c961e9e462a114df206c3e..b142f14cb5762f8f37b380df18b9fd1816b92962 100644
--- a/base/android/java/src/org/chromium/base/Callback.java
+++ b/base/android/java/src/org/chromium/base/Callback.java
@@ -4,14 +4,28 @@
package org.chromium.base;
+import org.chromium.base.annotations.CalledByNative;
+
/**
* A simple single-argument callback to handle the result of a computation.
*
* @param <T> The type of the computation's result.
*/
-public interface Callback<T> {
+public abstract class Callback<T> {
/**
* Invoked with the result of a computation.
*/
- public void onResult(T result);
+ public abstract void onResult(T result);
+
+ @SuppressWarnings("unchecked")
+ @CalledByNative
+ private void onResultFromNative(Object result) {
+ onResult((T) result);
+ }
+
+ @SuppressWarnings("unchecked")
+ @CalledByNative
+ private void onResultFromNative(boolean result) {
+ onResult((T) Boolean.valueOf(result));
+ }
}
« no previous file with comments | « base/android/callback_android.cc ('k') | base/base.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698