1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module trace_report.mojom;
import "mojo/public/mojom/base/big_buffer.mojom";
import "mojo/public/mojom/base/time.mojom";
import "mojo/public/mojom/base/token.mojom";
[EnableIf=is_win]
import "url/mojom/url.mojom";
// Keep in sync with ReportUploadState from
// content/browser/tracing/trace_report/trace_report_database.h
enum ReportUploadState {
kNotUploaded = 0,
kPending = 1,
kPending_UserRequested = 2,
kUploaded = 3
};
// Keep in sync with SkipUploadReason from
// content/browser/tracing/trace_report/trace_report_database.h
// TODO: update once the skip reasons have been established.
enum SkipUploadReason {
kNoSkip = 0,
kSizeLimitExceeded = 1,
kNotAnonymized = 2,
kScenarioQuotaExceeded = 3,
kUploadTimedOut = 4,
kLocalScenario = 5,
};
// Information about a single trace to display
struct ClientTraceReport {
// A unique identifier for each trace recorded.
mojo_base.mojom.Token uuid;
// The time at which the report was created.
mojo_base.mojom.Time creation_time;
// The name of the scenario that trigger this trace to be collected and
// report to be created.
string scenario_name;
// The upload rule name that triggered this report.
string upload_rule_name;
// The upload rule value that triggered this report.
int32? upload_rule_value;
// The total size in bytes taken by the report.
int64 total_size;
// The current upload state for this report represented by
// ReportUploadState enum.
ReportUploadState upload_state;
// The time at which the report was successfully uploaded to a server.
mojo_base.mojom.Time upload_time;
// The reason for which a report was not uploaded even if the upload rules
// were met.
SkipUploadReason skip_reason;
// Whether the report has content (payload) attached to it.
bool has_trace_content;
};
struct Scenario {
string scenario_name;
};
// Used by the WebUI page to bootstrap bidirectional communication.
interface TraceReportHandlerFactory {
// The WebUI calls this method when the page is first initialized.
CreatePageHandler(pending_remote<Page> page,
pending_receiver<PageHandler> handler);
};
// Browser-side handler for requests from WebUI page.
interface PageHandler {
// Starts the tracing session from a serialized proto config defined as
// `perfetto.protos.TraceConfig`. This isn't using ProtoWrapper
// because it's not compatible with cppgen proto headers used by perfetto.
// PageHandler supports only one tracing session at a time.
StartTraceSession(mojo_base.mojom.BigBuffer config_pb) => (bool success);
// Clones the current tracing session in read-only mode and returns the
// captured trace snapshot, or null if the operation fails.
CloneTraceSession() => (mojo_base.mojom.BigBuffer? trace);
// Stops the current tracing session. If successful, this will read the trace
// payload and return it via Page::OnTraceComplete().
StopTraceSession() => (bool success);
// Returns buffer usage stats for the current tracing session. PageHandler
// supports only one request at a time.
GetBufferUsage()
=> (bool success, float percent_full, bool data_loss);
// Get visual data for all the traces currently stored locally.
GetAllTraceReports() => (array<ClientTraceReport> reports);
// Delete a single trace from the database.
DeleteSingleTrace(mojo_base.mojom.Token uuid) => (bool success);
// Delete all traces from the database.
DeleteAllTraces() => (bool success);
// Manually upload a trace.
UserUploadSingleTrace(mojo_base.mojom.Token uuid) => (bool success);
// Download locally the trace file.
DownloadTrace(mojo_base.mojom.Token uuid)
=> (mojo_base.mojom.BigBuffer? trace);
// Get the tracing list of scenarios for local tracing.
GetAllPresetScenarios() => (array<Scenario> config);
// Get the tracing list of scenarios for field tracing.
GetAllFieldScenarios() => (array<Scenario> config);
// Get enabled tracing scenarios hashes for local tracing.
GetEnabledScenarios() => (array<string> config);
// Set the tracing scenario hashes for local tracing.
SetEnabledScenarios(array<string> new_config) => (bool success);
// Set scenario presets from a base64 encoded config.
SetScenariosConfigFromString(string config_string) => (bool success);
// Set scenario presets from a serialized proto config defined as
// `perfetto.protos.ChromeFieldTracingConfig`. This isn't using ProtoWrapper
// because it's not compatible with cppgen proto headers used by perfetto.
SetScenariosConfigFromBuffer(mojo_base.mojom.BigBuffer config_pb)
=> (bool success);
// Get the user-controlled pref to enable privacy filter on local
// traces.
GetPrivacyFilterEnabled() => (bool enabled);
// Saves user-controlled pref to enable privacy filter on local
// traces.
SetPrivacyFilterEnabled(bool enable);
// Returns the current state of the Windows system tracing service for the
// running browser:
// - `service_supported`: true if the service is supported.
// - `service_enabled`: true if the service is enabled.
[EnableIf=is_win]
GetSystemTracingState() => (bool service_supported,
bool service_registered);
// Returns a data URI containing an encoding of the system's security shield
// icon scaled for the current DPI for use for UAC prompts, or an empty URL if
// UAC is disabled.
[EnableIf=is_win]
GetSecurityShieldIconUrl() => (url.mojom.Url shield_icon_url);
// Enables the Windows system tracing service.
[EnableIf=is_win]
EnableSystemTracing() => (bool success);
// Disables the Windows system tracing service.
[EnableIf=is_win]
DisableSystemTracing() => (bool success);
};
// WebUI-side handler for requests from the browser.
interface Page {
// When a tracing session completes, either from calling PageHandler::Stop()
// or by itself, this is invoked with the serialized trace payload.
OnTraceComplete(mojo_base.mojom.BigBuffer? trace);
};
|