forked from mirrors/gecko-dev
Bug 1193389 - nsTransportEventSinkProxy clean up, r=necko-reviewers,valentin
This patch might not fix this issue, but we should try to avoid accessing raw pointer. Differential Revision: https://phabricator.services.mozilla.com/D199976
This commit is contained in:
parent
171e740e55
commit
3b3d13f309
1 changed files with 8 additions and 8 deletions
|
|
@ -24,24 +24,21 @@ class nsTransportEventSinkProxy : public nsITransportEventSink {
|
|||
nsTransportEventSinkProxy(nsITransportEventSink* sink, nsIEventTarget* target)
|
||||
: mSink(sink),
|
||||
mTarget(target),
|
||||
mLock("nsTransportEventSinkProxy.mLock"),
|
||||
mLastEvent(nullptr) {
|
||||
NS_ADDREF(mSink);
|
||||
}
|
||||
mLock("nsTransportEventSinkProxy.mLock") {}
|
||||
|
||||
private:
|
||||
virtual ~nsTransportEventSinkProxy() {
|
||||
// our reference to mSink could be the last, so be sure to release
|
||||
// it on the target thread. otherwise, we could get into trouble.
|
||||
NS_ProxyRelease("nsTransportEventSinkProxy::mSink", mTarget,
|
||||
dont_AddRef(mSink));
|
||||
mSink.forget());
|
||||
}
|
||||
|
||||
public:
|
||||
nsITransportEventSink* mSink;
|
||||
nsCOMPtr<nsITransportEventSink> mSink;
|
||||
nsCOMPtr<nsIEventTarget> mTarget;
|
||||
Mutex mLock MOZ_UNANNOTATED;
|
||||
nsTransportStatusEvent* mLastEvent;
|
||||
RefPtr<nsTransportStatusEvent> mLastEvent;
|
||||
};
|
||||
|
||||
class nsTransportStatusEvent : public Runnable {
|
||||
|
|
@ -69,11 +66,14 @@ class nsTransportStatusEvent : public Runnable {
|
|||
// if not coalescing all, then last event may not equal self!
|
||||
{
|
||||
MutexAutoLock lock(mProxy->mLock);
|
||||
if (mProxy->mLastEvent == this) mProxy->mLastEvent = nullptr;
|
||||
if (mProxy->mLastEvent == this) {
|
||||
mProxy->mLastEvent = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
mProxy->mSink->OnTransportStatus(mTransport, mStatus, mProgress,
|
||||
mProgressMax);
|
||||
mProxy = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue