зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1615436 - Allow capturing profiles even when profiling was started by another tool. r=gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D62825 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1ff2e87bb4
Коммит
cb4b236c58
|
@ -89,10 +89,8 @@ export type RecordingState =
|
|||
// An async request has been sent to stop the profiler.
|
||||
| "request-to-stop-profiler"
|
||||
// The profiler notified us that our request to start it actually started
|
||||
// it.
|
||||
// it, or it was already started.
|
||||
| "recording"
|
||||
// Some other code with access to the profiler started it.
|
||||
| "other-is-recording"
|
||||
// Profiling is not available when in private browsing mode.
|
||||
| "locked-by-private-browsing";
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ const { PureComponent } = require("devtools/client/shared/vendor/react");
|
|||
const { connect } = require("devtools/client/shared/vendor/react-redux");
|
||||
const actions = require("devtools/client/performance-new/store/actions");
|
||||
const selectors = require("devtools/client/performance-new/store/selectors");
|
||||
const { UnhandledCaseError } = require("devtools/client/performance-new/utils");
|
||||
|
||||
/**
|
||||
* This component state changes for the performance recording. e.g. If the profiler
|
||||
|
@ -66,7 +65,7 @@ class ProfilerEventHandling extends PureComponent {
|
|||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { perfFront, reportProfilerReady, pageContext } = this.props;
|
||||
const { perfFront, reportProfilerReady } = this.props;
|
||||
|
||||
// Ask for the initial state of the profiler.
|
||||
Promise.all([
|
||||
|
@ -87,22 +86,7 @@ class ProfilerEventHandling extends PureComponent {
|
|||
if (isLockedForPrivateBrowsing) {
|
||||
recordingState = "locked-by-private-browsing";
|
||||
} else if (isActive) {
|
||||
switch (pageContext) {
|
||||
case "popup":
|
||||
case "aboutprofiling":
|
||||
// These page contexts are in global control of the profiler, so allow it
|
||||
// to take control of recording.
|
||||
recordingState = "recording";
|
||||
break;
|
||||
case "devtools":
|
||||
// The DevTools performance recording shouldn't take control of others
|
||||
// use of the Gecko Profiler, since it's more interested in the current
|
||||
// page.
|
||||
recordingState = "other-is-recording";
|
||||
break;
|
||||
default:
|
||||
throw new UnhandledCaseError(pageContext, "PageContext");
|
||||
}
|
||||
recordingState = "recording";
|
||||
} else {
|
||||
recordingState = "available-to-record";
|
||||
}
|
||||
|
@ -142,7 +126,6 @@ class ProfilerEventHandling extends PureComponent {
|
|||
case "request-to-stop-profiler":
|
||||
case "request-to-get-profile-and-stop-profiler":
|
||||
case "locked-by-private-browsing":
|
||||
case "other-is-recording":
|
||||
// Do nothing for these states.
|
||||
break;
|
||||
|
||||
|
@ -157,7 +140,7 @@ class ProfilerEventHandling extends PureComponent {
|
|||
}
|
||||
|
||||
handleProfilerStarting() {
|
||||
const { changeRecordingState, recordingState, pageContext } = this.props;
|
||||
const { changeRecordingState, recordingState } = this.props;
|
||||
switch (recordingState) {
|
||||
case "not-yet-known":
|
||||
// We couldn't have started it yet, so it must have been someone
|
||||
|
@ -168,22 +151,7 @@ class ProfilerEventHandling extends PureComponent {
|
|||
// We requested to stop the profiler, but someone else already started
|
||||
// it up. (fallthrough)
|
||||
case "request-to-get-profile-and-stop-profiler":
|
||||
switch (pageContext) {
|
||||
case "popup":
|
||||
case "aboutprofiling":
|
||||
// These page contexts are in global control of the profiler, so allow it
|
||||
// to take control of recording.
|
||||
changeRecordingState("recording");
|
||||
break;
|
||||
case "devtools":
|
||||
// The DevTools performance recording shouldn't take control of others
|
||||
// use of the Gecko Profiler, since it's more interested in the current
|
||||
// page.
|
||||
changeRecordingState("other-is-recording");
|
||||
break;
|
||||
default:
|
||||
throw new UnhandledCaseError(pageContext, "PageContext");
|
||||
}
|
||||
changeRecordingState("recording");
|
||||
break;
|
||||
|
||||
case "request-to-start-recording":
|
||||
|
@ -192,7 +160,6 @@ class ProfilerEventHandling extends PureComponent {
|
|||
break;
|
||||
|
||||
case "locked-by-private-browsing":
|
||||
case "other-is-recording":
|
||||
case "recording":
|
||||
// These state cases don't make sense to happen, and means we have a logical
|
||||
// fallacy somewhere.
|
||||
|
@ -211,7 +178,6 @@ class ProfilerEventHandling extends PureComponent {
|
|||
case "not-yet-known":
|
||||
case "request-to-get-profile-and-stop-profiler":
|
||||
case "request-to-stop-profiler":
|
||||
case "other-is-recording":
|
||||
changeRecordingState("available-to-record");
|
||||
break;
|
||||
|
||||
|
@ -246,7 +212,6 @@ class ProfilerEventHandling extends PureComponent {
|
|||
// it will resolve correctly? (fallthrough)
|
||||
case "request-to-stop-profiler":
|
||||
case "available-to-record":
|
||||
case "other-is-recording":
|
||||
case "not-yet-known":
|
||||
changeRecordingState("locked-by-private-browsing");
|
||||
break;
|
||||
|
|
|
@ -185,13 +185,6 @@ class RecordingButton extends PureComponent {
|
|||
},
|
||||
});
|
||||
|
||||
case "other-is-recording":
|
||||
return this.renderButton({
|
||||
label: "Stop and discard the other recording",
|
||||
onClick: stopProfilerAndDiscardProfile,
|
||||
additionalMessage: "Another tool is currently recording.",
|
||||
});
|
||||
|
||||
case "locked-by-private-browsing":
|
||||
return this.renderButton({
|
||||
label: span(
|
||||
|
|
|
@ -40,12 +40,13 @@
|
|||
"The component at first is in an unknown state.");
|
||||
|
||||
await perfFrontMock._flushAsyncQueue();
|
||||
is(getRecordingState(), "other-is-recording",
|
||||
"The profiler is not available to record.");
|
||||
is(getRecordingState(), "recording",
|
||||
"The profiler is reflecting the recording state.");
|
||||
|
||||
const button = container.querySelector("button");
|
||||
ok(button, "Selected a button on the component");
|
||||
button.click();
|
||||
const [captureButton, stopButton] = container.querySelectorAll("button");
|
||||
ok(captureButton, "Selected capture button on the component");
|
||||
ok(stopButton, "Selected stop button on the component");
|
||||
stopButton.click();
|
||||
is(getRecordingState(), "request-to-stop-profiler",
|
||||
"We can request to stop the profiler.");
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче