Bug 1620280 - [devtools] Bypass SourceQueue as it should be made redundant with ResourceWatcher throttling. r=jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D90430
This commit is contained in:
Alexandre Poirot 2020-10-01 14:22:45 +00:00
Родитель 24fa559f26
Коммит 75809cbbf4
2 изменённых файлов: 9 добавлений и 23 удалений

Просмотреть файл

@ -8,7 +8,6 @@ import { setupCommands, clientCommands } from "./firefox/commands";
import { setupEvents, clientEvents } from "./firefox/events";
import { features, prefs } from "../utils/prefs";
import { prepareSourcePayload } from "./firefox/create";
import sourceQueue from "../utils/source-queue";
let actions;
let targetList;
@ -49,12 +48,6 @@ export async function onConnect(
await resourceWatcher.watchResources([resourceWatcher.TYPES.SOURCE], {
onAvailable: onSourceAvailable,
});
// Tests like browser_webconsole_eval_sources.js using viewSourceInDebugger
// are expecting to find sources in the debugger store immediately for existing sources.
// So flush the queue immediately after calling watchResources, which will
// process all existing sources.
await sourceQueue.flush();
}
export function onDisconnect() {
@ -143,22 +136,14 @@ function onTargetDestroyed({ targetFront }): void {
}
async function onSourceAvailable(sources) {
for (const source of sources) {
const threadFront = await source.targetFront.getFront("thread");
const frontendSource = prepareSourcePayload(threadFront, source);
// Use SourceQueue, which will throttle all incoming sources and only display merged set of
// action every 100ms. Unless SourceQueue.flush is manually called when:
// - the thread is paused and we have to retrieve the source immediately
// - after fetching all existing sources (tests expect sources to be in redux store immediately)
//
// This throttling code could probably be migrated in the ResourceWatcher API
// so that we use a generic throttling algorithm for all resources.
sourceQueue.queue({
type: "generated",
data: frontendSource,
});
}
const frontendSources = await Promise.all(
sources.map(async source => {
const threadFront = await source.targetFront.getFront("thread");
const frontendSource = prepareSourcePayload(threadFront, source);
return frontendSource;
})
);
await actions.newGeneratedSources(frontendSources);
}
export { clientCommands, clientEvents };

Просмотреть файл

@ -7,6 +7,7 @@
import { throttle } from "lodash";
import type { QueuedSourceData } from "../types";
// This SourceQueue module is now only used for source mapped sources
let newQueuedSources;
let queuedSources;
let currentWork;