|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 /* |
|
7 * A service that provides methods for synchronously loading a DOM in various ways. |
|
8 */ |
|
9 |
|
10 #ifndef nsSyncLoadService_h__ |
|
11 #define nsSyncLoadService_h__ |
|
12 |
|
13 #include "nscore.h" |
|
14 |
|
15 class nsIInputStream; |
|
16 class nsILoadGroup; |
|
17 class nsIStreamListener; |
|
18 class nsIURI; |
|
19 class nsIPrincipal; |
|
20 class nsIDOMDocument; |
|
21 class nsIChannel; |
|
22 |
|
23 class nsSyncLoadService |
|
24 { |
|
25 public: |
|
26 /** |
|
27 * Synchronously load the document from the specified URI. |
|
28 * |
|
29 * @param aURI URI to load the document from. |
|
30 * @param aLoaderPrincipal Principal of loading document. For security |
|
31 * checks and referrer header. May be null if no |
|
32 * security checks should be done. |
|
33 * @param aLoadGroup The loadgroup to use for loading the document. |
|
34 * @param aForceToXML Whether to parse the document as XML, regardless of |
|
35 * content type. |
|
36 * @param aResult [out] The document loaded from the URI. |
|
37 */ |
|
38 static nsresult LoadDocument(nsIURI *aURI, nsIPrincipal *aLoaderPrincipal, |
|
39 nsILoadGroup *aLoadGroup, bool aForceToXML, |
|
40 nsIDOMDocument** aResult); |
|
41 |
|
42 /** |
|
43 * Read input stream aIn in chunks and deliver synchronously to aListener. |
|
44 * |
|
45 * @param aIn The stream to be read. |
|
46 * @param aListener The listener that will receive |
|
47 * OnStartRequest/OnDataAvailable/OnStopRequest |
|
48 * notifications. |
|
49 * @param aChannel The channel that aIn was opened from. |
|
50 */ |
|
51 static nsresult PushSyncStreamToListener(nsIInputStream* aIn, |
|
52 nsIStreamListener* aListener, |
|
53 nsIChannel* aChannel); |
|
54 }; |
|
55 |
|
56 #endif // nsSyncLoadService_h__ |