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/. */
8 * A service that provides methods for synchronously loading a DOM in various
12 #ifndef nsSyncLoadService_h__
13 #define nsSyncLoadService_h__
15 #include "mozilla/AlreadyAddRefed.h"
17 #include "nsIContentPolicy.h"
18 #include "nsILoadInfo.h"
19 #include "nsIReferrerInfo.h"
21 class nsICookieJarSettings
;
24 class nsIStreamListener
;
29 namespace mozilla::dom
{
31 } // namespace mozilla::dom
33 class nsSyncLoadService
{
36 * Synchronously load the document from the specified URI.
38 * @param aURI URI to load the document from.
39 * @param aContentPolicyType contentPolicyType to be set on the channel
40 * @param aLoaderPrincipal Principal of loading document. For security
41 * checks and referrer header.
42 * @param aSecurityFlags securityFlags to be set on the channel
43 * @param aLoadGroup The loadgroup to use for loading the document.
44 * @param aForceToXML Whether to parse the document as XML, regardless of
46 * @param referrerPolicy Referrer policy.
47 * @param aResult [out] The document loaded from the URI.
49 static nsresult
LoadDocument(
50 nsIURI
* aURI
, nsContentPolicyType aContentPolicyType
,
51 nsIPrincipal
* aLoaderPrincipal
, nsSecurityFlags aSecurityFlags
,
52 nsILoadGroup
* aLoadGroup
, nsICookieJarSettings
* aCookieJarSettings
,
53 bool aForceToXML
, mozilla::dom::ReferrerPolicy aReferrerPolicy
,
54 mozilla::dom::Document
** aResult
);
57 * Read input stream aIn in chunks and deliver synchronously to aListener.
59 * @param aIn The stream to be read. The ownership of this stream is taken.
60 * @param aListener The listener that will receive
61 * OnStartRequest/OnDataAvailable/OnStopRequest
63 * @param aChannel The channel that aIn was opened from.
65 static nsresult
PushSyncStreamToListener(already_AddRefed
<nsIInputStream
> aIn
,
66 nsIStreamListener
* aListener
,
67 nsIChannel
* aChannel
);
70 #endif // nsSyncLoadService_h__