From af461a2c9dbcb7f44183578adad4c926b5ffb65c Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Tue, 17 Dec 2019 03:01:50 +0000 Subject: [PATCH] Bug 1574372 - Move nsDocumentOpenInfo into the header. r=bzbarsky Differential Revision: https://phabricator.services.mozilla.com/D56133 --HG-- extra : moz-landing-system : lando --- uriloader/base/nsURILoader.cpp | 98 -------------------------------- uriloader/base/nsURILoader.h | 100 +++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 98 deletions(-) diff --git a/uriloader/base/nsURILoader.cpp b/uriloader/base/nsURILoader.cpp index 4177201e7e23..570689c15af8 100644 --- a/uriloader/base/nsURILoader.cpp +++ b/uriloader/base/nsURILoader.cpp @@ -60,104 +60,6 @@ static bool InitPreferences() { return true; } -/** - * The nsDocumentOpenInfo contains the state required when a single - * document is being opened in order to discover the content type... - * Each instance remains alive until its target URL has been loaded - * (or aborted). - */ -class nsDocumentOpenInfo final : public nsIStreamListener, - public nsIThreadRetargetableStreamListener { - public: - // Real constructor - // aFlags is a combination of the flags on nsIURILoader - nsDocumentOpenInfo(nsIInterfaceRequestor* aWindowContext, uint32_t aFlags, - nsURILoader* aURILoader); - - NS_DECL_THREADSAFE_ISUPPORTS - - /** - * Prepares this object for receiving data. The stream - * listener methods of this class must not be called before calling this - * method. - */ - nsresult Prepare(); - - // Call this (from OnStartRequest) to attempt to find an nsIStreamListener to - // take the data off our hands. - nsresult DispatchContent(nsIRequest* request, nsISupports* aCtxt); - - // Call this if we need to insert a stream converter from aSrcContentType to - // aOutContentType into the StreamListener chain. DO NOT call it if the two - // types are the same, since no conversion is needed in that case. - nsresult ConvertData(nsIRequest* request, nsIURIContentListener* aListener, - const nsACString& aSrcContentType, - const nsACString& aOutContentType); - - /** - * Function to attempt to use aListener to handle the load. If - * true is returned, nothing else needs to be done; if false - * is returned, then a different way of handling the load should be - * tried. - */ - bool TryContentListener(nsIURIContentListener* aListener, - nsIChannel* aChannel); - - // nsIRequestObserver methods: - NS_DECL_NSIREQUESTOBSERVER - - // nsIStreamListener methods: - NS_DECL_NSISTREAMLISTENER - - // nsIThreadRetargetableStreamListener - NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER - protected: - ~nsDocumentOpenInfo(); - - protected: - /** - * The first content listener to try dispatching data to. Typically - * the listener associated with the entity that originated the load. - */ - nsCOMPtr m_contentListener; - - /** - * The stream listener to forward nsIStreamListener notifications - * to. This is set once the load is dispatched. - */ - nsCOMPtr m_targetStreamListener; - - /** - * A pointer to the entity that originated the load. We depend on getting - * things like nsIURIContentListeners, nsIDOMWindows, etc off of it. - */ - nsCOMPtr m_originalContext; - - /** - * IS_CONTENT_PREFERRED is used for the boolean to pass to CanHandleContent - * (also determines whether we use CanHandleContent or IsPreferred). - * DONT_RETARGET means that we will only try m_originalContext, no other - * listeners. - */ - uint32_t mFlags; - - /** - * The type of the data we will be trying to dispatch. - */ - nsCString mContentType; - - /** - * Reference to the URILoader service so we can access its list of - * nsIURIContentListeners. - */ - RefPtr mURILoader; - - /** - * Limit of data conversion depth to prevent infinite conversion loops - */ - uint32_t mDataConversionDepthLimit; -}; - NS_IMPL_ADDREF(nsDocumentOpenInfo) NS_IMPL_RELEASE(nsDocumentOpenInfo) diff --git a/uriloader/base/nsURILoader.h b/uriloader/base/nsURILoader.h index 809348822646..80ed616a9e90 100644 --- a/uriloader/base/nsURILoader.h +++ b/uriloader/base/nsURILoader.h @@ -15,6 +15,8 @@ #include "nsString.h" #include "nsIWeakReference.h" #include "mozilla/Attributes.h" +#include "nsIStreamListener.h" +#include "nsIThreadRetargetableStreamListener.h" #include "mozilla/Logging.h" @@ -54,4 +56,102 @@ class nsURILoader final : public nsIURILoader { friend class nsDocumentOpenInfo; }; +/** + * The nsDocumentOpenInfo contains the state required when a single + * document is being opened in order to discover the content type... + * Each instance remains alive until its target URL has been loaded + * (or aborted). + */ +class nsDocumentOpenInfo final : public nsIStreamListener, + public nsIThreadRetargetableStreamListener { + public: + // Real constructor + // aFlags is a combination of the flags on nsIURILoader + nsDocumentOpenInfo(nsIInterfaceRequestor* aWindowContext, uint32_t aFlags, + nsURILoader* aURILoader); + + NS_DECL_THREADSAFE_ISUPPORTS + + /** + * Prepares this object for receiving data. The stream + * listener methods of this class must not be called before calling this + * method. + */ + nsresult Prepare(); + + // Call this (from OnStartRequest) to attempt to find an nsIStreamListener to + // take the data off our hands. + nsresult DispatchContent(nsIRequest* request, nsISupports* aCtxt); + + // Call this if we need to insert a stream converter from aSrcContentType to + // aOutContentType into the StreamListener chain. DO NOT call it if the two + // types are the same, since no conversion is needed in that case. + nsresult ConvertData(nsIRequest* request, nsIURIContentListener* aListener, + const nsACString& aSrcContentType, + const nsACString& aOutContentType); + + /** + * Function to attempt to use aListener to handle the load. If + * true is returned, nothing else needs to be done; if false + * is returned, then a different way of handling the load should be + * tried. + */ + bool TryContentListener(nsIURIContentListener* aListener, + nsIChannel* aChannel); + + // nsIRequestObserver methods: + NS_DECL_NSIREQUESTOBSERVER + + // nsIStreamListener methods: + NS_DECL_NSISTREAMLISTENER + + // nsIThreadRetargetableStreamListener + NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER + protected: + ~nsDocumentOpenInfo(); + + protected: + /** + * The first content listener to try dispatching data to. Typically + * the listener associated with the entity that originated the load. + */ + nsCOMPtr m_contentListener; + + /** + * The stream listener to forward nsIStreamListener notifications + * to. This is set once the load is dispatched. + */ + nsCOMPtr m_targetStreamListener; + + /** + * A pointer to the entity that originated the load. We depend on getting + * things like nsIURIContentListeners, nsIDOMWindows, etc off of it. + */ + nsCOMPtr m_originalContext; + + /** + * IS_CONTENT_PREFERRED is used for the boolean to pass to CanHandleContent + * (also determines whether we use CanHandleContent or IsPreferred). + * DONT_RETARGET means that we will only try m_originalContext, no other + * listeners. + */ + uint32_t mFlags; + + /** + * The type of the data we will be trying to dispatch. + */ + nsCString mContentType; + + /** + * Reference to the URILoader service so we can access its list of + * nsIURIContentListeners. + */ + RefPtr mURILoader; + + /** + * Limit of data conversion depth to prevent infinite conversion loops + */ + uint32_t mDataConversionDepthLimit; +}; + #endif /* nsURILoader_h__ */