Bug 1892041 - Part 1: Update test262 features. r=spidermonkey-reviewers,dminor
[gecko.git] / dom / base / nsSyncLoadService.h
blob0f81f8ec8023fb6cce57e2ec216fb203de8580b0
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/. */
7 /*
8 * A service that provides methods for synchronously loading a DOM in various
9 * ways.
12 #ifndef nsSyncLoadService_h__
13 #define nsSyncLoadService_h__
15 #include "mozilla/AlreadyAddRefed.h"
16 #include "nscore.h"
17 #include "nsIContentPolicy.h"
18 #include "nsILoadInfo.h"
19 #include "nsIReferrerInfo.h"
21 class nsICookieJarSettings;
22 class nsIInputStream;
23 class nsILoadGroup;
24 class nsIStreamListener;
25 class nsIURI;
26 class nsIPrincipal;
27 class nsIChannel;
29 namespace mozilla::dom {
30 class Document;
31 } // namespace mozilla::dom
33 class nsSyncLoadService {
34 public:
35 /**
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
45 * content type.
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);
56 /**
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
62 * notifications.
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__