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

Side by Side Diff: chrome/browser/android/offline_pages/background_scheduler_bridge.cc

Issue 1985923002: Wireframe scheduler implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback per DougArnett Created 4 years, 6 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 unified diff | Download patch
OLDNEW
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/scoped_java_ref.h" 5 #include "base/android/scoped_java_ref.h"
6 #include "chrome/browser/android/offline_pages/background_scheduler_bridge.h" 6 #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/request_coordinator_factory.h"
7 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/profiles/profile_android.h" 10 #include "chrome/browser/profiles/profile_android.h"
11 #include "components/offline_pages/background/request_coordinator.h"
9 #include "jni/BackgroundSchedulerBridge_jni.h" 12 #include "jni/BackgroundSchedulerBridge_jni.h"
10 13
11 using base::android::ScopedJavaGlobalRef; 14 using base::android::ScopedJavaGlobalRef;
12 15
13 namespace offline_pages { 16 namespace offline_pages {
14 namespace android { 17 namespace android {
15 18
16 namespace { 19 namespace {
17 20
18 // C++ callback that delegates to Java callback. 21 // C++ callback that delegates to Java callback.
19 void ProcessingDoneCallback( 22 void ProcessingDoneCallback(
20 const ScopedJavaGlobalRef<jobject>& j_callback_obj, jboolean result) { 23 const ScopedJavaGlobalRef<jobject>& j_callback_obj, jboolean result) {
21 JNIEnv* env = base::android::AttachCurrentThread(); 24 JNIEnv* env = base::android::AttachCurrentThread();
22 Java_ProcessingDoneCallback_onProcessingDone( 25 Java_ProcessingDoneCallback_onProcessingDone(
23 env, j_callback_obj.obj(), result); 26 env, j_callback_obj.obj(), result);
24 } 27 }
25 28
26 } // namespace 29 } // namespace
27 30
28 // JNI call to start request processing. 31 // JNI call to start request processing.
29 static jboolean StartProcessing( 32 static jboolean StartProcessing(
30 JNIEnv* env, 33 JNIEnv* env,
31 const JavaParamRef<jclass>& jcaller, 34 const JavaParamRef<jclass>& jcaller,
32 const JavaParamRef<jobject>& j_profile, 35 const JavaParamRef<jobject>& j_context,
33 const JavaParamRef<jobject>& j_callback_obj) { 36 const JavaParamRef<jobject>& j_callback_obj) {
34 ScopedJavaGlobalRef<jobject> j_callback_ref; 37 ScopedJavaGlobalRef<jobject> j_callback_ref;
35 j_callback_ref.Reset(env, j_callback_obj); 38 j_callback_ref.Reset(env, j_callback_obj);
36 base::Bind(&ProcessingDoneCallback, j_callback_ref); 39 base::Bind(&ProcessingDoneCallback, j_callback_ref);
37 // TODO(dougarnett): lookup/create RequestCoordinator KeyedService 40 // TODO(dougarnett): lookup/create RequestCoordinator KeyedService
38 // and call StartProcessing on it with bound j_callback_obj. 41 // and call StartProcessing on it with bound j_callback_obj.
39 return false; 42 return false;
40 } 43 }
41 44
42 BackgroundSchedulerBridge::BackgroundSchedulerBridge() {
43 }
44
45 BackgroundSchedulerBridge::~BackgroundSchedulerBridge() {
46 }
47
48 void BackgroundSchedulerBridge::Schedule( 45 void BackgroundSchedulerBridge::Schedule(
49 const TriggerCondition& trigger_condition) { 46 const TriggerCondition& trigger_condition) {
50 JNIEnv* env = base::android::AttachCurrentThread(); 47 JNIEnv* env = base::android::AttachCurrentThread();
51 // TODO(dougarnett): pass trigger_condition. 48 // TODO(dougarnett): pass trigger_condition.
52 Java_BackgroundSchedulerBridge_schedule(env); 49 Java_BackgroundSchedulerBridge_schedule(env);
53 } 50 }
54 51
55 void BackgroundSchedulerBridge::Unschedule() { 52 void BackgroundSchedulerBridge::Unschedule() {
56 JNIEnv* env = base::android::AttachCurrentThread(); 53 JNIEnv* env = base::android::AttachCurrentThread();
57 Java_BackgroundSchedulerBridge_unschedule(env); 54 Java_BackgroundSchedulerBridge_unschedule(env);
58 } 55 }
59 56
60 bool RegisterBackgroundSchedulerBridge(JNIEnv* env) { 57 bool RegisterBackgroundSchedulerBridge(JNIEnv* env) {
61 return RegisterNativesImpl(env); 58 return RegisterNativesImpl(env);
62 } 59 }
63 60
64 } // namespace android 61 } // namespace android
65 } // namespace offline_pages 62 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698