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

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

Issue 2400393002: Set up a backup schedule request if we have deferred requests. (Closed)
Patch Set: CR feedback per Dimich Created 4 years, 2 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/callback_android.h"
6 #include "base/android/scoped_java_ref.h" 6 #include "base/android/scoped_java_ref.h"
7 #include "chrome/browser/android/offline_pages/background_scheduler_bridge.h" 7 #include "chrome/browser/android/offline_pages/background_scheduler_bridge.h"
8 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 8 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
9 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" 9 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void BackgroundSchedulerBridge::Schedule( 58 void BackgroundSchedulerBridge::Schedule(
59 const TriggerConditions& trigger_conditions) { 59 const TriggerConditions& trigger_conditions) {
60 JNIEnv* env = base::android::AttachCurrentThread(); 60 JNIEnv* env = base::android::AttachCurrentThread();
61 ScopedJavaLocalRef<jobject> j_conditions = 61 ScopedJavaLocalRef<jobject> j_conditions =
62 CreateTriggerConditions(env, trigger_conditions.require_power_connected, 62 CreateTriggerConditions(env, trigger_conditions.require_power_connected,
63 trigger_conditions.minimum_battery_percentage, 63 trigger_conditions.minimum_battery_percentage,
64 trigger_conditions.require_unmetered_network); 64 trigger_conditions.require_unmetered_network);
65 Java_BackgroundSchedulerBridge_schedule(env, j_conditions); 65 Java_BackgroundSchedulerBridge_schedule(env, j_conditions);
66 } 66 }
67 67
68 void BackgroundSchedulerBridge::BackupSchedule(
69 const TriggerConditions& trigger_conditions, long delay_in_seconds) {
70 JNIEnv* env = base::android::AttachCurrentThread();
71 ScopedJavaLocalRef<jobject> j_conditions =
72 CreateTriggerConditions(env, trigger_conditions.require_power_connected,
73 trigger_conditions.minimum_battery_percentage,
74 trigger_conditions.require_unmetered_network);
75 Java_BackgroundSchedulerBridge_backupSchedule(
76 env, j_conditions, delay_in_seconds);
77 }
78
68 void BackgroundSchedulerBridge::Unschedule() { 79 void BackgroundSchedulerBridge::Unschedule() {
69 JNIEnv* env = base::android::AttachCurrentThread(); 80 JNIEnv* env = base::android::AttachCurrentThread();
70 Java_BackgroundSchedulerBridge_unschedule(env); 81 Java_BackgroundSchedulerBridge_unschedule(env);
71 } 82 }
72 83
73 ScopedJavaLocalRef<jobject> BackgroundSchedulerBridge::CreateTriggerConditions( 84 ScopedJavaLocalRef<jobject> BackgroundSchedulerBridge::CreateTriggerConditions(
74 JNIEnv* env, 85 JNIEnv* env,
75 bool require_power_connected, 86 bool require_power_connected,
76 int minimum_battery_percentage, 87 int minimum_battery_percentage,
77 bool require_unmetered_network) const { 88 bool require_unmetered_network) const {
78 return Java_BackgroundSchedulerBridge_createTriggerConditions( 89 return Java_BackgroundSchedulerBridge_createTriggerConditions(
79 env, require_power_connected, minimum_battery_percentage, 90 env, require_power_connected, minimum_battery_percentage,
80 require_unmetered_network); 91 require_unmetered_network);
81 } 92 }
82 93
83 bool RegisterBackgroundSchedulerBridge(JNIEnv* env) { 94 bool RegisterBackgroundSchedulerBridge(JNIEnv* env) {
84 return RegisterNativesImpl(env); 95 return RegisterNativesImpl(env);
85 } 96 }
86 97
87 } // namespace android 98 } // namespace android
88 } // namespace offline_pages 99 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698