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