1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Mozilla Public License Version
6
* 1.1 (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/MPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is Mozilla FastLoad code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 2001
20
* the Initial Developer. All Rights Reserved.
23
* Brendan Eich <brendan@mozilla.org> (original author)
25
* Alternatively, the contents of this file may be used under the terms of
26
* either of the GNU General Public License Version 2 or later (the "GPL"),
27
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the MPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the MPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
39
#include "nsISupports.idl"
40
#include "nsrootidl.idl"
42
interface nsIFastLoadReadControl;
44
interface nsIInputStream;
45
interface nsIOutputStream;
46
interface nsIObjectInputStream;
47
interface nsIObjectOutputStream;
49
[scriptable, uuid(715577db-d9c5-464a-a32e-0a40c29b22d4)]
50
interface nsIFastLoadFileIO : nsISupports
52
readonly attribute nsIInputStream inputStream;
53
readonly attribute nsIOutputStream outputStream;
56
[scriptable, uuid(759e475e-0c23-4dbf-b1b8-78c9369e3072)]
57
interface nsIFastLoadService : nsISupports
59
nsIFile newFastLoadFile(in string aBaseName);
61
nsIObjectInputStream newInputStream(in nsIInputStream aSrcStream);
62
nsIObjectOutputStream newOutputStream(in nsIOutputStream aDestStream);
64
// Flag values for the direction attribute and the aDirectionFlags
65
// parameter to startMuxedDocument.
66
const PRInt32 NS_FASTLOAD_READ = 1;
67
const PRInt32 NS_FASTLOAD_WRITE = 2;
69
attribute nsIObjectInputStream inputStream;
70
attribute nsIObjectOutputStream outputStream;
71
attribute nsIFastLoadFileIO fileIO;
72
readonly attribute PRInt32 direction;
75
* These methods associate a URI object with its spec, for faster select
76
* using the object pointer as a key, rather than the spec string. The
77
* selectMuxedDocument method returns the previously selected URI object,
78
* in case a caller needs to reselect the previous after muxing data for
79
* a given URI synchronously. For the non-blocking or "asynchronous" i/o
80
* case, the caller must select the source URI from the FastLoad multiplex
81
* before writing a new burst of data parsed from the slow-loaded source.
83
* Clients of inputStream and outputStream should try to demultiplex data
84
* from the input stream only if fastLoadService->StartMuxedDocument(uri,
85
* urispec, NS_FASTLOAD_READ) succeeds. If StartMuxedDocument fails with
86
* NS_ERROR_NOT_AVAILABLE, callers should slow-load the documents, muxing
87
* their data to the current output stream.
89
void startMuxedDocument(in nsISupports aURI,
91
in PRInt32 aDirectionFlags);
92
nsISupports selectMuxedDocument(in nsISupports aURI);
93
void endMuxedDocument(in nsISupports aURI);
95
void addDependency(in nsIFile aFile);
97
PRUint32 computeChecksum(in nsIFile aFile,
98
in nsIFastLoadReadControl aControl);
99
void cacheChecksum(in nsIFile aFile,
100
in nsIObjectOutputStream aStream);
102
[noscript] void getFastLoadReferent(inout nsISupports aPtr);
104
[noscript] void readFastLoadPtr(in nsIObjectInputStream aInputStream,
105
inout nsISupports aPtr);
107
[noscript] void writeFastLoadPtr(in nsIObjectOutputStream aOutputStream,
108
in nsISupports aPtr);
111
* Return true if aURISpec identifies a muxed document in the FastLoad
112
* file, false otherwise.
114
boolean hasMuxedDocument(in string aURISpec);
118
#define NS_FASTLOADSERVICE_CLASSNAME "Mozilla FastLoad Service"
120
#define NS_FASTLOADSERVICE_CID \
121
{0xc943093c,0xac94,0x4bee,{0x84,0x0b,0x8b,0x5a,0x6e,0x31,0x4f,0xa7}}
123
#define NS_FASTLOADSERVICE_CONTRACTID \
124
"@mozilla.org/fast-load-service;1"
126
#ifndef nsCOMPtr_h___
127
# include "nsCOMPtr.h"
129
#ifndef __gen_nsIFile_h__
130
# include "nsIFile.h"
132
#ifndef nsIServiceManager_h___
133
# include "nsIServiceManager.h"
136
inline const nsGetServiceByContractID
137
do_GetFastLoadService()
139
return nsGetServiceByContractID(NS_FASTLOADSERVICE_CONTRACTID);
142
inline const nsGetServiceByContractIDWithError
143
do_GetFastLoadService(nsresult *aResultCode)
145
return nsGetServiceByContractIDWithError(NS_FASTLOADSERVICE_CONTRACTID,
150
NS_AddFastLoadDependency(nsIFile* aFile)
152
nsCOMPtr<nsIFastLoadService> fastLoadService(do_GetFastLoadService());
153
if (fastLoadService) {
154
nsresult rv = fastLoadService->AddDependency(aFile);
155
if (NS_FAILED(rv) && rv != NS_ERROR_NOT_AVAILABLE)
161
#if defined(XP_UNIX) || defined(XP_BEOS)
162
#define PLATFORM_FASL_SUFFIX ".mfasl"
163
#elif defined(XP_WIN) || defined(XP_OS2)
164
#define PLATFORM_FASL_SUFFIX ".mfl"