| 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);
|
| + }
|
| + }
|
| +}
|
|
|