Bug 1778272 - Revert the change to the LoadInfo release function. r=necko-reviewers,kershaw

Differential Revision: https://phabricator.services.mozilla.com/D151103
This commit is contained in:
Dragana Damjanovic 2022-07-06 08:10:51 +00:00
Родитель 4f87812c0f
Коммит 0cb9ae544a
10 изменённых файлов: 21 добавлений и 39 удалений

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

@ -37,7 +37,11 @@ using namespace mozilla;
// nsIconChannel methods
nsIconChannel::nsIconChannel() {}
nsIconChannel::~nsIconChannel() {}
nsIconChannel::~nsIconChannel() {
if (mLoadInfo) {
NS_ReleaseOnMainThread("nsIconChannel::mLoadInfo", mLoadInfo.forget());
}
}
NS_IMPL_ISUPPORTS(nsIconChannel, nsIChannel, nsIRequest, nsIRequestObserver, nsIStreamListener)

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

@ -560,6 +560,9 @@ NS_IMPL_ISUPPORTS(nsIconChannel, nsIChannel, nsIRequest, nsIRequestObserver,
nsIconChannel::nsIconChannel() {}
nsIconChannel::~nsIconChannel() {
if (mLoadInfo) {
NS_ReleaseOnMainThread("nsIconChannel::mLoadInfo", mLoadInfo.forget());
}
if (mLoadGroup) {
NS_ReleaseOnMainThread("nsIconChannel::mLoadGroup", mLoadGroup.forget());
}

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

@ -197,6 +197,7 @@ nsJARChannel::~nsJARChannel() {
}
// Proxy release the following members to main thread.
NS_ReleaseOnMainThread("nsJARChannel::mLoadInfo", mLoadInfo.forget());
NS_ReleaseOnMainThread("nsJARChannel::mCallbacks", mCallbacks.forget());
NS_ReleaseOnMainThread("nsJARChannel::mProgressSink", mProgressSink.forget());
NS_ReleaseOnMainThread("nsJARChannel::mLoadGroup", mLoadGroup.forget());

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

@ -757,41 +757,7 @@ void LoadInfo::ComputeIsThirdPartyContext(dom::WindowGlobalParent* aGlobal) {
thirdPartyUtil->IsThirdPartyGlobal(aGlobal, &mIsThirdPartyContext);
}
NS_IMPL_ADDREF(LoadInfo)
bool LoadInfo::DispatchRelease() {
if (NS_IsMainThread()) {
return false;
}
NS_DispatchToMainThread(NewNonOwningRunnableMethod("net::LoadInfo::Release",
this, &LoadInfo::Release),
NS_DISPATCH_NORMAL);
return true;
}
NS_IMETHODIMP_(MozExternalRefCountType)
LoadInfo::Release() {
nsrefcnt count = mRefCnt - 1;
if (DispatchRelease()) {
// Redispatched to main thread.
return count;
}
MOZ_ASSERT(0 != mRefCnt, "dup release");
count = --mRefCnt;
NS_LOG_RELEASE(this, count, "LoadInfo");
if (0 == count) {
mRefCnt = 1;
delete (this);
return 0;
}
return count;
}
NS_IMPL_QUERY_INTERFACE(LoadInfo, nsILoadInfo)
NS_IMPL_ISUPPORTS(LoadInfo, nsILoadInfo)
void LoadInfo::ReleaseMembers() {
mCSPEventListener = nullptr;

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

@ -262,7 +262,6 @@ class LoadInfo final : public nsILoadInfo {
void UpdateFrameBrowsingContextID(uint64_t aFrameBrowsingContextID) {
mFrameBrowsingContextID = aFrameBrowsingContextID;
}
bool DispatchRelease();
MOZ_NEVER_INLINE void ReleaseMembers();
// if you add a member, please also update the copy constructor and consider

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

@ -56,7 +56,9 @@ nsBaseChannel::nsBaseChannel() : NeckoTargetHolder(nullptr) {
mContentType.AssignLiteral(UNKNOWN_CONTENT_TYPE);
}
nsBaseChannel::~nsBaseChannel() {}
nsBaseChannel::~nsBaseChannel() {
NS_ReleaseOnMainThread("nsBaseChannel::mLoadInfo", mLoadInfo.forget());
}
nsresult nsBaseChannel::Redirect(nsIChannel* newChannel, uint32_t redirectFlags,
bool openNewChannel) {

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

@ -95,6 +95,11 @@ ClassifierDummyChannel::ClassifierDummyChannel(nsIURI* aURI,
SetLoadInfo(aLoadInfo);
}
ClassifierDummyChannel::~ClassifierDummyChannel() {
NS_ReleaseOnMainThread("ClassifierDummyChannel::mLoadInfo",
mLoadInfo.forget());
}
void ClassifierDummyChannel::AddClassificationFlags(
uint32_t aClassificationFlags, bool aThirdParty) {
if (aThirdParty) {

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

@ -71,7 +71,7 @@ class ClassifierDummyChannel final : public nsIChannel,
void AddClassificationFlags(uint32_t aClassificationFlags, bool aThirdParty);
private:
~ClassifierDummyChannel() = default;
~ClassifierDummyChannel();
nsCOMPtr<nsILoadInfo> mLoadInfo;
nsCOMPtr<nsIURI> mURI;

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

@ -285,6 +285,7 @@ void HttpBaseChannel::ReleaseMainThreadOnlyReferences() {
nsTArray<nsCOMPtr<nsISupports>> arrayToRelease;
arrayToRelease.AppendElement(mLoadGroup.forget());
arrayToRelease.AppendElement(mLoadInfo.forget());
arrayToRelease.AppendElement(mCallbacks.forget());
arrayToRelease.AppendElement(mProgressSink.forget());
arrayToRelease.AppendElement(mPrincipal.forget());

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

@ -1226,6 +1226,7 @@ WebSocketChannel::~WebSocketChannel() {
mListenerMT = nullptr;
NS_ReleaseOnMainThread("WebSocketChannel::mLoadGroup", mLoadGroup.forget());
NS_ReleaseOnMainThread("WebSocketChannel::mLoadInfo", mLoadInfo.forget());
NS_ReleaseOnMainThread("WebSocketChannel::mService", mService.forget());
nsCOMPtr<nsIEventTarget> target;
{