1 // 2 // Copyright (C) 2022 The Android Open Source Project 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 #pragma once 17 18 #include <vector> 19 20 #include <fruit/fruit.h> 21 22 #include "common/libs/fs/shared_fd.h" 23 #include "cvd_server.pb.h" 24 #include "host/commands/cvd/server_client.h" 25 #include "host/commands/cvd/server_command/server_handler.h" 26 #include "host/libs/config/inject.h" 27 28 namespace cuttlefish { 29 30 class CommandSequenceExecutor : public LateInjected { 31 public: 32 INJECT(CommandSequenceExecutor()); 33 34 Result<void> LateInject(fruit::Injector<>&) override; 35 36 Result<void> Interrupt(); 37 Result<std::vector<cvd::Response>> Execute( 38 const std::vector<RequestWithStdio>&, SharedFD report); 39 Result<cvd::Response> ExecuteOne(const RequestWithStdio&, SharedFD report); 40 41 std::vector<std::string> CmdList() const; 42 43 private: 44 std::vector<CvdServerHandler*> server_handlers_; 45 std::vector<CvdServerHandler*> handler_stack_; 46 std::mutex interrupt_mutex_; 47 bool interrupted_ = false; 48 }; 49 50 fruit::Component<CommandSequenceExecutor> CommandSequenceExecutorComponent(); 51 52 } // namespace cuttlefish 53