зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1746370 - [devtools] Simplify SourceQueue as it only handles original sources. r=nchevobbe
SourceQueue used to throttle both generated and original sources. But since we migrated to ResourceCommand, and it comes with a builtin throttling, we only use SourceQueue for original sources. So we can acknowledge that and simplify this a bit. Differential Revision: https://phabricator.services.mozilla.com/D134004
This commit is contained in:
Родитель
6dad0dbd64
Коммит
1c6546e6c4
|
@ -48,12 +48,7 @@ function loadSourceMaps(cx, sources) {
|
|||
const originalSources = await dispatch(
|
||||
loadSourceMap(cx, sourceActor)
|
||||
);
|
||||
sourceQueue.queueSources(
|
||||
originalSources.map(data => ({
|
||||
type: "original",
|
||||
data,
|
||||
}))
|
||||
);
|
||||
sourceQueue.queueOriginalSources(originalSources);
|
||||
return originalSources;
|
||||
})
|
||||
);
|
||||
|
@ -200,33 +195,14 @@ function restoreBlackBoxedSources(cx, sources) {
|
|||
};
|
||||
}
|
||||
|
||||
export function newQueuedSources(sourceInfo) {
|
||||
return async ({ dispatch }) => {
|
||||
const generated = [];
|
||||
const original = [];
|
||||
for (const source of sourceInfo) {
|
||||
if (source.type === "generated") {
|
||||
generated.push(source.data);
|
||||
} else {
|
||||
original.push(source.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (generated.length > 0) {
|
||||
await dispatch(newGeneratedSources(generated));
|
||||
}
|
||||
if (original.length > 0) {
|
||||
await dispatch(newOriginalSources(original));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Wrapper around newOriginalSources, only used by tests
|
||||
export function newOriginalSource(sourceInfo) {
|
||||
return async ({ dispatch }) => {
|
||||
const sources = await dispatch(newOriginalSources([sourceInfo]));
|
||||
return sources[0];
|
||||
};
|
||||
}
|
||||
|
||||
export function newOriginalSources(sourceInfo) {
|
||||
return async ({ dispatch, getState }) => {
|
||||
const state = getState();
|
||||
|
|
|
@ -5,37 +5,33 @@
|
|||
import { throttle } from "lodash";
|
||||
|
||||
// This SourceQueue module is now only used for source mapped sources
|
||||
let newQueuedSources;
|
||||
let queuedSources;
|
||||
let newOriginalQueuedSources;
|
||||
let queuedOriginalSources;
|
||||
let currentWork;
|
||||
|
||||
async function dispatchNewSources() {
|
||||
const sources = queuedSources;
|
||||
queuedSources = [];
|
||||
currentWork = await newQueuedSources(sources);
|
||||
const sources = queuedOriginalSources;
|
||||
queuedOriginalSources = [];
|
||||
currentWork = await newOriginalQueuedSources(sources);
|
||||
}
|
||||
|
||||
const queue = throttle(dispatchNewSources, 100);
|
||||
|
||||
export default {
|
||||
initialize: actions => {
|
||||
newQueuedSources = actions.newQueuedSources;
|
||||
queuedSources = [];
|
||||
newOriginalQueuedSources = actions.newOriginalSources;
|
||||
queuedOriginalSources = [];
|
||||
},
|
||||
queue: source => {
|
||||
queuedSources.push(source);
|
||||
queue();
|
||||
},
|
||||
queueSources: sources => {
|
||||
queueOriginalSources: sources => {
|
||||
if (sources.length > 0) {
|
||||
queuedSources = queuedSources.concat(sources);
|
||||
queuedOriginalSources = queuedOriginalSources.concat(sources);
|
||||
queue();
|
||||
}
|
||||
},
|
||||
|
||||
flush: () => Promise.all([queue.flush(), currentWork]),
|
||||
clear: () => {
|
||||
queuedSources = [];
|
||||
queuedOriginalSources = [];
|
||||
queue.cancel();
|
||||
},
|
||||
};
|
||||
|
|
|
@ -40,8 +40,8 @@ function createStore(client, initialState = {}, sourceMapsMock) {
|
|||
})(combineReducers(reducers), initialState);
|
||||
sourceQueue.clear();
|
||||
sourceQueue.initialize({
|
||||
newQueuedSources: sources =>
|
||||
store.dispatch(actions.newQueuedSources(sources)),
|
||||
newOriginalSources: sources =>
|
||||
store.dispatch(actions.newOriginalSources(sources)),
|
||||
});
|
||||
|
||||
store.thunkArgs = () => ({
|
||||
|
|
Загрузка…
Ссылка в новой задаче