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_IPC_BASIC_TYPES_H_
18 #define INCLUDE_PERFETTO_EXT_IPC_BASIC_TYPES_H_
19 
20 #include <stddef.h>
21 #include <stdint.h>
22 #include <sys/types.h>
23 
24 #include "perfetto/ext/base/utils.h"
25 #include "perfetto/protozero/cpp_message_obj.h"
26 
27 namespace perfetto {
28 namespace ipc {
29 
30 using ProtoMessage = ::protozero::CppMessageObj;
31 using ServiceID = uint32_t;
32 using MethodID = uint32_t;
33 using ClientID = uint64_t;
34 using RequestID = uint64_t;
35 
36 #if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
37 // AF_UNIX on Windows is supported only on Windows 10 from build 17063.
38 // Also it doesn't bring major advantages compared to a TCP socket.
39 // See go/perfetto-win .
40 constexpr bool kUseTCPSocket = true;
41 #else
42 // On Android, Linux, Mac use a AF_UNIX socket.
43 constexpr bool kUseTCPSocket = false;
44 #endif
45 
46 // This determines the maximum size allowed for an IPC message. Trying to send
47 // or receive a larger message will hit DCHECK(s) and auto-disconnect.
48 constexpr size_t kIPCBufferSize = 128 * 1024;
49 
50 constexpr uid_t kInvalidUid = static_cast<uid_t>(-1);
51 
52 }  // namespace ipc
53 }  // namespace perfetto
54 
55 #endif  // INCLUDE_PERFETTO_EXT_IPC_BASIC_TYPES_H_
56