зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1470430 - MediaDocumentStreamListener should allow off main thread OnDataAvailable calls. r=smaug
This patch makes MediaDocumentStreamListener implement the nsIThreadRetargetableStreamListener interface. This allows callers to redirect the OnDataAvailable calls to another thread if possible. Since ImageDocument's use ImageListener which inherits from this class, and we are often viewing large images this way, it would be nice to move the IO to the image IO thread.
This commit is contained in:
Родитель
75500f2673
Коммит
481ecf53ca
|
@ -23,23 +23,30 @@
|
|||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIMultiPartChannel.h"
|
||||
#include "nsProxyRelease.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
MediaDocumentStreamListener::MediaDocumentStreamListener(MediaDocument *aDocument)
|
||||
: mDocument(aDocument)
|
||||
{
|
||||
mDocument = aDocument;
|
||||
}
|
||||
|
||||
MediaDocumentStreamListener::~MediaDocumentStreamListener()
|
||||
{
|
||||
if (mDocument && !NS_IsMainThread()) {
|
||||
nsCOMPtr<nsIEventTarget> mainTarget(do_GetMainThread());
|
||||
NS_ProxyRelease("MediaDocumentStreamListener::mDocument",
|
||||
mainTarget, mDocument.forget());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS(MediaDocumentStreamListener,
|
||||
nsIRequestObserver,
|
||||
nsIStreamListener)
|
||||
nsIStreamListener,
|
||||
nsIThreadRetargetableStreamListener)
|
||||
|
||||
|
||||
void
|
||||
|
@ -99,6 +106,17 @@ MediaDocumentStreamListener::OnDataAvailable(nsIRequest* request,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MediaDocumentStreamListener::CheckListenerChain()
|
||||
{
|
||||
nsCOMPtr<nsIThreadRetargetableStreamListener> retargetable =
|
||||
do_QueryInterface(mNextStream);
|
||||
if (retargetable) {
|
||||
return retargetable->CheckListenerChain();
|
||||
}
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
// default format names for MediaDocument.
|
||||
const char* const MediaDocument::sFormatNames[4] =
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "nsHTMLDocument.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIThreadRetargetableStreamListener.h"
|
||||
|
||||
#define NSMEDIADOCUMENT_PROPERTIES_URI "chrome://global/locale/layout/MediaDocument.properties"
|
||||
|
||||
|
@ -92,7 +93,9 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class MediaDocumentStreamListener: public nsIStreamListener
|
||||
class MediaDocumentStreamListener
|
||||
: public nsIStreamListener
|
||||
, public nsIThreadRetargetableStreamListener
|
||||
{
|
||||
protected:
|
||||
virtual ~MediaDocumentStreamListener();
|
||||
|
@ -101,12 +104,14 @@ public:
|
|||
explicit MediaDocumentStreamListener(MediaDocument* aDocument);
|
||||
void SetStreamListener(nsIStreamListener *aListener);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
|
||||
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
|
||||
|
||||
void DropDocumentRef()
|
||||
{
|
||||
mDocument = nullptr;
|
||||
|
|
Загрузка…
Ссылка в новой задаче