1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef REMOTE_EXECUTOR_STUB_H 17 #define REMOTE_EXECUTOR_STUB_H 18 19 #include <optional> 20 21 #include "attributes.h" 22 #include "co_auth_client_defines.h" 23 #include "iexecutor_callback.h" 24 #include "hisysevent_adapter.h" 25 #include "nocopyable.h" 26 #include "remote_connect_manager.h" 27 #include "schedule_node.h" 28 29 namespace OHOS { 30 namespace UserIam { 31 namespace UserAuth { 32 class RemoteExecutorStub : public std::enable_shared_from_this<RemoteExecutorStub> { 33 public: 34 public: 35 RemoteExecutorStub(); 36 virtual ~RemoteExecutorStub(); 37 38 // ConnectionListener 39 void OnMessage(const std::string &connectionName, const std::string &srcEndPoint, 40 const std::shared_ptr<Attributes> &request, std::shared_ptr<Attributes> &reply); 41 42 // ScheduleNode 43 int32_t OnMessage(ExecutorRole dstRole, const std::vector<uint8_t> &msg); 44 int32_t ContinueSchedule(ResultCode resultCode, const std::shared_ptr<Attributes> &finalResult); 45 46 // IExecutorCallback 47 int32_t ProcBeginExecuteRequest(Attributes &attr, RemoteExecuteTrace &trace); 48 49 private: 50 int32_t ProcSendDataMsg(Attributes &attr); 51 52 std::recursive_mutex mutex_; 53 std::shared_ptr<ConnectionListener> connectionCallback_ = nullptr; 54 std::shared_ptr<ScheduleNode> remoteScheduleNode_ = nullptr; 55 uint64_t executorIndex_ = 0; 56 std::string connectionName_ = ""; 57 std::string endPointName_ = ""; 58 std::optional<uint64_t> contextId_ = std::nullopt; 59 }; 60 } // namespace UserAuth 61 } // namespace UserIam 62 } // namespace OHOS 63 #endif // REMOTE_EXECUTOR_STUB_H