| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/android/callback_android.h" |
| 5 #include "base/android/scoped_java_ref.h" | 6 #include "base/android/scoped_java_ref.h" |
| 6 #include "chrome/browser/android/offline_pages/background_scheduler_bridge.h" | 7 #include "chrome/browser/android/offline_pages/background_scheduler_bridge.h" |
| 7 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 8 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
| 8 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" | 9 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/profiles/profile_android.h" | 11 #include "chrome/browser/profiles/profile_android.h" |
| 11 #include "components/offline_pages/background/request_coordinator.h" | 12 #include "components/offline_pages/background/request_coordinator.h" |
| 12 #include "jni/BackgroundSchedulerBridge_jni.h" | 13 #include "jni/BackgroundSchedulerBridge_jni.h" |
| 13 | 14 |
| 14 using base::android::ScopedJavaGlobalRef; | 15 using base::android::ScopedJavaGlobalRef; |
| 15 | 16 |
| 16 namespace offline_pages { | 17 namespace offline_pages { |
| 17 namespace android { | 18 namespace android { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 // C++ callback that delegates to Java callback. | 22 // C++ callback that delegates to Java callback. |
| 22 void ProcessingDoneCallback( | 23 void ProcessingDoneCallback( |
| 23 const ScopedJavaGlobalRef<jobject>& j_callback_obj, jboolean result) { | 24 const ScopedJavaGlobalRef<jobject>& j_callback_obj, jboolean result) { |
| 24 JNIEnv* env = base::android::AttachCurrentThread(); | 25 base::android::RunCallbackAndroid(j_callback_obj, result); |
| 25 Java_ProcessingDoneCallback_onProcessingDone( | |
| 26 env, j_callback_obj.obj(), result); | |
| 27 } | 26 } |
| 28 | 27 |
| 29 } // namespace | 28 } // namespace |
| 30 | 29 |
| 31 // JNI call to start request processing. | 30 // JNI call to start request processing. |
| 32 static jboolean StartProcessing( | 31 static jboolean StartProcessing( |
| 33 JNIEnv* env, | 32 JNIEnv* env, |
| 34 const JavaParamRef<jclass>& jcaller, | 33 const JavaParamRef<jclass>& jcaller, |
| 35 const JavaParamRef<jobject>& j_callback_obj) { | 34 const JavaParamRef<jobject>& j_callback_obj) { |
| 36 ScopedJavaGlobalRef<jobject> j_callback_ref; | 35 ScopedJavaGlobalRef<jobject> j_callback_ref; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 52 JNIEnv* env = base::android::AttachCurrentThread(); | 51 JNIEnv* env = base::android::AttachCurrentThread(); |
| 53 Java_BackgroundSchedulerBridge_unschedule(env); | 52 Java_BackgroundSchedulerBridge_unschedule(env); |
| 54 } | 53 } |
| 55 | 54 |
| 56 bool RegisterBackgroundSchedulerBridge(JNIEnv* env) { | 55 bool RegisterBackgroundSchedulerBridge(JNIEnv* env) { |
| 57 return RegisterNativesImpl(env); | 56 return RegisterNativesImpl(env); |
| 58 } | 57 } |
| 59 | 58 |
| 60 } // namespace android | 59 } // namespace android |
| 61 } // namespace offline_pages | 60 } // namespace offline_pages |
| OLD | NEW |