Skip to content

Commit 2d2c0e5

Browse files
szuendDevtools-frontend LUCI CQ
authored andcommitted
[sdk] Pass PageResourceLoader to the source map loading helpers
In follow-up CLs we'll pass the PageResourceLoader to the SourceMapManager and the TimelinePanel respectively. [email protected] Bug: 458180550 Change-Id: I41be693bc171a6d5d31134cf7b76b6d0dc5700a1 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7204004 Commit-Queue: Simon Zünd <[email protected]> Reviewed-by: Nikolay Vitkov <[email protected]> Auto-Submit: Simon Zünd <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]>
1 parent 09ac2b7 commit 2d2c0e5

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

front_end/core/sdk/SourceMapManager.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export class SourceMapManager<T extends FrameAssociated> extends Common.ObjectWr
113113
this.#attachingClient = null;
114114
const initiator = client.createPageResourceLoadInitiator();
115115
clientData.sourceMapPromise =
116-
loadSourceMap(sourceMapURL, client.debugId(), initiator)
116+
loadSourceMap(PageResourceLoader.instance(), sourceMapURL, client.debugId(), initiator)
117117
.then(
118118
payload => {
119119
const sourceMap = this.#factory(sourceURL, sourceMapURL, payload, client);
@@ -180,8 +180,8 @@ export class SourceMapManager<T extends FrameAssociated> extends Common.ObjectWr
180180
}
181181
}
182182

183-
export async function loadSourceMap(
184-
url: Platform.DevToolsPath.UrlString, debugId: DebugId|null,
183+
async function loadSourceMap(
184+
pageResourceLoader: PageResourceLoader, url: Platform.DevToolsPath.UrlString, debugId: DebugId|null,
185185
initiator: PageResourceLoadInitiator): Promise<SourceMapV3> {
186186
try {
187187
if (debugId) {
@@ -191,7 +191,7 @@ export async function loadSourceMap(
191191
}
192192
}
193193

194-
const {content} = await PageResourceLoader.instance().loadResource(url, initiator);
194+
const {content} = await pageResourceLoader.loadResource(url, initiator);
195195
const sourceMap = parseSourceMap(content);
196196
if ('debugId' in sourceMap && sourceMap.debugId) {
197197
// In case something goes wrong with updating the cache, we still want to use the source map.
@@ -204,9 +204,10 @@ export async function loadSourceMap(
204204
}
205205

206206
export async function tryLoadSourceMap(
207-
url: Platform.DevToolsPath.UrlString, initiator: PageResourceLoadInitiator): Promise<SourceMapV3|null> {
207+
pageResourceLoader: PageResourceLoader, url: Platform.DevToolsPath.UrlString,
208+
initiator: PageResourceLoadInitiator): Promise<SourceMapV3|null> {
208209
try {
209-
return await loadSourceMap(url, null, initiator);
210+
return await loadSourceMap(pageResourceLoader, url, null, initiator);
210211
} catch (cause) {
211212
console.error(cause);
212213
return null;

front_end/panels/timeline/TimelinePanel.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2643,6 +2643,7 @@ export class TimelinePanel extends Common.ObjectWrapper.eventMixin<EventTypes, t
26432643
initiatorUrl: script.url as Platform.DevToolsPath.UrlString
26442644
};
26452645
rawSourceMap = await SDK.SourceMapManager.tryLoadSourceMap(
2646+
SDK.PageResourceLoader.PageResourceLoader.instance(),
26462647
script.sourceMapUrl as Platform.DevToolsPath.UrlString, initiator);
26472648
}
26482649

@@ -2745,7 +2746,8 @@ export class TimelinePanel extends Common.ObjectWrapper.eventMixin<EventTypes, t
27452746
frameId: frame,
27462747
initiatorUrl: sourceUrl
27472748
};
2748-
const payload = await SDK.SourceMapManager.tryLoadSourceMap(sourceMapUrl, initiator);
2749+
const payload = await SDK.SourceMapManager.tryLoadSourceMap(
2750+
SDK.PageResourceLoader.PageResourceLoader.instance(), sourceMapUrl, initiator);
27492751
return payload ? new SDK.SourceMap.SourceMap(sourceUrl, sourceMapUrl, payload) : null;
27502752
};
27512753
}

0 commit comments

Comments
 (0)