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_TRACE_PROCESSOR_TRACE_PROCESSOR_STORAGE_H_ 18 #define INCLUDE_PERFETTO_TRACE_PROCESSOR_TRACE_PROCESSOR_STORAGE_H_ 19 20 #include <cstdint> 21 22 #include <memory> 23 24 #include "perfetto/base/export.h" 25 #include "perfetto/base/status.h" 26 #include "perfetto/trace_processor/basic_types.h" 27 #include "perfetto/trace_processor/status.h" 28 #include "perfetto/trace_processor/trace_blob_view.h" 29 30 namespace perfetto::trace_processor { 31 32 // Coordinates the loading of traces from an arbitrary source. 33 class PERFETTO_EXPORT_COMPONENT TraceProcessorStorage { 34 public: 35 // Creates a new instance of TraceProcessorStorage. 36 static std::unique_ptr<TraceProcessorStorage> CreateInstance(const Config&); 37 38 virtual ~TraceProcessorStorage(); 39 40 // The entry point to push trace data into the processor. The trace format 41 // will be automatically discovered on the first push call. It is possible 42 // to make queries between two pushes. 43 // Returns the Ok status if parsing has been succeeding so far, and Error 44 // status if some unrecoverable error happened. If this happens, the 45 // TraceProcessor will ignore the following Parse() requests, drop data on the 46 // floor and return errors forever. 47 virtual base::Status Parse(TraceBlobView) = 0; 48 49 // Shorthand for Parse(TraceBlobView(TraceBlob(TakeOwnership(buf, size))). 50 // For compatibility with older API clients. 51 base::Status Parse(std::unique_ptr<uint8_t[]> buf, size_t size); 52 53 // Forces all data in the trace to be pushed to tables without buffering data 54 // in sorting queues. This is useful if queries need to be performed to 55 // compute post-processing data (e.g. deobfuscation, symbolization etc) which 56 // will be appended to the trace in a future call to Parse. 57 virtual void Flush() = 0; 58 59 // Calls Flush and finishes all of the actions required for parsing the trace. 60 // Calling this function multiple times is undefined behaviour. 61 virtual base::Status NotifyEndOfFile() = 0; 62 }; 63 64 } // namespace perfetto::trace_processor 65 66 #endif // INCLUDE_PERFETTO_TRACE_PROCESSOR_TRACE_PROCESSOR_STORAGE_H_ 67