Bug 1394705 - let HTMLMediaElement::MediaLoadListener implement nsIThreadRetargetableStreamListener. r=cpearce

This is required to use nsIThreadRetargetableRequest::RetargetDeliveryTo().

MozReview-Commit-ID: GFuAjovabpY

--HG--
extra : rebase_source : 4fbc7877f2548dcf0777c820ee724f41c46de688
This commit is contained in:
JW Wang 2017-08-29 14:28:13 +08:00
parent 14f6dae050
commit 29df163b4e
3 changed files with 45 additions and 13 deletions

View File

@ -449,10 +449,12 @@ private:
* to an nsIChannel, which holds a reference to this listener.
* We break the reference cycle in OnStartRequest by clearing mElement.
*/
class HTMLMediaElement::MediaLoadListener final : public nsIStreamListener,
public nsIChannelEventSink,
public nsIInterfaceRequestor,
public nsIObserver
class HTMLMediaElement::MediaLoadListener final
: public nsIStreamListener
, public nsIChannelEventSink
, public nsIInterfaceRequestor
, public nsIObserver
, public nsIThreadRetargetableStreamListener
{
~MediaLoadListener() {}
@ -462,6 +464,7 @@ class HTMLMediaElement::MediaLoadListener final : public nsIStreamListener,
NS_DECL_NSICHANNELEVENTSINK
NS_DECL_NSIOBSERVER
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
public:
explicit MediaLoadListener(HTMLMediaElement* aElement)
@ -477,9 +480,13 @@ private:
const uint32_t mLoadID;
};
NS_IMPL_ISUPPORTS(HTMLMediaElement::MediaLoadListener, nsIRequestObserver,
nsIStreamListener, nsIChannelEventSink,
nsIInterfaceRequestor, nsIObserver)
NS_IMPL_ISUPPORTS(HTMLMediaElement::MediaLoadListener,
nsIRequestObserver,
nsIStreamListener,
nsIChannelEventSink,
nsIInterfaceRequestor,
nsIObserver,
nsIThreadRetargetableStreamListener)
NS_IMETHODIMP
HTMLMediaElement::MediaLoadListener::Observe(nsISupports* aSubject,
@ -621,6 +628,18 @@ HTMLMediaElement::MediaLoadListener::AsyncOnChannelRedirect(nsIChannel* aOldChan
return NS_OK;
}
NS_IMETHODIMP
HTMLMediaElement::MediaLoadListener::CheckListenerChain()
{
MOZ_ASSERT(mNextListener);
nsCOMPtr<nsIThreadRetargetableStreamListener> retargetable =
do_QueryInterface(mNextListener);
if (retargetable) {
return retargetable->CheckListenerChain();
}
return NS_ERROR_NO_INTERFACE;
}
NS_IMETHODIMP
HTMLMediaElement::MediaLoadListener::GetInterface(const nsIID& aIID,
void** aResult)

View File

@ -122,8 +122,11 @@ ChannelMediaResource::~ChannelMediaResource()
// a new listener, so notifications from the old channel are discarded
// and don't confuse us.
NS_IMPL_ISUPPORTS(ChannelMediaResource::Listener,
nsIRequestObserver, nsIStreamListener, nsIChannelEventSink,
nsIInterfaceRequestor)
nsIRequestObserver,
nsIStreamListener,
nsIChannelEventSink,
nsIInterfaceRequestor,
nsIThreadRetargetableStreamListener)
nsresult
ChannelMediaResource::Listener::OnStartRequest(nsIRequest* aRequest,
@ -174,7 +177,13 @@ ChannelMediaResource::Listener::AsyncOnChannelRedirect(nsIChannel* aOldChannel,
}
nsresult
ChannelMediaResource::Listener::GetInterface(const nsIID & aIID, void **aResult)
ChannelMediaResource::Listener::CheckListenerChain()
{
return NS_OK;
}
nsresult
ChannelMediaResource::Listener::GetInterface(const nsIID& aIID, void** aResult)
{
return QueryInterface(aIID, aResult);
}

View File

@ -13,6 +13,7 @@
#include "nsIStreamListener.h"
#include "nsIChannelEventSink.h"
#include "nsIInterfaceRequestor.h"
#include "nsIThreadRetargetableStreamListener.h"
#include "Intervals.h"
#include "MediaCache.h"
#include "MediaContainerType.h"
@ -503,9 +504,11 @@ public:
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
class Listener final : public nsIStreamListener,
public nsIInterfaceRequestor,
public nsIChannelEventSink
class Listener final
: public nsIStreamListener
, public nsIInterfaceRequestor
, public nsIChannelEventSink
, public nsIThreadRetargetableStreamListener
{
~Listener() {}
public:
@ -516,6 +519,7 @@ public:
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSICHANNELEVENTSINK
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
void Revoke() { mResource = nullptr; }