1 /* 2 * Copyright (C) 2023 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 17 #ifndef SRC_CLOUD_TRACE_PROCESSOR_ORCHESTRATOR_IMPL_H_ 18 #define SRC_CLOUD_TRACE_PROCESSOR_ORCHESTRATOR_IMPL_H_ 19 20 #include <memory> 21 #include <vector> 22 23 #include "perfetto/ext/base/flat_hash_map.h" 24 #include "perfetto/ext/base/threading/future.h" 25 #include "perfetto/ext/cloud_trace_processor/orchestrator.h" 26 27 namespace perfetto { 28 namespace protos { 29 class TracePoolShardCreateArgs; 30 } 31 32 namespace cloud_trace_processor { 33 34 class OrchestratorImpl : public Orchestrator { 35 public: 36 explicit OrchestratorImpl(std::vector<std::unique_ptr<Worker>> workers); 37 38 base::StatusOrStream<protos::TracePoolQueryResponse> TracePoolQuery( 39 const protos::TracePoolQueryArgs&) override; 40 41 base::StatusOrFuture<protos::TracePoolCreateResponse> TracePoolCreate( 42 const protos::TracePoolCreateArgs&) override; 43 44 base::StatusOrFuture<protos::TracePoolSetTracesResponse> TracePoolSetTraces( 45 const protos::TracePoolSetTracesArgs&) override; 46 47 base::StatusOrFuture<protos::TracePoolDestroyResponse> TracePoolDestroy( 48 const protos::TracePoolDestroyArgs&) override; 49 50 private: 51 struct TracePool { 52 std::vector<std::string> loaded_traces; 53 }; 54 std::vector<std::unique_ptr<Worker>> workers_; 55 base::FlatHashMap<std::string, TracePool> pools_; 56 }; 57 58 } // namespace cloud_trace_processor 59 } // namespace perfetto 60 61 #endif // SRC_CLOUD_TRACE_PROCESSOR_ORCHESTRATOR_IMPL_H_ 62