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

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

Issue 2030773002: Add unit tests for the Background Scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR fixes per BauerB 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/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);
Bernhard Bauer 2016/06/07 08:43:42 Wait, does this work when |j_callback_obj| is a Pr
Pete Williamson 2016/06/07 22:04:12 Ah, good catch. I was thinking that since the arg
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698