@Override
  public void addCallbacks(ProducerContextCallbacks callbacks) {
    boolean cancelImmediately = false;
    synchronized (this) {
      mCallbacks.add(callbacks);
      if (mIsCancelled) {
        cancelImmediately = true;
      }
    }

    if (cancelImmediately) {
      callbacks.onCancellationRequested();
    }
  }
ProducerContext that can be cancelled. Exposes low level API to manipulate state of the
ProducerContext.
imagepipeline/src/main/java/com/facebook/imagepipeline/producers/BaseProducerContext.java