xref: /aosp_15_r20/external/perfetto/src/trace_processor/importers/perf/aux_data_tokenizer.cc (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1 /*
2  * Copyright (C) 2024 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 #include "src/trace_processor/importers/perf/aux_data_tokenizer.h"
18 
19 #include <cstdint>
20 #include <memory>
21 
22 #include "perfetto/base/status.h"
23 #include "perfetto/trace_processor/trace_blob_view.h"
24 #include "src/trace_processor/importers/perf/aux_record.h"
25 #include "src/trace_processor/importers/perf/itrace_start_record.h"
26 #include "src/trace_processor/storage/stats.h"
27 #include "src/trace_processor/storage/trace_storage.h"
28 #include "src/trace_processor/types/trace_processor_context.h"
29 
30 namespace perfetto::trace_processor::perf_importer {
31 
32 AuxDataTokenizer::~AuxDataTokenizer() = default;
33 AuxDataStream::~AuxDataStream() = default;
34 
DummyAuxDataTokenizer(TraceProcessorContext * context)35 DummyAuxDataTokenizer::DummyAuxDataTokenizer(TraceProcessorContext* context)
36     : stream_(context) {}
37 
38 DummyAuxDataTokenizer::~DummyAuxDataTokenizer() = default;
39 
InitializeAuxDataStream(AuxStream *)40 base::StatusOr<AuxDataStream*> DummyAuxDataTokenizer::InitializeAuxDataStream(
41     AuxStream*) {
42   return &stream_;
43 }
44 
DummyAuxDataStream(TraceProcessorContext * context)45 DummyAuxDataStream::DummyAuxDataStream(TraceProcessorContext* context)
46     : context_(context) {}
OnDataLoss(uint64_t size)47 void DummyAuxDataStream::OnDataLoss(uint64_t size) {
48   context_->storage->IncrementStats(stats::perf_aux_lost,
49                                     static_cast<int>(size));
50 }
Parse(AuxRecord,TraceBlobView data)51 base::Status DummyAuxDataStream::Parse(AuxRecord, TraceBlobView data) {
52   context_->storage->IncrementStats(stats::perf_aux_ignored,
53                                     static_cast<int>(data.size()));
54   return base::OkStatus();
55 }
NotifyEndOfStream()56 base::Status DummyAuxDataStream::NotifyEndOfStream() {
57   return base::OkStatus();
58 }
59 
OnItraceStartRecord(ItraceStartRecord)60 base::Status DummyAuxDataStream::OnItraceStartRecord(ItraceStartRecord) {
61   return base::OkStatus();
62 }
63 
64 }  // namespace perfetto::trace_processor::perf_importer
65