michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * A service that provides methods for synchronously loading a DOM in various ways. michael@0: */ michael@0: michael@0: #ifndef nsSyncLoadService_h__ michael@0: #define nsSyncLoadService_h__ michael@0: michael@0: #include "nscore.h" michael@0: michael@0: class nsIInputStream; michael@0: class nsILoadGroup; michael@0: class nsIStreamListener; michael@0: class nsIURI; michael@0: class nsIPrincipal; michael@0: class nsIDOMDocument; michael@0: class nsIChannel; michael@0: michael@0: class nsSyncLoadService michael@0: { michael@0: public: michael@0: /** michael@0: * Synchronously load the document from the specified URI. michael@0: * michael@0: * @param aURI URI to load the document from. michael@0: * @param aLoaderPrincipal Principal of loading document. For security michael@0: * checks and referrer header. May be null if no michael@0: * security checks should be done. michael@0: * @param aLoadGroup The loadgroup to use for loading the document. michael@0: * @param aForceToXML Whether to parse the document as XML, regardless of michael@0: * content type. michael@0: * @param aResult [out] The document loaded from the URI. michael@0: */ michael@0: static nsresult LoadDocument(nsIURI *aURI, nsIPrincipal *aLoaderPrincipal, michael@0: nsILoadGroup *aLoadGroup, bool aForceToXML, michael@0: nsIDOMDocument** aResult); michael@0: michael@0: /** michael@0: * Read input stream aIn in chunks and deliver synchronously to aListener. michael@0: * michael@0: * @param aIn The stream to be read. michael@0: * @param aListener The listener that will receive michael@0: * OnStartRequest/OnDataAvailable/OnStopRequest michael@0: * notifications. michael@0: * @param aChannel The channel that aIn was opened from. michael@0: */ michael@0: static nsresult PushSyncStreamToListener(nsIInputStream* aIn, michael@0: nsIStreamListener* aListener, michael@0: nsIChannel* aChannel); michael@0: }; michael@0: michael@0: #endif // nsSyncLoadService_h__