1// Copyright (C) 2019 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15import {perfetto} from '../gen/protos'; 16 17export interface Typed { 18 type: string; 19} 20 21export interface ReadBuffersResponse extends 22 Typed, perfetto.protos.IReadBuffersResponse {} 23export interface EnableTracingResponse extends 24 Typed, perfetto.protos.IEnableTracingResponse {} 25export interface GetTraceStatsResponse extends 26 Typed, perfetto.protos.IGetTraceStatsResponse {} 27export interface FreeBuffersResponse extends 28 Typed, perfetto.protos.IFreeBuffersResponse {} 29export interface GetCategoriesResponse extends Typed {} 30export interface DisableTracingResponse extends 31 Typed, perfetto.protos.IDisableTracingResponse {} 32 33export type ConsumerPortResponse = 34 EnableTracingResponse|ReadBuffersResponse|GetTraceStatsResponse| 35 GetCategoriesResponse|FreeBuffersResponse|DisableTracingResponse; 36 37export function isReadBuffersResponse(obj: Typed): obj is ReadBuffersResponse { 38 return obj.type === 'ReadBuffersResponse'; 39} 40 41export function isEnableTracingResponse(obj: Typed): 42 obj is EnableTracingResponse { 43 return obj.type === 'EnableTracingResponse'; 44} 45 46export function isGetTraceStatsResponse(obj: Typed): 47 obj is GetTraceStatsResponse { 48 return obj.type === 'GetTraceStatsResponse'; 49} 50 51export function isGetCategoriesResponse(obj: Typed): 52 obj is GetCategoriesResponse { 53 return obj.type === 'GetCategoriesResponse'; 54} 55 56export function isFreeBuffersResponse(obj: Typed): obj is FreeBuffersResponse { 57 return obj.type === 'FreeBuffersResponse'; 58} 59 60export function isDisableTracingResponse(obj: Typed): 61 obj is DisableTracingResponse { 62 return obj.type === 'DisableTracingResponse'; 63} 64