1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 /* 8 * A service that provides methods for synchronously loading a DOM in various 9 * ways. 10 */ 11 12 #ifndef nsSyncLoadService_h__ 13 #define nsSyncLoadService_h__ 14 15 #include "mozilla/AlreadyAddRefed.h" 16 #include "nscore.h" 17 #include "nsIContentPolicy.h" 18 #include "nsILoadInfo.h" 19 #include "nsIReferrerInfo.h" 20 21 class nsICookieJarSettings; 22 class nsIInputStream; 23 class nsILoadGroup; 24 class nsIStreamListener; 25 class nsIURI; 26 class nsIPrincipal; 27 class nsIChannel; 28 29 namespace mozilla { 30 namespace dom { 31 class Document; 32 } 33 } // namespace mozilla 34 35 class nsSyncLoadService { 36 public: 37 /** 38 * Synchronously load the document from the specified URI. 39 * 40 * @param aURI URI to load the document from. 41 * @param aContentPolicyType contentPolicyType to be set on the channel 42 * @param aLoaderPrincipal Principal of loading document. For security 43 * checks and referrer header. 44 * @param aSecurityFlags securityFlags to be set on the channel 45 * @param aLoadGroup The loadgroup to use for loading the document. 46 * @param aForceToXML Whether to parse the document as XML, regardless of 47 * content type. 48 * @param referrerPolicy Referrer policy. 49 * @param aResult [out] The document loaded from the URI. 50 */ 51 static nsresult LoadDocument( 52 nsIURI* aURI, nsContentPolicyType aContentPolicyType, 53 nsIPrincipal* aLoaderPrincipal, nsSecurityFlags aSecurityFlags, 54 nsILoadGroup* aLoadGroup, nsICookieJarSettings* aCookieJarSettings, 55 bool aForceToXML, mozilla::dom::ReferrerPolicy aReferrerPolicy, 56 mozilla::dom::Document** aResult); 57 58 /** 59 * Read input stream aIn in chunks and deliver synchronously to aListener. 60 * 61 * @param aIn The stream to be read. The ownership of this stream is taken. 62 * @param aListener The listener that will receive 63 * OnStartRequest/OnDataAvailable/OnStopRequest 64 * notifications. 65 * @param aChannel The channel that aIn was opened from. 66 */ 67 static nsresult PushSyncStreamToListener(already_AddRefed<nsIInputStream> aIn, 68 nsIStreamListener* aListener, 69 nsIChannel* aChannel); 70 }; 71 72 #endif // nsSyncLoadService_h__ 73