Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/android/scoped_java_ref.h" | |
| 6 #include "chrome/browser/android/offline_pages/background_scheduler_bridge.h" | |
| 7 #include "chrome/browser/profiles/profile.h" | |
| 8 #include "chrome/browser/profiles/profile_android.h" | |
| 9 #include "jni/BackgroundSchedulerBridge_jni.h" | |
| 10 | |
| 11 using base::android::ScopedJavaGlobalRef; | |
| 12 | |
| 13 namespace offline_pages { | |
| 14 namespace android { | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 // C++ callback that delegates to Java callback. | |
| 19 void ProcessingDoneCallback( | |
| 20 const ScopedJavaGlobalRef<jobject>& j_callback_obj) { | |
| 21 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 22 Java_ProcessingDoneCallback_onResult(env, j_callback_obj.obj()); | |
| 23 } | |
| 24 | |
| 25 } // namespace | |
| 26 | |
| 27 // JNI call to start request processing. | |
| 28 static jboolean StartProcessing( | |
| 29 JNIEnv* env, | |
| 30 const JavaParamRef<jclass>& jcaller, | |
| 31 const JavaParamRef<jobject>& j_profile, | |
| 32 const JavaParamRef<jobject>& j_callback_obj) { | |
| 33 ScopedJavaGlobalRef<jobject> j_callback_ref; | |
| 34 j_callback_ref.Reset(env, j_callback_obj); | |
| 35 base::Bind(&ProcessingDoneCallback, j_callback_ref); | |
| 36 // TODO(dougarnett): lookup/create RequestCoordinator KeyedService | |
| 37 // and call StartProcessing on it with Bind-ed j_callback_obj. | |
|
fgorski
2016/04/28 11:44:00
nit: bound?
| |
| 38 return false; | |
| 39 } | |
| 40 | |
| 41 BackgroundSchedulerBridge::BackgroundSchedulerBridge() { | |
| 42 } | |
| 43 | |
| 44 BackgroundSchedulerBridge::~BackgroundSchedulerBridge() { | |
| 45 } | |
| 46 | |
| 47 void BackgroundSchedulerBridge::EnsureScheduled( | |
| 48 const TriggerCondition& trigger_condition) { | |
| 49 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 50 // TODO(dougarnett): pass trigger_condition. | |
| 51 Java_BackgroundSchedulerBridge_ensureScheduled(env); | |
| 52 } | |
| 53 | |
| 54 void BackgroundSchedulerBridge::ClearScheduled() { | |
| 55 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 56 Java_BackgroundSchedulerBridge_clearScheduled(env); | |
| 57 } | |
| 58 | |
| 59 bool RegisterBackgroundSchedulerBridge(JNIEnv* env) { | |
| 60 return RegisterNativesImpl(env); | |
| 61 } | |
| 62 | |
| 63 } // namespace android | |
| 64 } // namespace offline_pages | |
| OLD | NEW |