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

Side by Side Diff: components/background_task_scheduler/android/java/src/org/chromium/components/background_task_scheduler/BackgroundTaskScheduler.java

Issue 2779753002: [Android] Adding scheduling through GcmNetworkManager (Closed)
Patch Set: Ensuring task is called on UI thread Created 3 years, 7 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 package org.chromium.components.background_task_scheduler; 5 package org.chromium.components.background_task_scheduler;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.content.Context; 8 import android.content.Context;
9 import android.os.Build; 9 import android.os.Build;
10 import android.support.annotation.Nullable; 10 import android.support.annotation.Nullable;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 * Schedules a background task. See {@link TaskInfo} for information on what types of tasks that 68 * Schedules a background task. See {@link TaskInfo} for information on what types of tasks that
69 * can be scheduled. 69 * can be scheduled.
70 * 70 *
71 * @param context the current context. 71 * @param context the current context.
72 * @param taskInfo the information about the task to be scheduled. 72 * @param taskInfo the information about the task to be scheduled.
73 * @return true if the schedule operation succeeded, and false otherwise. 73 * @return true if the schedule operation succeeded, and false otherwise.
74 * @see TaskInfo 74 * @see TaskInfo
75 */ 75 */
76 public boolean schedule(Context context, TaskInfo taskInfo) { 76 public boolean schedule(Context context, TaskInfo taskInfo) {
77 ThreadUtils.assertOnUiThread(); 77 ThreadUtils.assertOnUiThread();
78 BackgroundTaskSchedulerPrefs.addScheduledTask(taskInfo);
78 return mSchedulerDelegate.schedule(context, taskInfo); 79 return mSchedulerDelegate.schedule(context, taskInfo);
79 } 80 }
80 81
81 /** 82 /**
82 * Cancels the task specified by the task ID. 83 * Cancels the task specified by the task ID.
83 * 84 *
84 * @param context the current context. 85 * @param context the current context.
85 * @param taskId the ID of the task to cancel. See {@link TaskIds} for a lis t. 86 * @param taskId the ID of the task to cancel. See {@link TaskIds} for a lis t.
86 */ 87 */
87 public void cancel(Context context, int taskId) { 88 public void cancel(Context context, int taskId) {
88 ThreadUtils.assertOnUiThread(); 89 ThreadUtils.assertOnUiThread();
90 BackgroundTaskSchedulerPrefs.removeScheduledTask(taskId);
89 mSchedulerDelegate.cancel(context, taskId); 91 mSchedulerDelegate.cancel(context, taskId);
90 } 92 }
91 } 93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698