mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-24 19:37:15 +00:00
Bug 633051 - Remove LOAD_BACKGROUND flag from media channel when load completes. r=roc a=roc
This commit is contained in:
parent
c6d9c951c9
commit
db0d4b9abc
@ -319,6 +319,20 @@ nsMediaChannelStream::OnStopRequest(nsIRequest* aRequest, nsresult aStatus)
|
||||
|
||||
if (!mIgnoreClose) {
|
||||
mCacheStream.NotifyDataEnded(aStatus);
|
||||
|
||||
// Move this request back into the foreground. This is necessary for
|
||||
// requests owned by video documents to ensure the load group fires
|
||||
// OnStopRequest when restoring from session history.
|
||||
if (mLoadInBackground) {
|
||||
mLoadInBackground = PR_FALSE;
|
||||
|
||||
nsLoadFlags loadFlags;
|
||||
nsresult rv = mChannel->GetLoadFlags(&loadFlags);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "GetLoadFlags() failed!");
|
||||
|
||||
loadFlags &= ~nsIRequest::LOAD_BACKGROUND;
|
||||
ModifyLoadFlags(loadFlags);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -1155,28 +1169,40 @@ void nsMediaStream::MoveLoadsToBackground() {
|
||||
NS_WARNING("Null element in nsMediaStream::MoveLoadsToBackground()");
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
rv = mChannel->GetLoadGroup(getter_AddRefs(loadGroup));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "GetLoadGroup() failed!");
|
||||
nsresult status;
|
||||
mChannel->GetStatus(&status);
|
||||
// Note: if (NS_FAILED(status)), the channel won't be in the load group.
|
||||
PRBool isPending = PR_FALSE;
|
||||
if (loadGroup &&
|
||||
NS_SUCCEEDED(status) &&
|
||||
NS_SUCCEEDED(mChannel->IsPending(&isPending)) &&
|
||||
isPending) {
|
||||
rv = loadGroup->RemoveRequest(mChannel, nsnull, status);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "RemoveRequest() failed!");
|
||||
|
||||
PRBool isPending = PR_FALSE;
|
||||
if (NS_SUCCEEDED(mChannel->IsPending(&isPending)) &&
|
||||
isPending) {
|
||||
nsLoadFlags loadFlags;
|
||||
rv = mChannel->GetLoadFlags(&loadFlags);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "GetLoadFlags() failed!");
|
||||
|
||||
loadFlags |= nsIRequest::LOAD_BACKGROUND;
|
||||
rv = mChannel->SetLoadFlags(loadFlags);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "SetLoadFlags() failed!");
|
||||
ModifyLoadFlags(loadFlags);
|
||||
}
|
||||
}
|
||||
|
||||
void nsMediaStream::ModifyLoadFlags(nsLoadFlags aFlags)
|
||||
{
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
nsresult rv = mChannel->GetLoadGroup(getter_AddRefs(loadGroup));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "GetLoadGroup() failed!");
|
||||
|
||||
nsresult status;
|
||||
mChannel->GetStatus(&status);
|
||||
|
||||
// Note: if (NS_FAILED(status)), the channel won't be in the load group.
|
||||
if (loadGroup &&
|
||||
NS_SUCCEEDED(status)) {
|
||||
rv = loadGroup->RemoveRequest(mChannel, nsnull, status);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "RemoveRequest() failed!");
|
||||
}
|
||||
|
||||
rv = mChannel->SetLoadFlags(aFlags);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "SetLoadFlags() failed!");
|
||||
|
||||
if (loadGroup &&
|
||||
NS_SUCCEEDED(status)) {
|
||||
rv = loadGroup->AddRequest(mChannel, nsnull);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "AddRequest() failed!");
|
||||
}
|
||||
|
@ -285,6 +285,11 @@ protected:
|
||||
MOZ_COUNT_CTOR(nsMediaStream);
|
||||
}
|
||||
|
||||
// Set the request's load flags to aFlags. If the request is part of a
|
||||
// load group, the request is removed from the group, the flags are set, and
|
||||
// then the request is added back to the load group.
|
||||
void ModifyLoadFlags(nsLoadFlags aFlags);
|
||||
|
||||
// This is not an nsCOMPointer to prevent a circular reference
|
||||
// between the decoder to the media stream object. The stream never
|
||||
// outlives the lifetime of the decoder.
|
||||
|
Loading…
x
Reference in New Issue
Block a user