Skip to content

Commit db5435d

Browse files
szuendDevtools-frontend LUCI CQ
authored andcommitted
[stack_trace] Add StackTraceModel
We want one fragment trie per target, so we add a simple StackTraceModel. This automatically takes care of the life-time for us. The current plan is for StackTraceModel to be the "trie boundary". That is callers should not be aware that fragments are stored in a trie. [email protected] Bug: 433162438 Change-Id: I3fbaddce5264855f740c88011d284bba53844b44 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6854804 Reviewed-by: Philip Pfaffe <[email protected]> Commit-Queue: Simon Zünd <[email protected]>
1 parent 437d04f commit db5435d

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

config/gni/devtools_grd_files.gni

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,7 @@ grd_files_unbundled_sources = [
11231123
"front_end/models/source_map_scopes/ScopeTreeCache.js",
11241124
"front_end/models/stack_trace/StackTrace.js",
11251125
"front_end/models/stack_trace/StackTraceImpl.js",
1126+
"front_end/models/stack_trace/StackTraceModel.js",
11261127
"front_end/models/stack_trace/Trie.js",
11271128
"front_end/models/text_utils/CodeMirrorUtils.js",
11281129
"front_end/models/text_utils/ContentData.js",

front_end/models/stack_trace/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ devtools_entrypoint("bundle") {
2727
devtools_module("stack_trace_impl") {
2828
sources = [
2929
"StackTraceImpl.ts",
30+
"StackTraceModel.ts",
3031
"Trie.ts",
3132
]
3233

3334
deps = [
3435
":bundle",
36+
"../../core/sdk:bundle",
3537
"../../generated",
3638
]
3739
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2025 The Chromium Authors
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import * as SDK from '../../core/sdk/sdk.js';
6+
7+
import {FragmentImpl} from './StackTraceImpl.js';
8+
import {type RawFrame, Trie} from './Trie.js';
9+
10+
/**
11+
* The {@link StackTraceModel} is a thin wrapper around a fragment trie.
12+
*
13+
* We want to store stack trace fragments per target so a SDKModel is the natural choice.
14+
*/
15+
export class StackTraceModel extends SDK.SDKModel.SDKModel<unknown> {
16+
readonly #trie = new Trie();
17+
18+
createFragment(frames: RawFrame[]): FragmentImpl {
19+
return FragmentImpl.getOrCreate(this.#trie.insert(frames));
20+
}
21+
}
22+
23+
SDK.SDKModel.SDKModel.register(StackTraceModel, {capabilities: SDK.Target.Capability.NONE, autostart: false});

0 commit comments

Comments
 (0)