xref: /aosp_15_r20/development/tools/winscope/src/viewers/viewer_search/ui_data.ts (revision 90c8c64db3049935a07c6143d7fd006e26f8ecca)
1/*
2 * Copyright (C) 2024 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
17import {LogEntry, LogHeader} from 'viewers/common/ui_data_log';
18
19export class UiData {
20  currentSearches: SearchResult[] = [];
21  savedSearches: Search[] = [];
22  recentSearches: Search[] = [];
23  lastTraceFailed = false;
24  initialized = false;
25  searchViews: string[] = [];
26
27  static createEmpty() {
28    return new UiData();
29  }
30}
31
32export class SearchResult {
33  selectedIndex: undefined | number;
34  scrollToIndex: undefined | number;
35  currentIndex: undefined | number;
36
37  constructor(
38    readonly query: string,
39    readonly headers: LogHeader[],
40    readonly entries: LogEntry[],
41  ) {}
42}
43
44export class Search {
45  readonly timeMs: number;
46  constructor(readonly query: string, readonly name = query) {
47    this.timeMs = Date.now();
48  }
49}
50