зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1419368 - NetMonitor: Stop using ImmutableJS in timing-markers reducer. r=Honza
MozReview-Commit-ID: 5PQsSWT5m1P --HG-- extra : rebase_source : 1f1a21c174bbf69a29c781d95ff179e60189ad59
This commit is contained in:
Родитель
824f088ce8
Коммит
d0874f7146
|
@ -4,39 +4,39 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const I = require("devtools/client/shared/vendor/immutable");
|
||||
const {
|
||||
ADD_TIMING_MARKER,
|
||||
CLEAR_TIMING_MARKERS,
|
||||
CLEAR_REQUESTS,
|
||||
} = require("../constants");
|
||||
|
||||
const TimingMarkers = I.Record({
|
||||
firstDocumentDOMContentLoadedTimestamp: -1,
|
||||
firstDocumentLoadTimestamp: -1,
|
||||
});
|
||||
function TimingMarkers() {
|
||||
return {
|
||||
firstDocumentDOMContentLoadedTimestamp: -1,
|
||||
firstDocumentLoadTimestamp: -1,
|
||||
};
|
||||
}
|
||||
|
||||
function addTimingMarker(state, action) {
|
||||
state = { ...state };
|
||||
|
||||
if (action.marker.name === "document::DOMContentLoaded" &&
|
||||
state.firstDocumentDOMContentLoadedTimestamp === -1) {
|
||||
return state.set("firstDocumentDOMContentLoadedTimestamp",
|
||||
action.marker.unixTime / 1000);
|
||||
state.firstDocumentDOMContentLoadedTimestamp = action.marker.unixTime / 1000;
|
||||
return state;
|
||||
}
|
||||
|
||||
if (action.marker.name === "document::Load" &&
|
||||
state.firstDocumentLoadTimestamp === -1) {
|
||||
return state.set("firstDocumentLoadTimestamp",
|
||||
action.marker.unixTime / 1000);
|
||||
state.firstDocumentLoadTimestamp = action.marker.unixTime / 1000;
|
||||
return state;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
function clearTimingMarkers(state) {
|
||||
return state.withMutations(st => {
|
||||
st.remove("firstDocumentDOMContentLoadedTimestamp");
|
||||
st.remove("firstDocumentLoadTimestamp");
|
||||
});
|
||||
return new TimingMarkers();
|
||||
}
|
||||
|
||||
function timingMarkers(state = new TimingMarkers(), action) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"use strict";
|
||||
|
||||
function getDisplayedTimingMarker(state, marker) {
|
||||
return state.timingMarkers.get(marker) - state.requests.firstStartedMillis;
|
||||
return state.timingMarkers.marker - state.requests.firstStartedMillis;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
Загрузка…
Ссылка в новой задаче