@@ -0,0 +1,2137 @@
+// Copyright (C) 2021 The Android Open Source Project%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A// http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A%0Apackage com.google.gerrit.server.cancellation;%0A%0Aimport com.google.gerrit.common.Nullable;%0A%0A/** Interface that provides information about the state of the current request. */%0Apublic interface RequestStateProvider %7B%0A  /**%0A   * Checks whether the current request is cancelled.%0A   *%0A   * %3Cp%3EInvoked by Gerrit to check whether the current request is cancelled and should be aborted.%0A   *%0A   * %3Cp%3EIf the current request is cancelled %7B@link OnCancelled#onCancel(Reason, String)%7D is invoked%0A   * on the provided callback.%0A   *%0A   * @param onCancelled callback that should be invoked if the request is cancelled%0A   */%0A  void checkIfCancelled(OnCancelled onCancelled);%0A%0A  /** Callback interface to be invoked if a request is cancelled. */%0A  interface OnCancelled %7B%0A    /**%0A     * Callback that is invoked if the request is cancelled.%0A     *%0A     * @param reason the reason for the cancellation of the request%0A     * @param message an optional message providing details about the cancellation%0A     */%0A    void onCancel(Reason reason, @Nullable String message);%0A  %7D%0A%0A  /** Reason why a request is cancelled. */%0A  enum Reason %7B%0A    /** The client got disconnected or has cancelled the request. */%0A    CLIENT_CLOSED_REQUEST,%0A%0A    /** The deadline that the client provided for the request exceeded. */%0A    CLIENT_PROVIDED_DEADLINE_EXCEEDED,%0A%0A    /**%0A     * A server-side deadline for the request exceeded.%0A     *%0A     * %3Cp%3EServer-side deadlines are usually configurable, but may also be hard-coded.%0A     */%0A    SERVER_DEADLINE_EXCEEDED;%0A  %7D%0A%7D%0A

Add interface that allows Gerrit to check whether a request is cancelled