Bug 1851992 - send onDataFinished notifications from nsInputStreamPump. r=necko-reviewers,jesup

Differential Revision: https://phabricator.services.mozilla.com/D188757
This commit is contained in:
sunil mayya 2023-10-24 01:48:10 +00:00
parent 1acfb3f11f
commit d2b6e6de8b
3 changed files with 15 additions and 1 deletions

View File

@ -11673,6 +11673,12 @@
value: @IS_NIGHTLY_BUILD@
mirror: always
# Whether we can send OnDataAvailable to content process directly.
- name: network.send_OnDataFinished.nsInputStreamPump
type: RelaxedAtomicBool
value: @IS_NIGHTLY_BUILD@
mirror: always
# Perform all network access on the socket process.
# The pref requires "network.process.enabled" to be true.
# Changing these prefs requires a restart.

View File

@ -14,6 +14,7 @@
#include "mozilla/NonBlockingAsyncInputStream.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/SlicedInputStream.h"
#include "mozilla/StaticPrefs_network.h"
#include "nsIStreamListener.h"
#include "nsILoadGroup.h"
#include "nsNetCID.h"
@ -650,6 +651,14 @@ uint32_t nsInputStreamPump::OnStateStop() {
if (!NS_IsMainThread() && !mOffMainThread) {
// This method can be called on a different thread if nsInputStreamPump
// is used off the main-thread.
if (NS_SUCCEEDED(mStatus) && mListener &&
mozilla::StaticPrefs::network_send_OnDataFinished_nsInputStreamPump()) {
nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
do_QueryInterface(mListener);
if (retargetableListener) {
retargetableListener->OnDataFinished(mStatus);
}
}
nsresult rv = mLabeledMainThreadTarget->Dispatch(
mozilla::NewRunnableMethod("nsInputStreamPump::CallOnStateStop", this,
&nsInputStreamPump::CallOnStateStop));

View File

@ -29,7 +29,6 @@
#include "mozilla/StaticPrefs_html5.h"
#include "mozilla/StaticPrefs_intl.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/TaskCategory.h"
#include "mozilla/TextUtils.h"
#include "mozilla/UniquePtrExtensions.h"