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

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

Issue 2714463002: [android] Add JobScheduler-based BackgroundTaskScheduler. (Closed)
Patch Set: FindBugs wants the real Pi, but I won't give it. Created 3 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.components.background_task_scheduler;
6
7 import android.content.Context;
8 import android.os.Bundle;
9 import android.support.annotation.NonNull;
10
11 /**
12 * TaskParameters are passed to {@link BackgroundTask}s whenever they are invoke d. It contains the
13 * task ID and the extras that the caller of
14 * {@link BackgroundTaskScheduler#schedule(Context, TaskInfo)} passed in with th e {@link TaskInfo}.
15 */
16 public class TaskParameters {
17 private final int mTaskId;
18 private final Bundle mExtras;
19
20 private TaskParameters(Builder builder) {
21 mTaskId = builder.mTaskId;
22 mExtras = builder.mExtras == null ? new Bundle() : builder.mExtras;
23 }
24
25 /**
26 * @return the task ID.
27 */
28 public int getTaskId() {
29 return mTaskId;
30 }
31
32 /**
33 * @return the extras for this task.
34 */
35 @NonNull
36 public Bundle getExtras() {
37 return mExtras;
38 }
39
40 static Builder create(int taskId) {
41 return new Builder(taskId);
42 }
43
44 static final class Builder {
45 private final int mTaskId;
46 private Bundle mExtras;
47
48 Builder(int taskId) {
49 mTaskId = taskId;
50 }
51
52 Builder addExtras(Bundle extras) {
53 mExtras = extras;
54 return this;
55 }
56
57 TaskParameters build() {
58 return new TaskParameters(this);
59 }
60 }
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698