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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: components/background_task_scheduler/android/java/src/org/chromium/components/background_task_scheduler/TaskParameters.java
diff --git a/components/background_task_scheduler/android/java/src/org/chromium/components/background_task_scheduler/TaskParameters.java b/components/background_task_scheduler/android/java/src/org/chromium/components/background_task_scheduler/TaskParameters.java
new file mode 100644
index 0000000000000000000000000000000000000000..f389e1e5bd8a8cec21f959ca9c9ec11d0634de55
--- /dev/null
+++ b/components/background_task_scheduler/android/java/src/org/chromium/components/background_task_scheduler/TaskParameters.java
@@ -0,0 +1,61 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.components.background_task_scheduler;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+
+/**
+ * TaskParameters are passed to {@link BackgroundTask}s whenever they are invoked. It contains the
+ * task ID and the extras that the caller of
+ * {@link BackgroundTaskScheduler#schedule(Context, TaskInfo)} passed in with the {@link TaskInfo}.
+ */
+public class TaskParameters {
+ private final int mTaskId;
+ private final Bundle mExtras;
+
+ private TaskParameters(Builder builder) {
+ mTaskId = builder.mTaskId;
+ mExtras = builder.mExtras == null ? new Bundle() : builder.mExtras;
+ }
+
+ /**
+ * @return the task ID.
+ */
+ public int getTaskId() {
+ return mTaskId;
+ }
+
+ /**
+ * @return the extras for this task.
+ */
+ @NonNull
+ public Bundle getExtras() {
+ return mExtras;
+ }
+
+ static Builder create(int taskId) {
+ return new Builder(taskId);
+ }
+
+ static final class Builder {
+ private final int mTaskId;
+ private Bundle mExtras;
+
+ Builder(int taskId) {
+ mTaskId = taskId;
+ }
+
+ Builder addExtras(Bundle extras) {
+ mExtras = extras;
+ return this;
+ }
+
+ TaskParameters build() {
+ return new TaskParameters(this);
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698