• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2018 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// Use proto3 syntax as an optimization. The difference is that proto2 stores
18// unknown fields seen while decoding in an internal buffer (std::string) while
19// proto3 completely drops them. Since during validation we only need to check
20// for the presence of the trusted fields below, we can use proto3 as a way to
21// speed up this process.
22//
23// See https://developers.google.com/protocol-buffers/docs/proto3#unknowns and
24// https://android-review.googlesource.com/c/platform/external/perfetto/+/
25// 591673#17 for details.
26syntax = "proto3";
27option optimize_for = LITE_RUNTIME;
28
29import "perfetto/common/trace_stats.proto";
30import "perfetto/config/trace_config.proto";
31import "perfetto/trace/clock_snapshot.proto";
32import "perfetto/trace/system_info.proto";
33import "perfetto/trace/trigger.proto";
34
35package perfetto.protos;
36
37// This proto contains trusted fields of TracePacket which may only be generated
38// by the service (as opposed to the untrusted producers). Note that the field
39// ids here must be kept in sync with TracePacket.
40// This protobuf serves two purposes:
41// 1. Security validation of packets (see packet_stream_validator.cc)
42// 2. Avoid bloating the service binary with symbols for all possible trace
43//    protos. The service doesn't really care about all the protos in the trace,
44//    is just passes them through.
45message TrustedPacket {
46  // User id of the producer which generated this packet.
47  // The oneof boilerplate here is required to tell the difference between
48  // uid == 0 and uid not set (the writer uses proto2).
49  oneof optional_trusted_uid { int32 trusted_uid = 3; };
50
51  oneof optional_trusted_packet_sequence_id {
52    uint32 trusted_packet_sequence_id = 10;
53  }
54
55  ClockSnapshot clock_snapshot = 6;
56  uint64 timestamp = 8;
57  TraceConfig trace_config = 33;
58  TraceStats trace_stats = 35;
59  bytes synchronization_marker = 36;
60  bool previous_packet_dropped = 42;
61  SystemInfo system_info = 45;
62  Trigger trigger = 46;
63}
64