gecko-dev/xpcom/io/nsIFastLoadFileControl.idl

124 строки
5.3 KiB
Plaintext
Исходник Обычный вид История

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla FastLoad code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brendan Eich <brendan@mozilla.org> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsrootidl.idl"
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works for me on optimized and debug gcc2.96, rh7.1. - Better failure codes from nsXULPrototypeScript::Deserialize. - Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize failure, instead of just nulling the FastLoad service's output stream. - Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for good measure. - The needless "Current" adjective in nsIFastLoadService attribute and method names is no more. - Add a do_GetFastLoadService() helper, to use CID instead of contractid, and to let the compiler consolidate the static inline CID. - Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without the checksum verification step when reading a FastLoad file. - Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad service so we don't recompute it when re-opening the FastLoad file as mailnews and other top-levels start up. Fill the checksum cache in EndFastLoad, when the last pseudo-concurrent top-level finishes loading. My hope to compute the checksum while writing the FastLoad file ran afoul of misordered writes. The old code to checksum the in-memory nsFastLoadHeader also was broken on little endian platforms. Now all checksumming is done via a separate read pass over the complete file, save for the header's checksum field, which is summed as if it contained zero. - Track and check FastLoad file dependencies. This required groveling with a bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it and weep. Dependency checking, as well as checksum access and computation, use better-factored nsIFastLoad{File,Read,Write}Control interfaces. - nsBufferedStream::Seek wasn't flushing the buffer when seeking backward within the buffer, but it must, because mCursor bounds the amount to write if the buffer contains the end of file. - Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we don't have to screw around with the bufferying layer when checksumming. Also implement nsIStreamBufferAccess in nsBufferedOutputStream. - nsISeekableOutputStream was bogus, based on a bad state I had put the nsBufferedOutputStream code in on its way from being completely broken when you seek backwards outside of the buffer. Removing this interface required using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful ordering of Close calls (the Reader must close after the Writer or Updater, so that the Reader's underlying, unbuffered input stream can be read by nsFastLoadFileWriter::Close to compute the checksum. - Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style, nsnull vs. 0, useless variable elimination, tortured control flow, AutoString instead of String, and gratuitous ; after nsISupportsUtils.h macro call cleanups.
2001-08-22 00:51:34 +04:00
interface nsIFile;
interface nsISimpleEnumerator;
/**
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works for me on optimized and debug gcc2.96, rh7.1. - Better failure codes from nsXULPrototypeScript::Deserialize. - Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize failure, instead of just nulling the FastLoad service's output stream. - Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for good measure. - The needless "Current" adjective in nsIFastLoadService attribute and method names is no more. - Add a do_GetFastLoadService() helper, to use CID instead of contractid, and to let the compiler consolidate the static inline CID. - Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without the checksum verification step when reading a FastLoad file. - Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad service so we don't recompute it when re-opening the FastLoad file as mailnews and other top-levels start up. Fill the checksum cache in EndFastLoad, when the last pseudo-concurrent top-level finishes loading. My hope to compute the checksum while writing the FastLoad file ran afoul of misordered writes. The old code to checksum the in-memory nsFastLoadHeader also was broken on little endian platforms. Now all checksumming is done via a separate read pass over the complete file, save for the header's checksum field, which is summed as if it contained zero. - Track and check FastLoad file dependencies. This required groveling with a bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it and weep. Dependency checking, as well as checksum access and computation, use better-factored nsIFastLoad{File,Read,Write}Control interfaces. - nsBufferedStream::Seek wasn't flushing the buffer when seeking backward within the buffer, but it must, because mCursor bounds the amount to write if the buffer contains the end of file. - Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we don't have to screw around with the bufferying layer when checksumming. Also implement nsIStreamBufferAccess in nsBufferedOutputStream. - nsISeekableOutputStream was bogus, based on a bad state I had put the nsBufferedOutputStream code in on its way from being completely broken when you seek backwards outside of the buffer. Removing this interface required using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful ordering of Close calls (the Reader must close after the Writer or Updater, so that the Reader's underlying, unbuffered input stream can be read by nsFastLoadFileWriter::Close to compute the checksum. - Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style, nsnull vs. 0, useless variable elimination, tortured control flow, AutoString instead of String, and gratuitous ; after nsISupportsUtils.h macro call cleanups.
2001-08-22 00:51:34 +04:00
* The nsIFastLoadFileControl interface and its subinterfaces are mix-ins for
* classes implementing nsIObjectInputStream and nsIObjectOutputStream, so that
* those stream types can be used with nsIFastLoadService to access and compute
* FastLoad file checksums, update and check FastLoad file dependencies, and
* multiplex documents loaded via non-blocking i/o.
*
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works for me on optimized and debug gcc2.96, rh7.1. - Better failure codes from nsXULPrototypeScript::Deserialize. - Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize failure, instead of just nulling the FastLoad service's output stream. - Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for good measure. - The needless "Current" adjective in nsIFastLoadService attribute and method names is no more. - Add a do_GetFastLoadService() helper, to use CID instead of contractid, and to let the compiler consolidate the static inline CID. - Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without the checksum verification step when reading a FastLoad file. - Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad service so we don't recompute it when re-opening the FastLoad file as mailnews and other top-levels start up. Fill the checksum cache in EndFastLoad, when the last pseudo-concurrent top-level finishes loading. My hope to compute the checksum while writing the FastLoad file ran afoul of misordered writes. The old code to checksum the in-memory nsFastLoadHeader also was broken on little endian platforms. Now all checksumming is done via a separate read pass over the complete file, save for the header's checksum field, which is summed as if it contained zero. - Track and check FastLoad file dependencies. This required groveling with a bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it and weep. Dependency checking, as well as checksum access and computation, use better-factored nsIFastLoad{File,Read,Write}Control interfaces. - nsBufferedStream::Seek wasn't flushing the buffer when seeking backward within the buffer, but it must, because mCursor bounds the amount to write if the buffer contains the end of file. - Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we don't have to screw around with the bufferying layer when checksumming. Also implement nsIStreamBufferAccess in nsBufferedOutputStream. - nsISeekableOutputStream was bogus, based on a bad state I had put the nsBufferedOutputStream code in on its way from being completely broken when you seek backwards outside of the buffer. Removing this interface required using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful ordering of Close calls (the Reader must close after the Writer or Updater, so that the Reader's underlying, unbuffered input stream can be read by nsFastLoadFileWriter::Close to compute the checksum. - Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style, nsnull vs. 0, useless variable elimination, tortured control flow, AutoString instead of String, and gratuitous ; after nsISupportsUtils.h macro call cleanups.
2001-08-22 00:51:34 +04:00
* If an nsIObjectInputStream class doesn't support nsIFastLoadReadControl, or
* an nsIObjectOutputStream class doesn't support nsIFastLoadWriteControl, that
* implementation may still be useful for object serialization, but it can't be
* used to read or write a Mozilla FastLoad file.
*/
[scriptable, uuid(e7c8c14f-c273-4e70-826f-b85864303dc6)]
interface nsIFastLoadFileControl : nsISupports
{
/**
* Get the recorded checksum value from the FastLoad file header.
*/
readonly attribute PRUint32 checksum;
/**
* Multiplexed document control methods. A FastLoad file may contain
* multiple interleaved documents identified by a URI specifier string,
* and indexed for fast multiplexor select by an opaque URI object key.
* You StartMuxedDocument when initiating a document load, then Select
* before every batch of calls to (de)serialize document data, and End
* when the load completes.
*
* Document multiplexing is necessary to support incremental FastLoad
* development in a non-blocking i/o architecture such as Mozilla, where
* some (but not all, at first, or for a while during development) of the
* results of parsing and compiling various inputs can be multiplexed to
* or from a FastLoad file.
*
* Note: Select returns the previously selected URI object in case the
* caller is synchronously selecting and writing data to the FastLoad
* file, so the caller can reselect the previous URI and return to code
* the continues to write FastLoad data for the previous URI, unaware of
* the nested select/write/reselect.
*/
void startMuxedDocument(in nsISupports aURI, in string aURISpec);
nsISupports selectMuxedDocument(in nsISupports aURI);
void endMuxedDocument(in nsISupports aURI);
Reduce seeks outside the FastLoad file's underlying stream buffer (195010, r=ben, sr=bryner). - Pass null scope objects into nsIScriptContext::Compile{EventHandler,Script} when precompiling for brutal sharing. The JS engine does not need a non-null object parameter for static scope. That parameter can be non-null only if it helps the compiler "pre-bind" functions to the same scope object that they'll be parented by when executing, but with brutal sharing, functions are precompiled once and executed against many different scope objects. - A problem in XUL FastLoad was that it would serialize master .xul document out-of-line scripts (those included via script src= from non-overlay, "master" .xul docs) far from the place in the FastLoad file where XUL prototype script info was serialized for the <script src=> tag itself. I fixed that so that, unless the out-of-line script was previously serialized (by a different src= reference from another .xul file), the OOL script data immediately follows the proto-script info in the FastLoad file. This required adding a SerializeOutOfLine method to nsXULPrototypeScript, which restores symmetry by matching the existing DeserializeOutOfLine(Script) (note: I dropped the redundant "Script" from the end of the latter method's name. We need SerializeOutOfLine to handle overlay OOL scripts. They are serialized by nsXULDocument::OnStreamComplete, because that code knows the difference between an overlay and a master doc. This removes all trace of FastLoad writing from nsXULPrototypeScript::Compile -- FastLoad stuff didn't belong there, not only because we now want to write master OOL scripts later, when walking the master XUL prototype doc's element tree, but also for modularity reasons. The caller knows about FastLoad, nsXULPrototypeScript::Compile does just what its name implies. There are 132 seeks with the patch, only 49 of which dump the underlying file stream's buffer, vs. 133 seeks without the patch, 87 of which dump the buffer. - Nit-picked some comments to fit in 80 columns, and made other cosmetic fixes. - Implicated the nsXULDocument::mIsWritingFastLoad flag from the useXULCache "is the XUL cache enabled?" flag, so other places that test mIsWritingFastLoad don't have to query whether the cache is enabled. - Added METERING synchronous meter-dumping to /tmp/bufstats, only ifdef DEBUG_brendan, in netwerk/base/src/nsBufferedStreams.cpp. - Added the deferred seek optimization from the first patch in bug 195010 to nsFastLoadFile.cpp. - Fixed nsFastLoadFileReader so it overrides readSegments as well as read. This catches up with the interface extension made to nsIInputStream to add readSegments. The nsFastLoadFileReader extends nsBinaryInputStream, which is a concrete class, and overrides Read in order to snoop on *all* bytes read. It does this in order to demultiplex documents interleaved when the FastLoad file was written. But since the readSegments move into nsIInputStream.idl, certain primitives in nsBinaryStream.cpp, e.g., nsBinaryInputStream::ReadCString, have used ReadSegments, not Read, to consume parts of the underlying stream (to read the C string's chars, in that example), and the FastLoad file implementation has not accounted for those bytes. - Added a new method to nsIFastLoadFileControl and its impls: hasMuxedDocument. This is needed when serializing master XUL doc OOL scripts, because we must not serialize twice, and any OOL script that other XUL docs can include via script src= could already be in the FastLoad mux. /be
2003-04-12 05:34:11 +04:00
/**
* Return true if aURISpec identifies a muxed document in the FastLoad
* file, false otherwise.
*/
boolean hasMuxedDocument(in string aURISpec);
};
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works for me on optimized and debug gcc2.96, rh7.1. - Better failure codes from nsXULPrototypeScript::Deserialize. - Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize failure, instead of just nulling the FastLoad service's output stream. - Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for good measure. - The needless "Current" adjective in nsIFastLoadService attribute and method names is no more. - Add a do_GetFastLoadService() helper, to use CID instead of contractid, and to let the compiler consolidate the static inline CID. - Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without the checksum verification step when reading a FastLoad file. - Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad service so we don't recompute it when re-opening the FastLoad file as mailnews and other top-levels start up. Fill the checksum cache in EndFastLoad, when the last pseudo-concurrent top-level finishes loading. My hope to compute the checksum while writing the FastLoad file ran afoul of misordered writes. The old code to checksum the in-memory nsFastLoadHeader also was broken on little endian platforms. Now all checksumming is done via a separate read pass over the complete file, save for the header's checksum field, which is summed as if it contained zero. - Track and check FastLoad file dependencies. This required groveling with a bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it and weep. Dependency checking, as well as checksum access and computation, use better-factored nsIFastLoad{File,Read,Write}Control interfaces. - nsBufferedStream::Seek wasn't flushing the buffer when seeking backward within the buffer, but it must, because mCursor bounds the amount to write if the buffer contains the end of file. - Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we don't have to screw around with the bufferying layer when checksumming. Also implement nsIStreamBufferAccess in nsBufferedOutputStream. - nsISeekableOutputStream was bogus, based on a bad state I had put the nsBufferedOutputStream code in on its way from being completely broken when you seek backwards outside of the buffer. Removing this interface required using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful ordering of Close calls (the Reader must close after the Writer or Updater, so that the Reader's underlying, unbuffered input stream can be read by nsFastLoadFileWriter::Close to compute the checksum. - Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style, nsnull vs. 0, useless variable elimination, tortured control flow, AutoString instead of String, and gratuitous ; after nsISupportsUtils.h macro call cleanups.
2001-08-22 00:51:34 +04:00
[scriptable, uuid(652ecec6-d40b-45b6-afef-641d6c63a35b)]
interface nsIFastLoadReadControl : nsIFastLoadFileControl
{
/**
* Computes the correct checksum of the FastLoad file, independent of the
* header's checksum value. The header checksum field is treated as zero
* when computing the checksum.
*/
PRUint32 computeChecksum();
/**
* Get the collection of dependency nsIFile instances recorded during the
* FastLoad file write or read/update process, and checked during the read
* process to invalidate the FastLoad file if any dependencies are newer.
*/
readonly attribute nsISimpleEnumerator dependencies;
};
[scriptable, uuid(2ad6e9e6-1379-4e45-a899-a54b27ff915c)]
interface nsIFastLoadWriteControl : nsIFastLoadFileControl
{
/**
* Add a file dependency of the FastLoad file (e.g., a .jar file) to the
* set of dependencies that trigger regeneration if any dependency has a
* last-modified-time greater than the FastLoad file's mtime.
*/
void addDependency(in nsIFile aFile);
};