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