ui: move TraceSource back into core
There's no need for it to be exposed to plugins, exposing it also
requires exposing StateSerializationSchema which is just confusing.
Change-Id: Ib36b6cec0220c56fcd0a510ad2113f3ff20e5e32
diff --git a/ui/src/common/state.ts b/ui/src/common/state.ts
index 4d45311..39f9c5b 100644
--- a/ui/src/common/state.ts
+++ b/ui/src/common/state.ts
@@ -13,7 +13,7 @@
// limitations under the License.
import {RecordConfig} from '../controller/record_config_types';
-import {TraceSource} from '../public/trace_source';
+import {TraceSource} from '../core/trace_source';
/**
* A plain js object, holding objects of type |Class| keyed by string id.
diff --git a/ui/src/core/app_impl.ts b/ui/src/core/app_impl.ts
index 097211a..0779457 100644
--- a/ui/src/core/app_impl.ts
+++ b/ui/src/core/app_impl.ts
@@ -23,8 +23,8 @@
import {NewEngineMode} from '../trace_processor/engine';
import {RouteArgs} from '../public/route_schema';
import {SqlPackage} from '../public/extra_sql_packages';
-import {SerializedAppState} from '../public/state_serialization_schema';
-import {PostedTrace, TraceSource} from '../public/trace_source';
+import {SerializedAppState} from './state_serialization_schema';
+import {PostedTrace, TraceSource} from './trace_source';
import {loadTrace} from './load_trace';
import {CORE_PLUGIN_ID} from './plugin_manager';
import {Router} from './router';
diff --git a/ui/src/core/cache_manager.ts b/ui/src/core/cache_manager.ts
index 78c7567..7dd9cd0 100644
--- a/ui/src/core/cache_manager.ts
+++ b/ui/src/core/cache_manager.ts
@@ -18,7 +18,7 @@
* containing it is discarded by Chrome (e.g. because the tab was not used for
* a long time) or when the user accidentally hits reload.
*/
-import {TraceArrayBufferSource, TraceSource} from '../public/trace_source';
+import {TraceArrayBufferSource, TraceSource} from './trace_source';
const TRACE_CACHE_NAME = 'cached_traces';
const TRACE_CACHE_SIZE = 10;
diff --git a/ui/src/core/fake_trace_impl.ts b/ui/src/core/fake_trace_impl.ts
index bb80844..6b3f763 100644
--- a/ui/src/core/fake_trace_impl.ts
+++ b/ui/src/core/fake_trace_impl.ts
@@ -14,10 +14,10 @@
import {getServingRoot} from '../base/http_utils';
import {Time} from '../base/time';
-import {TraceInfo} from '../public/trace_info';
import {EngineBase} from '../trace_processor/engine';
import {AppImpl} from './app_impl';
import {TraceImpl} from './trace_impl';
+import {TraceInfoImpl} from './trace_info_impl';
export interface FakeTraceImplArgs {
// If true suppresses exceptions when trying to issue a query. This is to
@@ -48,7 +48,7 @@
if (!AppImpl.initialized) {
initializeAppImplForTesting();
}
- const fakeTraceInfo: TraceInfo = {
+ const fakeTraceInfo: TraceInfoImpl = {
source: {type: 'URL', url: ''},
traceTitle: '',
traceUrl: '',
diff --git a/ui/src/core/load_trace.ts b/ui/src/core/load_trace.ts
index 1423365..3776f95 100644
--- a/ui/src/core/load_trace.ts
+++ b/ui/src/core/load_trace.ts
@@ -40,13 +40,13 @@
deserializeAppStatePhase1,
deserializeAppStatePhase2,
} from './state_serialization';
-import {TraceInfo} from '../public/trace_info';
import {AppImpl} from './app_impl';
import {raf} from './raf_scheduler';
import {TraceImpl} from './trace_impl';
-import {SerializedAppState} from '../public/state_serialization_schema';
-import {TraceSource} from '../public/trace_source';
+import {SerializedAppState} from './state_serialization_schema';
+import {TraceSource} from './trace_source';
import {Router} from '../core/router';
+import {TraceInfoImpl} from './trace_info_impl';
const ENABLE_CHROME_RELIABLE_RANGE_ZOOM_FLAG = featureFlags.register({
id: 'enableChromeReliableRangeZoom',
@@ -354,7 +354,7 @@
async function getTraceInfo(
engine: Engine,
traceSource: TraceSource,
-): Promise<TraceInfo> {
+): Promise<TraceInfoImpl> {
const traceTime = await getTraceTimeBounds(engine);
// Find the first REALTIME or REALTIME_COARSE clock snapshot.
diff --git a/ui/src/core/state_serialization.ts b/ui/src/core/state_serialization.ts
index 38b8727..bafc74f 100644
--- a/ui/src/core/state_serialization.ts
+++ b/ui/src/core/state_serialization.ts
@@ -19,7 +19,7 @@
SerializedPluginState,
SerializedSelection,
SerializedAppState,
-} from '../public/state_serialization_schema';
+} from './state_serialization_schema';
import {TimeSpan} from '../base/time';
import {TraceImpl} from './trace_impl';
diff --git a/ui/src/public/state_serialization_schema.ts b/ui/src/core/state_serialization_schema.ts
similarity index 100%
rename from ui/src/public/state_serialization_schema.ts
rename to ui/src/core/state_serialization_schema.ts
diff --git a/ui/src/core/trace_impl.ts b/ui/src/core/trace_impl.ts
index 8944fe0..591664f 100644
--- a/ui/src/core/trace_impl.ts
+++ b/ui/src/core/trace_impl.ts
@@ -19,7 +19,6 @@
import {Command} from '../public/command';
import {EventListeners, Trace} from '../public/trace';
import {ScrollToArgs, setScrollToFunction} from '../public/scroll_helper';
-import {TraceInfo} from '../public/trace_info';
import {TrackDescriptor} from '../public/track';
import {EngineBase, EngineProxy} from '../trace_processor/engine';
import {CommandManagerImpl} from './command_manager';
@@ -44,6 +43,7 @@
import {Analytics} from '../public/analytics';
import {getOrCreate} from '../base/utils';
import {fetchWithProgress} from '../base/http_utils';
+import {TraceInfoImpl} from './trace_info_impl';
/**
* Handles the per-trace state of the UI
@@ -61,7 +61,7 @@
readonly selectionMgr: SelectionManagerImpl;
readonly tabMgr = new TabManagerImpl();
readonly timeline: TimelineImpl;
- readonly traceInfo: TraceInfo;
+ readonly traceInfo: TraceInfoImpl;
readonly trackMgr = new TrackManagerImpl();
readonly workspaceMgr = new WorkspaceManagerImpl();
readonly noteMgr = new NoteManagerImpl();
@@ -77,7 +77,7 @@
// what TraceProcessor reports on the stats table at import time.
readonly loadingErrors: string[] = [];
- constructor(gctx: AppContext, engine: EngineBase, traceInfo: TraceInfo) {
+ constructor(gctx: AppContext, engine: EngineBase, traceInfo: TraceInfoImpl) {
this.appCtx = gctx;
this.engine = engine;
this.trash.use(engine);
@@ -179,7 +179,7 @@
static createInstanceForCore(
appImpl: AppImpl,
engine: EngineBase,
- traceInfo: TraceInfo,
+ traceInfo: TraceInfoImpl,
): TraceImpl {
const traceCtx = new TraceContext(
appImpl.__appCtxForTraceImplCtor,
@@ -321,7 +321,7 @@
return this.traceCtx.selectionMgr;
}
- get traceInfo(): TraceInfo {
+ get traceInfo(): TraceInfoImpl {
return this.traceCtx.traceInfo;
}
diff --git a/ui/src/core/trace_info_impl.ts b/ui/src/core/trace_info_impl.ts
new file mode 100644
index 0000000..1584143
--- /dev/null
+++ b/ui/src/core/trace_info_impl.ts
@@ -0,0 +1,20 @@
+// Copyright (C) 2024 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import {TraceSource} from '../core/trace_source';
+import {TraceInfo} from '../public/trace_info';
+
+export interface TraceInfoImpl extends TraceInfo {
+ readonly source: TraceSource;
+}
diff --git a/ui/src/public/trace_source.ts b/ui/src/core/trace_source.ts
similarity index 100%
rename from ui/src/public/trace_source.ts
rename to ui/src/core/trace_source.ts
diff --git a/ui/src/frontend/permalink.ts b/ui/src/frontend/permalink.ts
index 9dda684..75c7f0b 100644
--- a/ui/src/frontend/permalink.ts
+++ b/ui/src/frontend/permalink.ts
@@ -30,7 +30,7 @@
import {
SERIALIZED_STATE_VERSION,
SerializedAppState,
-} from '../public/state_serialization_schema';
+} from '../core/state_serialization_schema';
import {z} from 'zod';
import {showModal} from '../widgets/modal';
import {AppImpl} from '../core/app_impl';
diff --git a/ui/src/frontend/post_message_handler.ts b/ui/src/frontend/post_message_handler.ts
index 1a381c8..60c97c5 100644
--- a/ui/src/frontend/post_message_handler.ts
+++ b/ui/src/frontend/post_message_handler.ts
@@ -14,7 +14,7 @@
import m from 'mithril';
import {Time} from '../base/time';
-import {PostedTrace} from '../public/trace_source';
+import {PostedTrace} from '../core/trace_source';
import {showModal} from '../widgets/modal';
import {initCssConstants} from './css_constants';
import {toggleHelp} from './help_modal';
diff --git a/ui/src/frontend/sidebar.ts b/ui/src/frontend/sidebar.ts
index 319d59a..55608cf 100644
--- a/ui/src/frontend/sidebar.ts
+++ b/ui/src/frontend/sidebar.ts
@@ -41,6 +41,7 @@
import {AppImpl} from '../core/app_impl';
import {Trace} from '../public/trace';
import {removeFalsyValues} from '../base/array_utils';
+import {TraceImpl} from '../core/trace_impl';
const GITILES_URL =
'https://android.googlesource.com/platform/external/perfetto';
@@ -96,7 +97,7 @@
});
export interface OptionalTraceAttrs {
- trace?: Trace;
+ trace?: TraceImpl;
}
function shouldShowHiringBanner(): boolean {
@@ -147,7 +148,7 @@
});
}
-function getSections(app: AppImpl, trace: Trace | undefined): Section[] {
+function getSections(app: AppImpl, trace: TraceImpl | undefined): Section[] {
const downloadDisabled = trace?.traceInfo.downloadable
? undefined
: 'Cannot download external trace';
@@ -315,7 +316,7 @@
await convertTraceToJsonAndDownload(file);
}
-function downloadTrace(trace: Trace) {
+function downloadTrace(trace: TraceImpl) {
if (!trace.traceInfo.downloadable) return;
AppImpl.instance.analytics.logEvent('Trace Actions', 'Download trace');
diff --git a/ui/src/frontend/trace_share_utils.ts b/ui/src/frontend/trace_share_utils.ts
index c1033c6..418fe51 100644
--- a/ui/src/frontend/trace_share_utils.ts
+++ b/ui/src/frontend/trace_share_utils.ts
@@ -13,19 +13,20 @@
// limitations under the License.
import m from 'mithril';
-import {TraceUrlSource} from '../public/trace_source';
+import {TraceUrlSource} from '../core/trace_source';
import {createPermalink} from './permalink';
import {showModal} from '../widgets/modal';
import {onClickCopy} from './clipboard';
import {globals} from './globals';
import {AppImpl} from '../core/app_impl';
import {Trace} from '../public/trace';
+import {TraceImpl} from '../core/trace_impl';
export function isShareable(trace: Trace) {
return globals.isInternalUser && trace.traceInfo.downloadable;
}
-export async function shareTrace(trace: Trace) {
+export async function shareTrace(trace: TraceImpl) {
const traceSource = trace.traceInfo.source;
const traceUrl = (traceSource as TraceUrlSource).url ?? '';
diff --git a/ui/src/public/trace_info.ts b/ui/src/public/trace_info.ts
index 6ac99c5..71d977bd 100644
--- a/ui/src/public/trace_info.ts
+++ b/ui/src/public/trace_info.ts
@@ -13,11 +13,8 @@
// limitations under the License.
import {time} from '../base/time';
-import {TraceSource} from './trace_source';
export interface TraceInfo {
- readonly source: TraceSource;
-
readonly traceTitle: string; // File name and size of the current trace.
readonly traceUrl: string; // URL of the Trace.