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 #include "fcp/secagg/client/secagg_client_aborted_state.h"
18
19 #include <memory>
20 #include <string>
21 #include <utility>
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
SecAggClientAbortedState(const std::string & reason,std::unique_ptr<SendToServerInterface> sender,std::unique_ptr<StateTransitionListenerInterface> transition_listener)30 SecAggClientAbortedState::SecAggClientAbortedState(
31 const std::string& reason, std::unique_ptr<SendToServerInterface> sender,
32 std::unique_ptr<StateTransitionListenerInterface> transition_listener)
33 : SecAggClientState(std::move(sender), std::move(transition_listener),
34 ClientState::ABORTED),
35 reason_(reason) {
36 FCP_LOG(WARNING) << "Aborting for reason: " << reason_;
37 }
38
39 SecAggClientAbortedState::~SecAggClientAbortedState() = default;
40
IsAborted() const41 bool SecAggClientAbortedState::IsAborted() const { return true; }
42
ErrorMessage() const43 StatusOr<std::string> SecAggClientAbortedState::ErrorMessage() const {
44 return reason_;
45 }
46
StateName() const47 std::string SecAggClientAbortedState::StateName() const { return "ABORTED"; }
48
49 } // namespace secagg
50 } // namespace fcp
51