New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 767522 link

Starred by 1 user

Issue metadata

Status: Untriaged
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

NativeBackgroundTask's TaskFinishedCallback API is confusing/ambiguous

Project Member Reported by dewittj@chromium.org, Sep 21 2017

Issue description

In NativeBackgroundTask, we have the following abstract methods that clients override: 

    @StartBeforeNativeResult
    protected abstract int onStartTaskBeforeNativeLoaded(
            Context context, TaskParameters taskParameters, TaskFinishedCallback callback);
    protected abstract void onStartTaskWithNative(
            Context context, TaskParameters taskParameters, TaskFinishedCallback callback);

Confusingly, |callback| is different across the two calls, and if I read the code correctly,
|callback| should not be saved after onStartTaskBeforeNativeLoaded.  This is because in
NativeBackgroundTask#onStartTask, we call NativeBackgroundTask#onStartTaskBeforeNativeLoaded
using the raw |callback| passed in from the scheduler.  It is not wrapped in
NativeBackgroundTask#buildRescheduleRunable.

It seems to me that there should be one or more changes related to this:
* Add a StartBeforeNativeResult named DEFER that makes |callback| sensible in the before
  native case.  Then clients would save callback and call it when beforeNative processing
  finishes.  |Callback| would be a different type, since it should be called with a
  StartBeforeNativeResult.
* Stop passing |callback| into onStartTaskBeforeNativeLoaded. Clients should save the callback
  passed into onStartTaskWithNative.
* Make |callback| the same object in both APIs, so it doesn't matter which is saved by clients.
 

Sign in to add a comment