Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ChromeTracingTracer.h
Go to the documentation of this file.
1/*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef ChromeTracingTracer_DEFINED
9#define ChromeTracingTracer_DEFINED
10
13#include "src/base/SkSpinlock.h"
14#include "src/core/SkTHash.h"
16
17class SkJSONWriter;
18
19/**
20 * A SkEventTracer implementation that logs events to JSON for viewing with chrome://tracing.
21 */
23public:
24 ChromeTracingTracer(const char* filename);
25 ~ChromeTracingTracer() override;
26
28 const uint8_t* categoryEnabledFlag,
29 const char* name,
30 uint64_t id,
31 int numArgs,
32 const char** argNames,
33 const uint8_t* argTypes,
34 const uint64_t* argValues,
35 uint8_t flags) override;
36
37 void updateTraceEventDuration(const uint8_t* categoryEnabledFlag,
38 const char* name,
39 SkEventTracer::Handle handle) override;
40
41 const uint8_t* getCategoryGroupEnabled(const char* name) override {
42 return fCategories.getCategoryGroupEnabled(name);
43 }
44
45 const char* getCategoryGroupName(const uint8_t* categoryEnabledFlag) override {
46 return fCategories.getCategoryGroupName(categoryEnabledFlag);
47 }
48
49 // The Chrome tracer does not yet support splitting up trace output into sections.
50 void newTracingSection(const char* name) override {}
51
52private:
53 void flush();
54
55 enum {
56 // Events are variable size, but most commonly 48 bytes, assuming 64-bit pointers and
57 // reasonable packing. This is a first guess at a number that balances memory usage vs.
58 // time overhead of allocating blocks.
59 kBlockSize = 512 * 1024,
60 };
61
62 typedef std::unique_ptr<uint8_t[]> BlockPtr;
63 struct TraceEventBlock {
64 BlockPtr fBlock;
65 int fEventsInBlock;
66 };
67
68 void createBlock();
69
70 Handle appendEvent(const void* data, size_t size);
71
72 SkString fFilename;
73 SkSpinlock fMutex;
74 SkEventTracingCategories fCategories;
75
76 TraceEventBlock fCurBlock;
77 size_t fCurBlockUsed;
78
80};
81
82#endif
SkEventTracer::Handle addTraceEvent(char phase, const uint8_t *categoryEnabledFlag, const char *name, uint64_t id, int numArgs, const char **argNames, const uint8_t *argTypes, const uint64_t *argValues, uint8_t flags) override
const char * getCategoryGroupName(const uint8_t *categoryEnabledFlag) override
const uint8_t * getCategoryGroupEnabled(const char *name) override
void updateTraceEventDuration(const uint8_t *categoryEnabledFlag, const char *name, SkEventTracer::Handle handle) override
void newTracingSection(const char *name) override
uint64_t Handle
const char * getCategoryGroupName(const uint8_t *categoryEnabledFlag)
uint8_t * getCategoryGroupEnabled(const char *name)
FlutterSemanticsFlag flags
const char * name
Definition fuchsia.cc:50