| Index: components/dom_distiller/content/browser/distillable_page_utils_android.cc
|
| diff --git a/components/dom_distiller/content/browser/distillable_page_utils_android.cc b/components/dom_distiller/content/browser/distillable_page_utils_android.cc
|
| index 56dfffaf18ec47497acac7f153272cbd42e6989d..00b69ba6686d8ee4df9585935df8416857d44a25 100644
|
| --- a/components/dom_distiller/content/browser/distillable_page_utils_android.cc
|
| +++ b/components/dom_distiller/content/browser/distillable_page_utils_android.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/message_loop/message_loop.h"
|
| +#include "components/dom_distiller/content/browser/distillability_driver.h"
|
| #include "components/dom_distiller/content/browser/distillable_page_utils.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "jni/DistillablePageUtils_jni.h"
|
| @@ -16,34 +17,32 @@ namespace dom_distiller {
|
| namespace android {
|
| namespace {
|
| void OnIsPageDistillableResult(
|
| - scoped_ptr<ScopedJavaGlobalRef<jobject>> callback_holder,
|
| - bool isDistillable) {
|
| + ScopedJavaGlobalRef<jobject>* callback_holder,
|
| + bool isDistillable, bool isLast) {
|
| Java_DistillablePageUtils_callOnIsPageDistillableResult(
|
| base::android::AttachCurrentThread(), callback_holder->obj(),
|
| - isDistillable);
|
| + isDistillable, isLast);
|
| }
|
| } // namespace
|
|
|
| -static void IsPageDistillable(JNIEnv* env,
|
| +static void SetCallback(JNIEnv* env,
|
| const JavaParamRef<jclass>& jcaller,
|
| const JavaParamRef<jobject>& webContents,
|
| - jboolean is_mobile_optimized,
|
| const JavaParamRef<jobject>& callback) {
|
| content::WebContents* web_contents(
|
| content::WebContents::FromJavaWebContents(webContents));
|
| - scoped_ptr<ScopedJavaGlobalRef<jobject>> callback_holder(
|
| - new ScopedJavaGlobalRef<jobject>());
|
| - callback_holder->Reset(env, callback);
|
| -
|
| if (!web_contents) {
|
| - base::MessageLoop::current()->PostTask(
|
| - FROM_HERE, base::Bind(OnIsPageDistillableResult,
|
| - base::Passed(&callback_holder), false));
|
| return;
|
| }
|
| - IsDistillablePage(
|
| - web_contents, is_mobile_optimized,
|
| - base::Bind(OnIsPageDistillableResult, base::Passed(&callback_holder)));
|
| +
|
| + // FIXME(wychen): check memory management
|
| + ScopedJavaGlobalRef<jobject>* callback_holder(
|
| + new ScopedJavaGlobalRef<jobject>());
|
| + callback_holder->Reset(env, callback);
|
| +
|
| + base::Callback<void(bool, bool)> cb =
|
| + base::Bind(OnIsPageDistillableResult, base::Owned(callback_holder));
|
| + setCallback(web_contents, cb);
|
| }
|
|
|
| bool RegisterDistillablePageUtils(JNIEnv* env) {
|
|
|