Bug 1758792 - [devtools] Remove private browsing lock from performance front end r=julienw,devtools-backward-compat-reviewers

Depends on D140753

Differential Revision: https://phabricator.services.mozilla.com/D140754
This commit is contained in:
Julian Descottes 2022-03-11 09:32:23 +00:00
Родитель e5a462eb3c
Коммит 1c52152e37
9 изменённых файлов: 13 добавлений и 148 удалений

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

@ -50,9 +50,6 @@ perftools-devtools-settings-label = Settings
## Various statuses that affect the current state of profiling, not typically displayed.
perftools-status-private-browsing-notice =
The profiler is disabled when Private Browsing is enabled.
Close all Private Windows to re-enable the profiler
perftools-status-recording-stopped-by-another-tool = The recording was stopped by another tool.
perftools-status-restart-required = The browser must be restarted to enable this feature.

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

@ -47,8 +47,8 @@ export interface Commands {
targetCommand: {
targetFront: {
getTrait: (
traitName: "noDisablingOnPrivateBrowsing"
) => boolean | undefined;
traitName: string
) => unknown;
};
};
}
@ -66,7 +66,6 @@ export interface PerfFront {
) => Promise<[number[], number[], number[]]>;
isActive: () => Promise<boolean>;
isSupportedPlatform: () => Promise<boolean>;
isLockedForPrivateBrowsing: () => Promise<boolean>;
on: (type: string, listener: () => void) => void;
off: (type: string, listener: () => void) => void;
destroy: () => void;
@ -87,13 +86,7 @@ export interface PreferenceFront {
}
export interface RootTraits {
// In Firefox >= 98, this will be true, and will be missing for older
// versions. The functionality controlled by this property can be removed once
// Firefox 98 hits release.
noDisablingOnPrivateBrowsing?: boolean;
// There are other properties too, but we don't use them here as they're not
// related to the performance panel.
// There are no traits used by the performance front end at the moment.
}
export type RecordingState =
@ -109,9 +102,7 @@ export type RecordingState =
| "request-to-stop-profiler"
// The profiler notified us that our request to start it actually started
// it, or it was already started.
| "recording"
// Profiling is not available when in private browsing mode.
| "locked-by-private-browsing";
| "recording";
// We are currently migrating to a new UX workflow with about:profiling.
// This type provides an easy way to change the implementation based
@ -264,7 +255,6 @@ export type Action =
| {
type: "REPORT_PROFILER_READY";
isActive: boolean;
isLockedForPrivateBrowsing: boolean;
}
| {
type: "REPORT_PROFILER_STARTED";
@ -272,12 +262,6 @@ export type Action =
| {
type: "REPORT_PROFILER_STOPPED";
}
| {
type: "REPORT_PRIVATE_BROWSING_STARTED";
}
| {
type: "REPORT_PRIVATE_BROWSING_STOPPED";
}
| {
type: "REQUESTING_TO_START_RECORDING";
}

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

@ -27,8 +27,6 @@
* @property {typeof actions.reportProfilerReady} reportProfilerReady
* @property {typeof actions.reportProfilerStarted} reportProfilerStarted
* @property {typeof actions.reportProfilerStopped} reportProfilerStopped
* @property {typeof actions.reportPrivateBrowsingStarted} reportPrivateBrowsingStarted
* @property {typeof actions.reportPrivateBrowsingStopped} reportPrivateBrowsingStopped
*/
/**
@ -64,9 +62,6 @@ class ProfilerEventHandling extends PureComponent {
reportProfilerReady,
reportProfilerStarted,
reportProfilerStopped,
reportPrivateBrowsingStarted,
reportPrivateBrowsingStopped,
traits: { noDisablingOnPrivateBrowsing },
} = this.props;
if (!isSupportedPlatform) {
@ -74,32 +69,11 @@ class ProfilerEventHandling extends PureComponent {
}
// Ask for the initial state of the profiler.
Promise.all([
perfFront.isActive(),
noDisablingOnPrivateBrowsing
? false
: perfFront.isLockedForPrivateBrowsing(),
]).then(([isActive, isLockedForPrivateBrowsing]) => {
reportProfilerReady(isActive, isLockedForPrivateBrowsing);
});
perfFront.isActive().then(isActive => reportProfilerReady(isActive));
// Handle when the profiler changes state. It might be us, it might be someone else.
this.props.perfFront.on("profiler-started", reportProfilerStarted);
this.props.perfFront.on("profiler-stopped", reportProfilerStopped);
if (!noDisablingOnPrivateBrowsing) {
// @backward-compat { version 98 }
// These events are not used anymore in Firefox 98 and above. They can be
// removed along with the rest of the functionality once 98 hits release.
this.props.perfFront.on(
"profile-locked-by-private-browsing",
reportPrivateBrowsingStarted
);
this.props.perfFront.on(
"profile-unlocked-from-private-browsing",
reportPrivateBrowsingStopped
);
}
}
componentWillUnmount() {
@ -108,7 +82,6 @@ class ProfilerEventHandling extends PureComponent {
case "available-to-record":
case "request-to-stop-profiler":
case "request-to-get-profile-and-stop-profiler":
case "locked-by-private-browsing":
// Do nothing for these states.
break;
@ -143,8 +116,6 @@ const mapDispatchToProps = {
reportProfilerReady: actions.reportProfilerReady,
reportProfilerStarted: actions.reportProfilerStarted,
reportProfilerStopped: actions.reportProfilerStopped,
reportPrivateBrowsingStarted: actions.reportPrivateBrowsingStarted,
reportPrivateBrowsingStopped: actions.reportPrivateBrowsingStopped,
};
module.exports = connect(

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

@ -165,18 +165,6 @@ class RecordingButton extends PureComponent {
},
});
case "locked-by-private-browsing":
return renderButton({
label: startRecordingLabel(),
isPrimary: true,
disabled: true,
additionalMessage: Localized(
{ id: "perftools-status-private-browsing-notice" },
`The profiler is disabled when Private Browsing is enabled.
Close all Private Windows to re-enable the profiler`
),
});
default:
throw new Error("Unhandled recording state");
}

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

@ -62,11 +62,10 @@ class PerformancePanel {
this.panelWin.gIsPanelDestroyed = false;
const perfFront = await this.commands.client.mainRoot.getFront("perf");
const traits = {
noDisablingOnPrivateBrowsing: this.commands.targetCommand.targetFront.getTrait(
"noDisablingOnPrivateBrowsing"
),
};
// Note: we are not using traits in the panel at the moment but we keep the
// wiring in case we need it later on.
const traits = {};
await this.panelWin.gInit(
perfFront,

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

@ -31,13 +31,11 @@ const {
* This is the result of the initial questions about the state of the profiler.
*
* @param {boolean} isActive
* @param {boolean} isLockedForPrivateBrowsing
* @return {Action}
*/
exports.reportProfilerReady = (isActive, isLockedForPrivateBrowsing) => ({
exports.reportProfilerReady = isActive => ({
type: "REPORT_PROFILER_READY",
isActive,
isLockedForPrivateBrowsing,
});
/**
@ -56,22 +54,6 @@ exports.reportProfilerStopped = () => ({
type: "REPORT_PROFILER_STOPPED",
});
/**
* Dispatched when a private browsing session has started.
* @return {Action}
*/
exports.reportPrivateBrowsingStarted = () => ({
type: "REPORT_PRIVATE_BROWSING_STARTED",
});
/**
* Dispatched when a private browsing session has ended.
* @return {Action}
*/
exports.reportPrivateBrowsingStopped = () => ({
type: "REPORT_PRIVATE_BROWSING_STOPPED",
});
/**
* Updates the recording settings for the interval.
* @param {number} interval

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

@ -31,10 +31,7 @@ function recordingState(state = "not-yet-known", action) {
return state;
}
const { isActive, isLockedForPrivateBrowsing } = action;
if (isLockedForPrivateBrowsing) {
return "locked-by-private-browsing";
}
const { isActive } = action;
if (isActive) {
return "recording";
}
@ -58,7 +55,6 @@ function recordingState(state = "not-yet-known", action) {
// Wait for the profiler to tell us that it has started.
return "recording";
case "locked-by-private-browsing":
case "recording":
// These state cases don't make sense to happen, and means we have a logical
// fallacy somewhere.
@ -78,10 +74,8 @@ function recordingState(state = "not-yet-known", action) {
return "available-to-record";
case "request-to-start-recording":
// Highly unlikely, but someone stopped the recorder, this is fine.
// Do nothing (fallthrough).
case "locked-by-private-browsing":
// The profiler is already locked, so we know about this already.
// Highly unlikely, but someone stopped the recorder, this is fine.
// Do nothing.
return state;
case "recording":
@ -95,33 +89,6 @@ function recordingState(state = "not-yet-known", action) {
throw new Error("Unhandled recording state");
}
case "REPORT_PRIVATE_BROWSING_STARTED":
switch (state) {
case "request-to-get-profile-and-stop-profiler":
// This one is a tricky case. Go ahead and act like nothing went wrong, maybe
// it will resolve correctly? (fallthrough)
case "request-to-stop-profiler":
case "available-to-record":
case "not-yet-known":
return "locked-by-private-browsing";
case "request-to-start-recording":
case "recording":
return "locked-by-private-browsing";
case "locked-by-private-browsing":
// Do nothing
return state;
default:
throw new Error("Unhandled recording state");
}
case "REPORT_PRIVATE_BROWSING_STOPPED":
// No matter the state, go ahead and set this as ready to record. This should
// be the only logical state to go into.
return "available-to-record";
case "REQUESTING_TO_START_RECORDING":
return "request-to-start-recording";
@ -150,7 +117,6 @@ function recordingState(state = "not-yet-known", action) {
function recordingUnexpectedlyStopped(recState, state = false, action) {
switch (action.type) {
case "REPORT_PROFILER_STOPPED":
case "REPORT_PRIVATE_BROWSING_STARTED":
if (
recState === "recording" ||
recState == "request-to-start-recording"

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

@ -145,11 +145,6 @@ exports.RootActor = protocol.ActorClassWithSpec(rootSpec, {
// @backward-compat { version 86 } ThreadActor.attach no longer pauses the thread,
// so that we no longer have to resume.
noPauseOnThreadActorAttach: true,
// @backward-compat { version 98 }
// Starting version 98, we stopped disabling the profiler if the user has
// a window with private browsing enabled. This trait helps to detect this
// so that different code paths can be called.
noDisablingOnPrivateBrowsing: true,
};
},

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

@ -31,16 +31,6 @@ const perfDescription = {
"profiler-stopped": {
type: "profiler-stopped",
},
// @backward-compat { version 98 } These 2 events are not used anymore since
// Firefox 98. Instead we expose the information about private browsing in
// captured profile and show a warning in the profiler frontend UI. We can
// remove these 2 events once Firefox 98 hits release.
"profile-locked-by-private-browsing": {
type: "profile-locked-by-private-browsing",
},
"profile-unlocked-from-private-browsing": {
type: "profile-unlocked-from-private-browsing",
},
},
methods: {
@ -86,13 +76,6 @@ const perfDescription = {
response: { value: RetVal("boolean") },
},
// @backward-compat { version 98 } This method is not used since Firefox 98.
// We can remove it once Firefox 98 hits release.
isLockedForPrivateBrowsing: {
request: {},
response: { value: RetVal("boolean") },
},
getSupportedFeatures: {
request: {},
response: { value: RetVal("array:string") },