mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 964462, simplify ipc offline resource refcounting, r=mayhemer
--HG-- extra : rebase_source : 362ce98a10c25f7e3263f23736a18d2bcfb16e75
This commit is contained in:
parent
c55b555306
commit
0b60275ff0
@ -2108,7 +2108,7 @@ bool
|
||||
TabChild::DeallocPOfflineCacheUpdateChild(POfflineCacheUpdateChild* actor)
|
||||
{
|
||||
OfflineCacheUpdateChild* offlineCacheUpdate = static_cast<OfflineCacheUpdateChild*>(actor);
|
||||
delete offlineCacheUpdate;
|
||||
NS_RELEASE(offlineCacheUpdate);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -67,18 +67,7 @@ NS_INTERFACE_MAP_BEGIN(OfflineCacheUpdateChild)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ADDREF(OfflineCacheUpdateChild)
|
||||
NS_IMPL_RELEASE_WITH_DESTROY(OfflineCacheUpdateChild, RefcountHitZero())
|
||||
|
||||
void
|
||||
OfflineCacheUpdateChild::RefcountHitZero()
|
||||
{
|
||||
if (mIPCActivated) {
|
||||
// ContentChild::DeallocPOfflineCacheUpdate will delete this
|
||||
OfflineCacheUpdateChild::Send__delete__(this);
|
||||
} else {
|
||||
delete this; // we never opened IPDL channel
|
||||
}
|
||||
}
|
||||
NS_IMPL_RELEASE(OfflineCacheUpdateChild)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// OfflineCacheUpdateChild <public>
|
||||
@ -87,7 +76,6 @@ OfflineCacheUpdateChild::RefcountHitZero()
|
||||
OfflineCacheUpdateChild::OfflineCacheUpdateChild(nsIDOMWindow* aWindow)
|
||||
: mState(STATE_UNINITIALIZED)
|
||||
, mIsUpgrade(false)
|
||||
, mIPCActivated(false)
|
||||
, mAppID(NECKO_NO_APP_ID)
|
||||
, mInBrowser(false)
|
||||
, mWindow(aWindow)
|
||||
@ -448,8 +436,8 @@ OfflineCacheUpdateChild::Schedule()
|
||||
child->SendPOfflineCacheUpdateConstructor(this, manifestURI, documentURI,
|
||||
stickDocument);
|
||||
|
||||
mIPCActivated = true;
|
||||
this->AddRef();
|
||||
// TabChild::DeallocPOfflineCacheUpdate will release this.
|
||||
NS_ADDREF_THIS();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -537,7 +525,8 @@ OfflineCacheUpdateChild::RecvFinish(const bool &succeeded,
|
||||
|
||||
// This is by contract the last notification from the parent, release
|
||||
// us now. This is corresponding to AddRef in Schedule().
|
||||
this->Release();
|
||||
// TabChild::DeallocPOfflineCacheUpdate will call Release.
|
||||
OfflineCacheUpdateChild::Send__delete__(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -53,8 +53,6 @@ private:
|
||||
void GatherObservers(nsCOMArray<nsIOfflineCacheUpdateObserver> &aObservers);
|
||||
nsresult Finish();
|
||||
|
||||
void RefcountHitZero();
|
||||
|
||||
enum {
|
||||
STATE_UNINITIALIZED,
|
||||
STATE_INITIALIZED,
|
||||
@ -66,7 +64,6 @@ private:
|
||||
|
||||
bool mIsUpgrade;
|
||||
bool mSucceeded;
|
||||
bool mIPCActivated;
|
||||
|
||||
nsCString mUpdateDomain;
|
||||
nsCOMPtr<nsIURI> mManifestURI;
|
||||
|
@ -1157,7 +1157,6 @@ NS_IMPL_ISUPPORTS3(nsOfflineCacheUpdate,
|
||||
|
||||
nsOfflineCacheUpdate::nsOfflineCacheUpdate()
|
||||
: mState(STATE_UNINITIALIZED)
|
||||
, mOwner(nullptr)
|
||||
, mAddedItems(false)
|
||||
, mPartialUpdate(false)
|
||||
, mOnlyCheckUpdate(false)
|
||||
@ -1986,7 +1985,7 @@ void
|
||||
nsOfflineCacheUpdate::SetOwner(nsOfflineCacheUpdateOwner *aOwner)
|
||||
{
|
||||
NS_ASSERTION(!mOwner, "Tried to set cache update owner twice.");
|
||||
mOwner = aOwner;
|
||||
mOwner = aOwner->asWeakPtr();
|
||||
}
|
||||
|
||||
bool
|
||||
@ -2107,7 +2106,9 @@ nsOfflineCacheUpdate::FinishNoNotify()
|
||||
|
||||
if (mOwner) {
|
||||
rv = mOwner->UpdateFinished(this);
|
||||
mOwner = nullptr;
|
||||
// mozilla::WeakPtr is missing some key features, like setting it to
|
||||
// null explicitly.
|
||||
mOwner = mozilla::WeakPtr<nsOfflineCacheUpdateOwner>();
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsICryptoHash.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
|
||||
@ -185,8 +186,10 @@ private:
|
||||
};
|
||||
|
||||
class nsOfflineCacheUpdateOwner
|
||||
: public mozilla::SupportsWeakPtr<nsOfflineCacheUpdateOwner>
|
||||
{
|
||||
public:
|
||||
virtual ~nsOfflineCacheUpdateOwner() {}
|
||||
virtual nsresult UpdateFinished(nsOfflineCacheUpdate *aUpdate) = 0;
|
||||
};
|
||||
|
||||
@ -261,7 +264,7 @@ private:
|
||||
STATE_FINISHED
|
||||
} mState;
|
||||
|
||||
nsOfflineCacheUpdateOwner *mOwner;
|
||||
mozilla::WeakPtr<nsOfflineCacheUpdateOwner> mOwner;
|
||||
|
||||
bool mAddedItems;
|
||||
bool mPartialUpdate;
|
||||
|
Loading…
Reference in New Issue
Block a user