зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1730919 - Add 'Extension Suspend' profiler marker from ChannelWrapper::Suspend. r=florian,mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D125722
This commit is contained in:
Родитель
9408d87ba5
Коммит
73f6d61afa
|
@ -122,17 +122,17 @@ interface ChannelWrapper : EventTarget {
|
|||
void upgradeToSecure();
|
||||
|
||||
/**
|
||||
* Suspends the underlying channel.
|
||||
* Suspends the underlying channel. The profilerText parameter is only used
|
||||
* to annotate profiles.
|
||||
*/
|
||||
[Throws]
|
||||
void suspend();
|
||||
void suspend(ByteString profileMarkerText);
|
||||
|
||||
/**
|
||||
* Resumes (un-suspends) the underlying channel. The profilerText parameter
|
||||
* is only used to annotate profiles.
|
||||
* Resumes (un-suspends) the underlying channel.
|
||||
*/
|
||||
[Throws]
|
||||
void resume(ByteString profileText);
|
||||
void resume();
|
||||
|
||||
/**
|
||||
* The content type of the request, usually as read from the Content-Type
|
||||
|
|
|
@ -246,35 +246,40 @@ void ChannelWrapper::UpgradeToSecure(ErrorResult& aRv) {
|
|||
}
|
||||
}
|
||||
|
||||
void ChannelWrapper::Suspend(ErrorResult& aRv) {
|
||||
void ChannelWrapper::Suspend(const nsCString& aProfileMarkerText,
|
||||
ErrorResult& aRv) {
|
||||
if (!mSuspended) {
|
||||
nsresult rv = NS_ERROR_UNEXPECTED;
|
||||
if (nsCOMPtr<nsIChannel> chan = MaybeChannel()) {
|
||||
mSuspendTime = mozilla::TimeStamp::Now();
|
||||
rv = chan->Suspend();
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
} else {
|
||||
mSuspended = true;
|
||||
MOZ_ASSERT(mSuspendedMarkerText.IsVoid());
|
||||
mSuspendedMarkerText = aProfileMarkerText;
|
||||
PROFILER_MARKER_TEXT("Extension Suspend", NETWORK,
|
||||
MarkerOptions(MarkerTiming::IntervalStart()),
|
||||
mSuspendedMarkerText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelWrapper::Resume(const nsCString& aText, ErrorResult& aRv) {
|
||||
void ChannelWrapper::Resume(ErrorResult& aRv) {
|
||||
if (mSuspended) {
|
||||
nsresult rv = NS_ERROR_UNEXPECTED;
|
||||
if (nsCOMPtr<nsIChannel> chan = MaybeChannel()) {
|
||||
rv = chan->Resume();
|
||||
|
||||
PROFILER_MARKER_TEXT("Extension Suspend", NETWORK,
|
||||
MarkerTiming::IntervalUntilNowFrom(mSuspendTime),
|
||||
aText);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
} else {
|
||||
mSuspended = false;
|
||||
PROFILER_MARKER_TEXT("Extension Suspend", NETWORK,
|
||||
MarkerOptions(MarkerTiming::IntervalEnd()),
|
||||
mSuspendedMarkerText);
|
||||
mSuspendedMarkerText = VoidCString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,8 +141,8 @@ class ChannelWrapper final : public DOMEventTargetHelper,
|
|||
void UpgradeToSecure(ErrorResult& aRv);
|
||||
|
||||
bool Suspended() const { return mSuspended; }
|
||||
void Suspend(ErrorResult& aRv);
|
||||
void Resume(const nsCString& aText, ErrorResult& aRv);
|
||||
void Suspend(const nsCString& aProfileMarkerText, ErrorResult& aRv);
|
||||
void Resume(ErrorResult& aRv);
|
||||
|
||||
void GetContentType(nsCString& aContentType) const;
|
||||
void SetContentType(const nsACString& aContentType);
|
||||
|
@ -318,7 +318,9 @@ class ChannelWrapper final : public DOMEventTargetHelper,
|
|||
|
||||
nsInterfaceHashtable<nsPtrHashKey<const nsAtom>, nsIRemoteTab> mAddonEntries;
|
||||
|
||||
mozilla::TimeStamp mSuspendTime;
|
||||
// The text for the "Extension Suspend" marker, set from the Suspend method
|
||||
// when called for the first time and then cleared on the Resume method.
|
||||
nsCString mSuspendedMarkerText = VoidCString();
|
||||
|
||||
class RequestListener final : public nsIStreamListener,
|
||||
public nsIMultiPartChannelListener,
|
||||
|
|
|
@ -944,14 +944,25 @@ HttpObserverManager = {
|
|||
requestHeaders,
|
||||
responseHeaders
|
||||
) {
|
||||
const { finalURL, id: chanId } = channel;
|
||||
let shouldResume = !channel.suspended;
|
||||
let suspenders = [];
|
||||
|
||||
// NOTE: if a request has been suspended before the GeckoProfiler
|
||||
// has been activated and then resumed while the GeckoProfiler is active
|
||||
// and collecting data, the resulting "Extension Suspend" marker will be
|
||||
// recorded with an empty marker text (and so without url, chan id and
|
||||
// the supenders addon ids).
|
||||
let markerText = "";
|
||||
if (Services.profiler?.IsActive()) {
|
||||
const suspenders = handlerResults
|
||||
.filter(({ result }) => isThenable(result))
|
||||
.map(({ opts }) => opts.addonId)
|
||||
.join(", ");
|
||||
markerText = `${kind} ${finalURL} by ${suspenders} (chanId: ${chanId})`;
|
||||
}
|
||||
try {
|
||||
for (let { opts, result } of handlerResults) {
|
||||
if (isThenable(result)) {
|
||||
suspenders.push(opts.addonId);
|
||||
channel.suspend();
|
||||
channel.suspend(markerText);
|
||||
try {
|
||||
result = await result;
|
||||
} catch (e) {
|
||||
|
@ -986,17 +997,16 @@ HttpObserverManager = {
|
|||
}
|
||||
|
||||
if (result.cancel) {
|
||||
let text = "";
|
||||
if (Services.profiler?.IsActive()) {
|
||||
text =
|
||||
`${kind} ${channel.finalURL}` +
|
||||
` by ${suspenders.join(", ")} canceled`;
|
||||
}
|
||||
channel.resume(text);
|
||||
channel.resume();
|
||||
channel.cancel(
|
||||
Cr.NS_ERROR_ABORT,
|
||||
Ci.nsILoadInfo.BLOCKING_REASON_EXTENSION_WEBREQUEST
|
||||
);
|
||||
ChromeUtils.addProfilerMarker(
|
||||
"Extension Canceled",
|
||||
{ category: "Network" },
|
||||
`${kind} ${finalURL} canceled by ${opts.addonId} (chanId: ${chanId})`
|
||||
);
|
||||
if (opts.policy) {
|
||||
let properties = channel.channel.QueryInterface(
|
||||
Ci.nsIWritablePropertyBag
|
||||
|
@ -1008,15 +1018,14 @@ HttpObserverManager = {
|
|||
|
||||
if (result.redirectUrl) {
|
||||
try {
|
||||
let text = "";
|
||||
if (Services.profiler?.IsActive()) {
|
||||
text =
|
||||
`${kind} ${channel.finalURL}` +
|
||||
` by ${suspenders.join(", ")}` +
|
||||
` redirected to ${result.redirectUrl}`;
|
||||
}
|
||||
channel.resume(text);
|
||||
channel.redirectTo(Services.io.newURI(result.redirectUrl));
|
||||
const { redirectUrl } = result;
|
||||
channel.resume();
|
||||
channel.redirectTo(Services.io.newURI(redirectUrl));
|
||||
ChromeUtils.addProfilerMarker(
|
||||
"Extension Redirected",
|
||||
{ category: "Network" },
|
||||
`${kind} ${finalURL} redirected to ${redirectUrl} by ${opts.addonId} (chanId: ${chanId})`
|
||||
);
|
||||
if (opts.policy) {
|
||||
let properties = channel.channel.QueryInterface(
|
||||
Ci.nsIWritablePropertyBag
|
||||
|
@ -1102,11 +1111,7 @@ HttpObserverManager = {
|
|||
|
||||
// Only resume the channel if it was suspended by this call.
|
||||
if (shouldResume) {
|
||||
let text = "";
|
||||
if (Services.profiler?.IsActive()) {
|
||||
text = `${kind} ${channel.finalURL} by ${suspenders.join(", ")}`;
|
||||
}
|
||||
channel.resume(text);
|
||||
channel.resume();
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче