xref: /aosp_15_r20/external/federated-compute/fcp/secagg/client/secagg_client_aborted_state.h (revision 14675a029014e728ec732f129a32e299b2da0601)
1 /*
2  * Copyright 2018 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef FCP_SECAGG_CLIENT_SECAGG_CLIENT_ABORTED_STATE_H_
18 #define FCP_SECAGG_CLIENT_SECAGG_CLIENT_ABORTED_STATE_H_
19 
20 #include <memory>
21 #include <string>
22 
23 #include "fcp/base/monitoring.h"
24 #include "fcp/secagg/client/secagg_client_state.h"
25 #include "fcp/secagg/client/state_transition_listener_interface.h"
26 
27 namespace fcp {
28 namespace secagg {
29 
30 // This class represents the abort state for a client. There are no transitions
31 // out of this state. A new SecAggClient object will be needed to start a new
32 // run of the protocol.
33 
34 class SecAggClientAbortedState : public SecAggClientState {
35  public:
36   SecAggClientAbortedState(
37       const std::string& reason, std::unique_ptr<SendToServerInterface> sender,
38       std::unique_ptr<StateTransitionListenerInterface> transition_listener);
39 
40   ~SecAggClientAbortedState() override;
41 
42   // Returns true from this state.
43   bool IsAborted() const override;
44 
45   // Returns the error message with which the client aborted.
46   StatusOr<std::string> ErrorMessage() const override;
47 
48   // Returns the name of this state, "ABORTED".
49   std::string StateName() const override;
50 
51  private:
52   const std::string reason_;
53 };
54 
55 }  // namespace secagg
56 }  // namespace fcp
57 
58 #endif  // FCP_SECAGG_CLIENT_SECAGG_CLIENT_ABORTED_STATE_H_
59