зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1401461. P1 - remove ChannelMediaResource::Listener::Revoke(). r=gerald
See comment 0 for the rationale. We check |aRequest != mResource->mChannel| to know if a new channel is being loaded and the call should be aborted. MozReview-Commit-ID: 6G1x7cXNvAq --HG-- extra : rebase_source : 3114979192346e257f5d8040b8e0ffffa419d3f5 extra : source : eeb067bc2905dfa6fb5764fd42ebb78e1b71a61d
This commit is contained in:
Родитель
02939c27b3
Коммит
3ce1e10aba
|
@ -68,8 +68,9 @@ nsresult
|
|||
ChannelMediaResource::Listener::OnStartRequest(nsIRequest* aRequest,
|
||||
nsISupports* aContext)
|
||||
{
|
||||
if (!mResource)
|
||||
if (aRequest != mResource->mChannel) {
|
||||
return NS_OK;
|
||||
}
|
||||
return mResource->OnStartRequest(aRequest, mOffset);
|
||||
}
|
||||
|
||||
|
@ -78,8 +79,9 @@ ChannelMediaResource::Listener::OnStopRequest(nsIRequest* aRequest,
|
|||
nsISupports* aContext,
|
||||
nsresult aStatus)
|
||||
{
|
||||
if (!mResource)
|
||||
if (aRequest != mResource->mChannel) {
|
||||
return NS_OK;
|
||||
}
|
||||
return mResource->OnStopRequest(aRequest, aStatus);
|
||||
}
|
||||
|
||||
|
@ -91,7 +93,9 @@ ChannelMediaResource::Listener::OnDataAvailable(nsIRequest* aRequest,
|
|||
uint32_t aCount)
|
||||
{
|
||||
// This might happen off the main thread.
|
||||
MOZ_DIAGNOSTIC_ASSERT(mResource);
|
||||
// Don't check |aRequest != mResource->mChannel| for it is a data race to read
|
||||
// mResource->mChannel off the main thread. Instead we check the load ID to
|
||||
// determine if the data is from an old channel.
|
||||
return mResource->OnDataAvailable(mLoadID, aStream, aCount);
|
||||
}
|
||||
|
||||
|
@ -103,7 +107,7 @@ ChannelMediaResource::Listener::AsyncOnChannelRedirect(
|
|||
nsIAsyncVerifyRedirectCallback* cb)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (mResource) {
|
||||
if (aOld == mResource->mChannel) {
|
||||
rv = mResource->OnChannelRedirect(aOld, aNew, aFlags, mOffset);
|
||||
}
|
||||
|
||||
|
@ -415,8 +419,6 @@ ChannelMediaResource::OnDataAvailable(uint32_t aLoadID,
|
|||
uint32_t aCount)
|
||||
{
|
||||
// This might happen off the main thread.
|
||||
// Don't assert |mChannel.get() == aRequest| since reading mChannel here off
|
||||
// the main thread is a data race.
|
||||
|
||||
RefPtr<ChannelMediaResource> self = this;
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
|
||||
|
@ -587,7 +589,6 @@ void ChannelMediaResource::CloseChannel()
|
|||
}
|
||||
|
||||
if (mListener) {
|
||||
mListener->Revoke();
|
||||
mListener = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,10 +128,8 @@ public:
|
|||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
|
||||
|
||||
void Revoke() { mResource = nullptr; }
|
||||
|
||||
private:
|
||||
RefPtr<ChannelMediaResource> mResource;
|
||||
const RefPtr<ChannelMediaResource> mResource;
|
||||
const int64_t mOffset;
|
||||
const uint32_t mLoadID;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче