• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CONSUMER_IPC_CLIENT_H_
18 #define INCLUDE_PERFETTO_TRACING_IPC_CONSUMER_IPC_CLIENT_H_
19 
20 #include <memory>
21 #include <string>
22 
23 #include "perfetto/tracing/core/tracing_service.h"
24 
25 namespace perfetto {
26 
27 class Consumer;
28 
29 // Allows to connect to a remote Service through a UNIX domain socket.
30 // Exposed to:
31 //   Consumer(s) of the tracing library.
32 // Implemented in:
33 //   src/tracing/ipc/consumer/consumer_ipc_client_impl.cc
34 class ConsumerIPCClient {
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 Consumer interface.
39   // If the connection fails, OnDisconnect() will be invoked instead.
40   // The returned ConsumerEndpoint serves also to delimit the scope of the
41   // callbacks invoked on the Consumer interface: no more Consumer callbacks are
42   // invoked immediately after its destruction and any pending callback will be
43   // dropped.
44   static std::unique_ptr<TracingService::ConsumerEndpoint>
45   Connect(const char* service_sock_name, Consumer*, base::TaskRunner*);
46 
47  protected:
48   ConsumerIPCClient() = delete;
49 };
50 
51 }  // namespace perfetto
52 
53 #endif  // INCLUDE_PERFETTO_TRACING_IPC_CONSUMER_IPC_CLIENT_H_
54