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

Unified Diff: chrome/browser/android/ntp/ntp_snippets_bridge.cc

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
Index: chrome/browser/android/ntp/ntp_snippets_bridge.cc
diff --git a/chrome/browser/android/ntp/ntp_snippets_bridge.cc b/chrome/browser/android/ntp/ntp_snippets_bridge.cc
index faba81df0f75d39368a2fba4325d4443346c64c9..5e9e257a3544e37602e81a6182b113809d54629c 100644
--- a/chrome/browser/android/ntp/ntp_snippets_bridge.cc
+++ b/chrome/browser/android/ntp/ntp_snippets_bridge.cc
@@ -6,6 +6,7 @@
#include <jni.h>
+#include "base/android/callback_android.h"
#include "base/android/jni_android.h"
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
@@ -38,10 +39,7 @@ void SnippetVisitedHistoryRequestCallback(
const history::URLRow& row,
const history::VisitVector& visitVector) {
bool visited = success && row.visit_count() != 0;
-
- JNIEnv* env = base::android::AttachCurrentThread();
- Java_SnippetsBridge_runCallback(env, callback.obj(),
- static_cast<jboolean>(visited));
+ base::android::RunCallbackAndroid(callback, visited);
}
} // namespace
@@ -178,14 +176,11 @@ void NTPSnippetsBridge::NTPSnippetsServiceDisabled() {
void NTPSnippetsBridge::OnImageFetched(ScopedJavaGlobalRef<jobject> callback,
const std::string& snippet_id,
const gfx::Image& image) {
- JNIEnv* env = AttachCurrentThread();
-
ScopedJavaLocalRef<jobject> j_bitmap;
if (!image.IsEmpty())
j_bitmap = gfx::ConvertToJavaBitmap(image.ToSkBitmap());
- Java_FetchSnippetImageCallback_onSnippetImageAvailable(env, callback.obj(),
- j_bitmap.obj());
+ base::android::RunCallbackAndroid(callback, j_bitmap);
}
// static

Powered by Google App Engine
This is Rietveld 408576698