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 #pragma once 18 19 #include "TracingVM.grpc.pb.h" 20 #include "TracingVM.pb.h" 21 22 #include <grpc++/grpc++.h> 23 24 #include <atomic> 25 #include <memory> 26 #include <string> 27 28 namespace android::tools::automotive::tracing { 29 30 class TracingServerImpl : public tracing_vm_proto::TracingServer::Service { 31 public: 32 TracingServerImpl(const std::string& addr); 33 34 grpc::Status StartTracing(::grpc::ServerContext* context, 35 const tracing_vm_proto::StartTracingRequest* request, 36 tracing_vm_proto::RequestStatus* request_status); 37 38 grpc::Status StopTracing(::grpc::ServerContext* context, 39 const tracing_vm_proto::TracingSessionIdentifier* session_id, 40 tracing_vm_proto::RequestStatus* request_status); 41 42 grpc::Status GetTracingFile(::grpc::ServerContext* context, 43 const tracing_vm_proto::TracingSessionIdentifier* session_id, 44 ::grpc::ServerWriter<tracing_vm_proto::TracingFileBuffer>* stream); 45 void Start(); 46 47 private: 48 std::atomic_uint64_t mSessionId = 1; 49 std::string mServiceAddr; 50 std::unique_ptr<::grpc::Server> mGrpcServer; 51 }; 52 53 } // namespace android::tools::automotive::tracing 54