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.