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 <stdint.h> 21 22 #include <memory> 23 24 #include "perfetto/base/export.h" 25 #include "perfetto/trace_processor/basic_types.h" 26 #include "perfetto/trace_processor/status.h" 27 28 namespace perfetto { 29 namespace trace_processor { 30 31 // Coordinates the loading of traces from an arbitrary source. 32 class PERFETTO_EXPORT TraceProcessorStorage { 33 public: 34 // Creates a new instance of TraceProcessorStorage. 35 static std::unique_ptr<TraceProcessorStorage> CreateInstance(const Config&); 36 37 virtual ~TraceProcessorStorage(); 38 39 // The entry point to push trace data into the processor. The trace format 40 // will be automatically discovered on the first push call. It is possible 41 // to make queries between two pushes. 42 // Returns the Ok status if parsing has been succeeding so far, and Error 43 // status if some unrecoverable error happened. If this happens, the 44 // TraceProcessor will ignore the following Parse() requests, drop data on the 45 // floor and return errors forever. 46 virtual util::Status Parse(std::unique_ptr<uint8_t[]>, size_t) = 0; 47 48 // When parsing a bounded file (as opposite to streaming from a device) this 49 // function should be called when the last chunk of the file has been passed 50 // into Parse(). This allows to flush the events queued in the ordering stage, 51 // without having to wait for their time window to expire. 52 virtual void NotifyEndOfFile() = 0; 53 }; 54 55 } // namespace trace_processor 56 } // namespace perfetto 57 58 #endif // INCLUDE_PERFETTO_TRACE_PROCESSOR_TRACE_PROCESSOR_STORAGE_H_ 59