• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {}
27
28export type ConsumerPortResponse =
29    EnableTracingResponse|ReadBuffersResponse|GetTraceStatsResponse;
30
31export function isConsumerPortResponse(obj: Typed):
32    obj is ConsumerPortResponse {
33  return isReadBuffersResponse(obj) || isEnableTracingResponse(obj) ||
34      isGetTraceStatsResponse(obj);
35}
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}