Commit 1dc99fe0 authored by Sky Malice's avatar Sky Malice Committed by Commit Bot

[Feed] When rescheduling, just set period to 1 day instead of going to

native.

Bug: 901331
Change-Id: I65b3d748cb96669fa78a712552f82a44873debf3
Reviewed-on: https://chromium-review.googlesource.com/c/1315929
Commit-Queue: Sky Malice <skym@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606873}
parent 4e05b6f1
......@@ -15,6 +15,8 @@ import org.chromium.components.background_task_scheduler.TaskIds;
import org.chromium.components.background_task_scheduler.TaskInfo;
import org.chromium.components.background_task_scheduler.TaskParameters;
import java.util.concurrent.TimeUnit;
/**
* A task implementation that loads native and then tries to refresh the Feed's articles. Failures
* or interruptions are not retried or rescheduled.
......@@ -89,11 +91,10 @@ public class FeedRefreshTask extends NativeBackgroundTask {
@Override
public void reschedule(Context context) {
ThreadUtils.runOnUiThread(() -> {
FeedScheduler scheduler = FeedProcessScopeFactory.getFeedScheduler();
if (scheduler != null) {
scheduler.onTaskReschedule();
}
});
// The user may be trying to do something other than use Chrome right now, so we want to be
// as light weight as possible. Instead of going to native to reschedule with a more
// informed threshold, just schedule for 1 day from now. The next time a successful fetch
// occurs, this value will be set to a value tailored to current usage patterns.
ThreadUtils.runOnUiThread(() -> scheduleWakeUp(TimeUnit.DAYS.toMillis(1)));
}
}
......@@ -20,9 +20,6 @@ public interface FeedScheduler extends SchedulerApi {
/** To be called when a background scheduling task wakes up the browser. */
void onFixedTimer(Runnable onCompletion);
/** To be called when a background scheduling task needs to be rescheduled. */
void onTaskReschedule();
/** To be called when an article is consumed, influencing future scheduling. */
void onSuggestionConsumed();
}
......@@ -116,12 +116,6 @@ public class FeedSchedulerBridge implements FeedScheduler {
nativeOnFixedTimer(mNativeBridge, (Void ignored) -> onCompletion.run());
}
@Override
public void onTaskReschedule() {
assert mNativeBridge != 0;
nativeOnTaskReschedule(mNativeBridge);
}
@Override
public void onSuggestionConsumed() {
assert mNativeBridge != 0;
......@@ -158,6 +152,5 @@ public class FeedSchedulerBridge implements FeedScheduler {
private native void nativeOnForegrounded(long nativeFeedSchedulerBridge);
private native void nativeOnFixedTimer(
long nativeFeedSchedulerBridge, Callback<Void> onCompletion);
private native void nativeOnTaskReschedule(long nativeFeedSchedulerBridge);
private native void nativeOnSuggestionConsumed(long nativeFeedSchedulerBridge);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment