/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package perfetto.protos;

// This metric provides information about the monitor contention graph in a
// trace
message AndroidMonitorContentionMetric {
  // Next field id: 26
  message Node {
    // Global context
    optional int64 node_parent_id = 1;
    optional int64 node_child_id = 24;
    optional int64 node_id = 2;
    optional int64 ts = 3;
    optional int64 dur = 4;
    optional int64 monotonic_dur = 25;
    optional string process_name = 14;
    optional uint32 pid = 23;
    optional uint32 waiter_count = 11;
    repeated ThreadStateBreakdown thread_states = 19;
    repeated BlockedFunctionBreakdown blocked_functions = 20;

    // Blocking context
    optional string blocking_method = 5;
    optional string short_blocking_method = 7;
    optional string blocking_src = 9;
    optional string blocking_thread_name = 13;
    optional bool is_blocking_thread_main = 16;
    optional uint32 blocking_thread_tid = 22;

    // Blocked context
    optional string blocked_method = 6;
    optional string short_blocked_method = 8;
    optional string blocked_src = 10;
    optional string blocked_thread_name = 12;
    optional bool is_blocked_thread_main = 15;
    optional uint32 blocked_thread_tid = 21;

    // Binder context
    optional int64 binder_reply_ts = 17;
    optional uint32 binder_reply_tid = 18;
  }

  message ThreadStateBreakdown {
    optional string thread_state = 1;
    optional int64 thread_state_dur = 2;
    optional int64 thread_state_count = 3;
  }

  message BlockedFunctionBreakdown {
    optional string blocked_function = 1;
    optional int64 blocked_function_dur = 2;
    optional int64 blocked_function_count = 3;
  }

  repeated Node node = 1;
}
