Bug 1574372 - Move nsDocumentOpenInfo into the header. r=bzbarsky

Differential Revision: https://phabricator.services.mozilla.com/D56133

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matt Woodrow 2019-12-17 03:01:50 +00:00
Родитель 8fe54626de
Коммит af461a2c9d
2 изменённых файлов: 100 добавлений и 98 удалений

Просмотреть файл

@ -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<nsIURIContentListener> m_contentListener;
/**
* The stream listener to forward nsIStreamListener notifications
* to. This is set once the load is dispatched.
*/
nsCOMPtr<nsIStreamListener> m_targetStreamListener;
/**
* A pointer to the entity that originated the load. We depend on getting
* things like nsIURIContentListeners, nsIDOMWindows, etc off of it.
*/
nsCOMPtr<nsIInterfaceRequestor> 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<nsURILoader> mURILoader;
/**
* Limit of data conversion depth to prevent infinite conversion loops
*/
uint32_t mDataConversionDepthLimit;
};
NS_IMPL_ADDREF(nsDocumentOpenInfo)
NS_IMPL_RELEASE(nsDocumentOpenInfo)

Просмотреть файл

@ -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<nsIURIContentListener> m_contentListener;
/**
* The stream listener to forward nsIStreamListener notifications
* to. This is set once the load is dispatched.
*/
nsCOMPtr<nsIStreamListener> m_targetStreamListener;
/**
* A pointer to the entity that originated the load. We depend on getting
* things like nsIURIContentListeners, nsIDOMWindows, etc off of it.
*/
nsCOMPtr<nsIInterfaceRequestor> 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<nsURILoader> mURILoader;
/**
* Limit of data conversion depth to prevent infinite conversion loops
*/
uint32_t mDataConversionDepthLimit;
};
#endif /* nsURILoader_h__ */