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 17 #ifndef SRC_CLOUD_TRACE_PROCESSOR_WORKER_IMPL_H_ 18 #define SRC_CLOUD_TRACE_PROCESSOR_WORKER_IMPL_H_ 19 20 #include <vector> 21 22 #include "perfetto/ext/base/flat_hash_map.h" 23 #include "perfetto/ext/base/threading/thread_pool.h" 24 #include "perfetto/ext/cloud_trace_processor/environment.h" 25 #include "perfetto/ext/cloud_trace_processor/worker.h" 26 #include "src/cloud_trace_processor/trace_processor_wrapper.h" 27 28 namespace perfetto { 29 namespace protos { 30 31 enum GroupType : int; 32 33 } // namespace protos 34 } // namespace perfetto 35 36 namespace perfetto { 37 namespace cloud_trace_processor { 38 39 class WorkerImpl : public Worker { 40 public: 41 explicit WorkerImpl(CtpEnvironment*, base::ThreadPool*); 42 43 base::StatusOrFuture<protos::TracePoolShardCreateResponse> 44 TracePoolShardCreate(const protos::TracePoolShardCreateArgs&) override; 45 46 base::StatusOrStream<protos::TracePoolShardSetTracesResponse> 47 TracePoolShardSetTraces(const protos::TracePoolShardSetTracesArgs&) override; 48 49 base::StatusOrStream<protos::TracePoolShardQueryResponse> TracePoolShardQuery( 50 const protos::TracePoolShardQueryArgs&) override; 51 52 base::StatusOrFuture<protos::TracePoolShardDestroyResponse> 53 TracePoolShardDestroy(const protos::TracePoolShardDestroyArgs&) override; 54 55 private: 56 struct TracePoolShard { 57 std::vector<std::unique_ptr<TraceProcessorWrapper>> tps; 58 }; 59 CtpEnvironment* const environment_; 60 base::ThreadPool* const thread_pool_; 61 base::FlatHashMap<std::string, TracePoolShard> shards_; 62 }; 63 64 } // namespace cloud_trace_processor 65 } // namespace perfetto 66 67 #endif // SRC_CLOUD_TRACE_PROCESSOR_WORKER_IMPL_H_ 68