• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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_TRACE_PROCESSOR_EXPORT_JSON_H_
18 #define INCLUDE_PERFETTO_EXT_TRACE_PROCESSOR_EXPORT_JSON_H_
19 
20 #include <stdio.h>
21 
22 #include <functional>
23 
24 #include "perfetto/base/export.h"
25 #include "perfetto/trace_processor/status.h"
26 
27 namespace perfetto {
28 namespace trace_processor {
29 
30 class TraceProcessorStorage;
31 
32 namespace json {
33 
34 using ArgumentNameFilterPredicate = std::function<bool(const char* arg_name)>;
35 using ArgumentFilterPredicate =
36     std::function<bool(const char* category_group_name,
37                        const char* event_name,
38                        ArgumentNameFilterPredicate*)>;
39 using MetadataFilterPredicate = std::function<bool(const char* metadata_name)>;
40 using LabelFilterPredicate = std::function<bool(const char* label_name)>;
41 
42 class PERFETTO_EXPORT OutputWriter {
43  public:
44   OutputWriter();
45   virtual ~OutputWriter();
46 
47   virtual util::Status AppendString(const std::string&) = 0;
48 };
49 
50 // Public for Chrome. Exports the trace loaded in TraceProcessorStorage to json,
51 // applying argument, metadata and label filtering using the callbacks.
52 util::Status PERFETTO_EXPORT ExportJson(TraceProcessorStorage*,
53                                         OutputWriter*,
54                                         ArgumentFilterPredicate = nullptr,
55                                         MetadataFilterPredicate = nullptr,
56                                         LabelFilterPredicate = nullptr);
57 
58 }  // namespace json
59 }  // namespace trace_processor
60 }  // namespace perfetto
61 
62 #endif  // INCLUDE_PERFETTO_EXT_TRACE_PROCESSOR_EXPORT_JSON_H_
63