/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
mozilla::ipc::IPCResult FetchChild::Recv__delete__(const nsresult&& aResult) {
FETCH_LOG(("FetchChild::Recv__delete__ [%p]", this)); if (mIsShutdown) { return IPC_OK();
} // Shutdown has not been called, so mWorkerRef->Private() should be still // alive. if (mWorkerRef) {
MOZ_ASSERT(mWorkerRef->Private());
mWorkerRef->Private()->AssertIsOnWorkerThread();
} else {
MOZ_ASSERT(mIsKeepAliveRequest);
}
if (mPromise->State() == Promise::PromiseState::Pending) { if (NS_FAILED(aResult)) {
mPromise->MaybeReject(aResult); if (mFetchObserver) {
mFetchObserver->SetState(FetchState::Errored);
}
} else {
mPromise->MaybeResolve(aResult); if (mFetchObserver) {
mFetchObserver->SetState(FetchState::Complete);
}
}
} return IPC_OK();
}
mozilla::ipc::IPCResult FetchChild::RecvOnResponseAvailableInternal(
ParentToChildInternalResponse&& aResponse) {
FETCH_LOG(("FetchChild::RecvOnResponseAvailableInternal [%p]", this)); if (mIsShutdown) { return IPC_OK();
} // Shutdown has not been called, so mWorkerRef->Private() should be still // alive. if (mWorkerRef) {
MOZ_ASSERT(mWorkerRef->Private());
mWorkerRef->Private()->AssertIsOnWorkerThread();
}
if (internalResponse->Type() != ResponseType::Error) { if (internalResponse->Type() == ResponseType::Opaque) {
internalResponse->GeneratePaddingInfo();
}
if (mFetchObserver) {
mFetchObserver->SetState(FetchState::Complete);
}
// mFetchObserver->SetState runs JS and a blocking JS function can run // queued runnables, including ActorDestroy that nullifies mPromise. if (!mPromise) { return IPC_OK();
}
nsCOMPtr<nsIGlobalObject> global;
global = mPromise->GetGlobalObject();
RefPtr<Response> response = new Response(global, internalResponse.clonePtr(), mSignalImpl);
mPromise->MaybeResolve(response);
return IPC_OK();
}
FETCH_LOG(
("FetchChild::RecvOnResponseAvailableInternal [%p] response type is " "Error(0x%x)", this, static_cast<int32_t>(internalResponse->GetErrorCode()))); if (mFetchObserver) {
mFetchObserver->SetState(FetchState::Errored);
}
// mFetchObserver->SetState runs JS and a blocking JS function can run queued // runnables, including ActorDestroy that nullifies mPromise. if (!mPromise) { return IPC_OK();
}
mPromise->MaybeRejectWithTypeError<MSG_FETCH_FAILED>(); return IPC_OK();
}
mozilla::ipc::IPCResult FetchChild::RecvOnResponseEnd(ResponseEndArgs&& aArgs) {
FETCH_LOG(("FetchChild::RecvOnResponseEnd [%p]", this)); if (mIsShutdown) { return IPC_OK();
} // Shutdown has not been called, so mWorkerRef->Private() should be still // alive. if (mWorkerRef) {
MOZ_ASSERT(mWorkerRef->Private());
mWorkerRef->Private()->AssertIsOnWorkerThread();
}
if (aArgs.endReason() == FetchDriverObserver::eAborted) {
FETCH_LOG(
("FetchChild::RecvOnResponseEnd [%p] endReason is eAborted", this)); if (mFetchObserver) {
mFetchObserver->SetState(FetchState::Errored);
}
// mFetchObserver->SetState runs JS and a blocking JS function can run // queued runnables, including ActorDestroy that nullifies mPromise. if (!mPromise) { return IPC_OK();
}
mPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
}
Unfollow(); return IPC_OK();
}
mozilla::ipc::IPCResult FetchChild::RecvOnDataAvailable() {
FETCH_LOG(("FetchChild::RecvOnDataAvailable [%p]", this)); if (mIsShutdown) { return IPC_OK();
} // Shutdown has not been called, so mWorkerRef->Private() should be still // alive. if (mWorkerRef) {
MOZ_ASSERT(mWorkerRef->Private());
mWorkerRef->Private()->AssertIsOnWorkerThread();
}
if (NS_IsMainThread()) {
MOZ_ASSERT(mIsKeepAliveRequest); // extract doc object to flush the console report for (constauto& report : aReports) {
mReporter->AddConsoleReport(
report.errorFlags(), report.category(), static_cast<nsContentUtils::PropertiesFile>(report.propertiesFile()),
report.sourceFileURI(), report.lineNumber(), report.columnNumber(),
report.messageName(), report.stringParams());
}
MOZ_ASSERT(mPromise);
nsCOMPtr<nsPIDOMWindowInner> window =
do_QueryInterface(mPromise->GetGlobalObject()); if (window) {
Document* doc = window->GetExtantDoc();
mReporter->FlushConsoleReports(doc);
} else {
mReporter->FlushReportsToConsole(0);
} return IPC_OK();
} // Shutdown has not been called, so mWorkerRef->Private() should be still // alive. if (mWorkerRef) {
MOZ_ASSERT(mWorkerRef->Private());
mWorkerRef->Private()->AssertIsOnWorkerThread();
}
mozilla::ipc::IPCResult FetchChild::RecvOnReportPerformanceTiming(
ResponseTiming&& aTiming) {
FETCH_LOG(("FetchChild::RecvOnReportPerformanceTiming [%p]", this)); if (mIsShutdown) { return IPC_OK();
} // Shutdown has not been called, so mWorkerRef->Private() should be still // alive. if (mWorkerRef) {
MOZ_ASSERT(mWorkerRef->Private());
mWorkerRef->Private()->AssertIsOnWorkerThread();
mozilla::ipc::IPCResult FetchChild::RecvOnNotifyNetworkMonitorAlternateStack(
uint64_t aChannelID) {
FETCH_LOG(
("FetchChild::RecvOnNotifyNetworkMonitorAlternateStack [%p]", this)); if (mIsShutdown) { return IPC_OK();
} // Shutdown has not been called, so mWorkerRef->Private() should be still // alive. if (mWorkerRef) {
MOZ_ASSERT(mWorkerRef->Private());
mWorkerRef->Private()->AssertIsOnWorkerThread();
if (!mOriginStack) { return IPC_OK();
}
if (!mWorkerChannelInfo) {
mWorkerChannelInfo = MakeRefPtr<WorkerChannelInfo>(
aChannelID, mWorkerRef->Private()->AssociatedBrowsingContextID());
}
// Unfortunately, SerializedStackHolder can only be read on the main thread. // However, it doesn't block the fetch execution.
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
__func__, [channel = mWorkerChannelInfo,
stack = std::move(mOriginStack)]() mutable {
NotifyNetworkMonitorAlternateStack(channel, std::move(stack));
});
MOZ_ALWAYS_SUCCEEDS(SchedulerGroup::Dispatch(r.forget()));
} // Currently we only support sending notifications for worker-thread initiated // Fetch requests. We need to extend this to main-thread fetch requests as // well. See Bug 1897424.
void FetchChild::DoFetchOp(const FetchOpArgs& aArgs) {
FETCH_LOG(("FetchChild::DoFetchOp [%p]", this)); // we need to store this for keepalive request // as we need to update the load group during actor termination
mIsKeepAliveRequest = aArgs.request().keepalive(); if (mIsKeepAliveRequest) {
mKeepaliveRequestSize =
aArgs.request().bodySize() > 0 ? aArgs.request().bodySize() : 0;
} if (mSignalImpl) { if (mSignalImpl->Aborted()) {
Unused << SendAbortFetchOp(true); return;
}
Follow(mSignalImpl);
}
Unused << SendFetchOp(aArgs);
}
void FetchChild::Shutdown() { // This is invoked for worker fetch requests only. // We need to modify this to be invoked for main-thread fetch requests as // well. Typically during global teardown. See Bug 1901082
FETCH_LOG(("FetchChild::Shutdown [%p]", this)); if (mIsShutdown) { return;
}
mIsShutdown.Flip();
// If mWorkerRef is nullptr here, that means Recv__delete__() must be called if (!mWorkerRef) { return;
}
mPromise = nullptr;
mFetchObserver = nullptr;
Unfollow();
mSignalImpl = nullptr;
mCSPEventListener = nullptr;
SendAbortFetchOp(false);
mWorkerRef = nullptr;
}
void FetchChild::ActorDestroy(ActorDestroyReason aReason) {
FETCH_LOG(("FetchChild::ActorDestroy [%p]", this)); // for keepalive request decrement the pending keepalive count if (mIsKeepAliveRequest) { // For workers we do not have limit per load group rather we have limit // per request if (NS_IsMainThread()) {
MOZ_ASSERT(mPromise->GetGlobalObject());
nsCOMPtr<nsILoadGroup> loadGroup =
FetchUtil::GetLoadGroupFromGlobal(mPromise->GetGlobalObject()); if (loadGroup) {
FetchUtil::DecrementPendingKeepaliveRequestSize(loadGroup,
mKeepaliveRequestSize);
}
}
}
mPromise = nullptr;
mFetchObserver = nullptr;
mSignalImpl = nullptr;
mCSPEventListener = nullptr;
mWorkerRef = nullptr;
}
} // namespace mozilla::dom
¤ Dauer der Verarbeitung: 0.18 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.