MCPcopy Create free account
hub / github.com/google/gapid / Capture

Method Capture

gapis/perfetto/android/trace.go:79–107  ·  view source on GitHub ↗

Capture starts the perfetto capture.

(ctx context.Context, start task.Signal, stop task.Signal, w io.Writer, written *int64)

Source from the content-addressed store, hash-verified

77
78// Capture starts the perfetto capture.
79func (p *Process) Capture(ctx context.Context, start task.Signal, stop task.Signal, w io.Writer, written *int64) (int64, error) {
80 tmp, err := file.Temp()
81 if err != nil {
82 return 0, log.Err(ctx, err, "Failed to create a temp file")
83 }
84
85 // Signal that we are ready to start.
86 atomic.StoreInt64(written, 1)
87
88 if p.deferred && !start.Wait(ctx) {
89 return 0, log.Err(ctx, nil, "Cancelled")
90 }
91
92 if err := p.device.StartPerfettoTrace(ctx, p.config, perfettoTraceFile, stop); err != nil {
93 return 0, err
94 }
95
96 if err := p.device.Pull(ctx, perfettoTraceFile, tmp.System()); err != nil {
97 return 0, err
98 }
99
100 size := tmp.Info().Size()
101 atomic.StoreInt64(written, size)
102 fh, err := os.Open(tmp.System())
103 if err != nil {
104 return 0, log.Err(ctx, err, fmt.Sprintf("Failed to open %s", tmp))
105 }
106 return io.Copy(w, fh)
107}

Callers

nothing calls this directly

Calls 9

SystemMethod · 0.80
WaitMethod · 0.65
StartPerfettoTraceMethod · 0.65
PullMethod · 0.65
SizeMethod · 0.65
OpenMethod · 0.65
CopyMethod · 0.65
ErrMethod · 0.45
InfoMethod · 0.45

Tested by

no test coverage detected