1 /* 2 * Copyright (C) 2017 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 INCLUDE_PERFETTO_EXT_TRACING_IPC_CONSUMER_IPC_CLIENT_H_ 18 #define INCLUDE_PERFETTO_EXT_TRACING_IPC_CONSUMER_IPC_CLIENT_H_ 19 20 #include <memory> 21 #include <string> 22 23 #include "perfetto/base/export.h" 24 #include "perfetto/ext/tracing/core/tracing_service.h" 25 26 namespace perfetto { 27 28 class Consumer; 29 30 // Allows to connect to a remote Service through a UNIX domain socket. 31 // Exposed to: 32 // Consumer(s) of the tracing library. 33 // Implemented in: 34 // src/tracing/ipc/consumer/consumer_ipc_client_impl.cc 35 class PERFETTO_EXPORT ConsumerIPCClient { 36 public: 37 // Connects to the producer port of the Service listening on the given 38 // |service_sock_name|. If the connection is successful, the OnConnect() 39 // method will be invoked asynchronously on the passed Consumer interface. 40 // If the connection fails, OnDisconnect() will be invoked instead. 41 // The returned ConsumerEndpoint serves also to delimit the scope of the 42 // callbacks invoked on the Consumer interface: no more Consumer callbacks are 43 // invoked immediately after its destruction and any pending callback will be 44 // dropped. 45 static std::unique_ptr<TracingService::ConsumerEndpoint> 46 Connect(const char* service_sock_name, Consumer*, base::TaskRunner*); 47 48 protected: 49 ConsumerIPCClient() = delete; 50 }; 51 52 } // namespace perfetto 53 54 #endif // INCLUDE_PERFETTO_EXT_TRACING_IPC_CONSUMER_IPC_CLIENT_H_ 55