2018-11-30 19:52:05 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2000-01-13 09:11:01 +00:00
|
|
|
|
2012-08-28 12:41:04 +00:00
|
|
|
#include "ipc/IPCMessageUtils.h"
|
2010-10-21 18:36:13 +00:00
|
|
|
|
2000-01-13 09:11:01 +00:00
|
|
|
#include "nsBufferedStreams.h"
|
2006-01-02 02:30:32 +00:00
|
|
|
#include "nsStreamUtils.h"
|
2010-10-21 18:36:13 +00:00
|
|
|
#include "nsNetCID.h"
|
|
|
|
#include "nsIClassInfoImpl.h"
|
2019-08-15 17:25:51 +00:00
|
|
|
#include "mozilla/DebugOnly.h"
|
2012-08-23 02:13:54 +00:00
|
|
|
#include "mozilla/ipc/InputStreamUtils.h"
|
2013-01-15 12:22:03 +00:00
|
|
|
#include <algorithm>
|
2000-01-13 09:11:01 +00:00
|
|
|
|
2001-07-31 19:05:34 +00:00
|
|
|
#ifdef DEBUG_brendan
|
|
|
|
# define METERING
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef METERING
|
2004-05-06 03:45:34 +00:00
|
|
|
# include <stdio.h>
|
2001-07-31 19:05:34 +00:00
|
|
|
# define METER(x) x
|
|
|
|
# define MAX_BIG_SEEKS 20
|
|
|
|
|
|
|
|
static struct {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mSeeksWithinBuffer;
|
|
|
|
uint32_t mSeeksOutsideBuffer;
|
|
|
|
uint32_t mBufferReadUponSeek;
|
|
|
|
uint32_t mBufferUnreadUponSeek;
|
|
|
|
uint32_t mBytesReadFromBuffer;
|
|
|
|
uint32_t mBigSeekIndex;
|
2001-07-31 19:05:34 +00:00
|
|
|
struct {
|
2012-08-22 15:56:38 +00:00
|
|
|
int64_t mOldOffset;
|
|
|
|
int64_t mNewOffset;
|
2001-07-31 19:05:34 +00:00
|
|
|
} mBigSeek[MAX_BIG_SEEKS];
|
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-21 20:51:34 +00:00
|
|
|
} bufstats;
|
2001-07-31 19:05:34 +00:00
|
|
|
#else
|
|
|
|
# define METER(x) /* nothing */
|
|
|
|
#endif
|
|
|
|
|
2012-08-23 02:13:54 +00:00
|
|
|
using namespace mozilla::ipc;
|
2019-08-15 17:25:51 +00:00
|
|
|
using mozilla::DebugOnly;
|
2016-09-29 04:20:00 +00:00
|
|
|
using mozilla::Maybe;
|
2019-03-20 14:40:44 +00:00
|
|
|
using mozilla::MutexAutoLock;
|
2016-09-29 04:20:00 +00:00
|
|
|
using mozilla::Nothing;
|
|
|
|
using mozilla::Some;
|
2012-08-23 02:13:54 +00:00
|
|
|
|
2000-01-13 09:11:01 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsBufferedStream
|
|
|
|
|
|
|
|
nsBufferedStream::nsBufferedStream()
|
2018-06-14 08:19:07 +00:00
|
|
|
: mBufferSize(0),
|
|
|
|
mBuffer(nullptr),
|
2018-04-13 13:01:28 +00:00
|
|
|
mBufferStartOffset(0),
|
|
|
|
mCursor(0),
|
|
|
|
mFillPoint(0),
|
|
|
|
mStream(nullptr),
|
|
|
|
mBufferDisabled(false),
|
|
|
|
mEOF(false),
|
|
|
|
mGetBufferCount(0) {}
|
2000-01-13 09:11:01 +00:00
|
|
|
|
|
|
|
nsBufferedStream::~nsBufferedStream() { Close(); }
|
|
|
|
|
Bug 1496581 - Split nsISeekableStream in 2 classes: nsISeekableStream and nsITellableStream, f=mayhemer, r=froydnj
In the current code there are 3 main issues:
1. nsFileStream is not really thread-safe. There is nothing to protect the
internal members and we see crashes.
2. nsPipeInputStream doesn't implement ::Seek() method and that caused issues
in devtools when a nsHttpChannel sends POST data using a pipe. In order to fix
this, bug 1494176 added a check in nsHttpChannel: if the stream doesn't
implement ::Seek(), let's clone it. This was an hack around nsPipeInputStream,
and it's bad.
3. When nsHttpChannel sends POST data using a file stream, nsFileStream does
I/O on main-thread because of the issue 2. Plus, ::Seek() is called on the
main-thread causing issue 1.
Note that nsPipeInputStream implements only ::Tell(), of the nsISeekableStream
methods. It doesn't implement ::Seek() and it doesn't implement ::SetEOF().
With this patch I want to fix point 2 and point 3 (and consequentially issue 1
- but we need a separate fix for it - follow up). The patch does:
1. it splits nsISeekableStream in 2 interfaces: nsITellableStream and
nsISeekableStream.
2. nsPipeInputStream implements only nsITellableStream. Doing this, we don't
need the ::Seek() check for point 2 in nsHttpChannel: a simple QI check is
enough.
3. Because we don't call ::Seek() in nsHttpChannel, nsFileStream doesn't do I/O
on the main-thread, and we don't crash doing so.
2018-10-18 11:35:35 +00:00
|
|
|
NS_IMPL_ISUPPORTS(nsBufferedStream, nsITellableStream, nsISeekableStream)
|
2000-01-13 09:11:01 +00:00
|
|
|
|
2019-03-05 18:43:02 +00:00
|
|
|
nsresult nsBufferedStream::Init(nsISupports* aStream, uint32_t bufferSize) {
|
|
|
|
NS_ASSERTION(aStream, "need to supply a stream");
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ASSERTION(mStream == nullptr, "already inited");
|
2019-03-05 18:43:02 +00:00
|
|
|
mStream = aStream; // we keep a reference until nsBufferedStream::Close
|
2000-02-04 07:31:43 +00:00
|
|
|
mBufferSize = bufferSize;
|
2000-01-13 09:11:01 +00:00
|
|
|
mBufferStartOffset = 0;
|
|
|
|
mCursor = 0;
|
2015-01-28 09:00:40 +00:00
|
|
|
mBuffer = new (mozilla::fallible) char[bufferSize];
|
2017-01-26 22:15:00 +00:00
|
|
|
if (mBuffer == nullptr) {
|
2000-01-13 09:11:01 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
2000-01-13 09:11:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:21:06 +00:00
|
|
|
void nsBufferedStream::Close() {
|
2019-03-05 18:43:02 +00:00
|
|
|
// Drop the reference from nsBufferedStream::Init()
|
|
|
|
mStream = nullptr;
|
2000-08-22 07:03:33 +00:00
|
|
|
if (mBuffer) {
|
2000-02-21 05:22:43 +00:00
|
|
|
delete[] mBuffer;
|
2012-07-30 14:20:58 +00:00
|
|
|
mBuffer = nullptr;
|
2000-01-13 09:11:01 +00:00
|
|
|
mBufferSize = 0;
|
|
|
|
mBufferStartOffset = 0;
|
|
|
|
mCursor = 0;
|
2006-01-02 02:30:32 +00:00
|
|
|
mFillPoint = 0;
|
2000-01-13 09:11:01 +00:00
|
|
|
}
|
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 01:34:11 +00:00
|
|
|
#ifdef METERING
|
|
|
|
{
|
|
|
|
static FILE* tfp;
|
|
|
|
if (!tfp) {
|
|
|
|
tfp = fopen("/tmp/bufstats", "w");
|
2017-01-26 22:15:00 +00:00
|
|
|
if (tfp) {
|
2013-09-19 19:28:26 +00:00
|
|
|
setvbuf(tfp, nullptr, _IOLBF, 0);
|
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 01:34:11 +00:00
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
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 01:34:11 +00:00
|
|
|
if (tfp) {
|
|
|
|
fprintf(tfp, "seeks within buffer: %u\n", bufstats.mSeeksWithinBuffer);
|
|
|
|
fprintf(tfp, "seeks outside buffer: %u\n",
|
|
|
|
bufstats.mSeeksOutsideBuffer);
|
|
|
|
fprintf(tfp, "buffer read on seek: %u\n",
|
|
|
|
bufstats.mBufferReadUponSeek);
|
|
|
|
fprintf(tfp, "buffer unread on seek: %u\n",
|
|
|
|
bufstats.mBufferUnreadUponSeek);
|
|
|
|
fprintf(tfp, "bytes read from buffer: %u\n",
|
|
|
|
bufstats.mBytesReadFromBuffer);
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < bufstats.mBigSeekIndex; i++) {
|
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 01:34:11 +00:00
|
|
|
fprintf(tfp, "bigseek[%u] = {old: %u, new: %u}\n", i,
|
|
|
|
bufstats.mBigSeek[i].mOldOffset,
|
|
|
|
bufstats.mBigSeek[i].mNewOffset);
|
|
|
|
}
|
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
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 01:34:11 +00:00
|
|
|
#endif
|
2000-01-13 09:11:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBufferedStream::Seek(int32_t whence, int64_t offset) {
|
2017-01-26 22:15:00 +00:00
|
|
|
if (mStream == nullptr) {
|
2000-01-13 09:11:01 +00:00
|
|
|
return NS_BASE_STREAM_CLOSED;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
|
|
|
|
2000-02-04 07:31:43 +00:00
|
|
|
// If the underlying stream isn't a random access store, then fail early.
|
|
|
|
// We could possibly succeed for the case where the seek position denotes
|
|
|
|
// something that happens to be read into the buffer, but that would make
|
|
|
|
// the failure data-dependent.
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsISeekableStream> ras = do_QueryInterface(mStream, &rv);
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2018-05-24 05:52:31 +00:00
|
|
|
NS_WARNING("mStream doesn't QI to nsISeekableStream");
|
2017-01-26 22:15:00 +00:00
|
|
|
return rv;
|
|
|
|
}
|
2000-02-04 07:31:43 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int64_t absPos = 0;
|
2000-02-04 07:31:43 +00:00
|
|
|
switch (whence) {
|
|
|
|
case nsISeekableStream::NS_SEEK_SET:
|
|
|
|
absPos = offset;
|
|
|
|
break;
|
|
|
|
case nsISeekableStream::NS_SEEK_CUR:
|
2004-04-13 14:37:53 +00:00
|
|
|
absPos = mBufferStartOffset;
|
|
|
|
absPos += mCursor;
|
|
|
|
absPos += offset;
|
2000-02-04 07:31:43 +00:00
|
|
|
break;
|
|
|
|
case nsISeekableStream::NS_SEEK_END:
|
|
|
|
absPos = -1;
|
|
|
|
break;
|
|
|
|
default:
|
2018-06-18 05:43:11 +00:00
|
|
|
MOZ_ASSERT_UNREACHABLE("bogus seek whence parameter");
|
2000-02-04 07:31:43 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
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-21 20:51:34 +00:00
|
|
|
// Let mCursor point into the existing buffer if the new position is
|
|
|
|
// between the current cursor and the mFillPoint "fencepost" -- the
|
|
|
|
// client may never get around to a Read or Write after this Seek.
|
|
|
|
// Read and Write worry about flushing and filling in that event.
|
2011-10-18 20:17:10 +00:00
|
|
|
// But if we're at EOF, make sure to pass the seek through to the
|
|
|
|
// underlying stream, because it may have auto-closed itself and
|
|
|
|
// needs to reopen.
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t offsetInBuffer = uint32_t(absPos - mBufferStartOffset);
|
2011-10-18 20:17:10 +00:00
|
|
|
if (offsetInBuffer <= mFillPoint && !mEOF) {
|
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-21 20:51:34 +00:00
|
|
|
METER(bufstats.mSeeksWithinBuffer++);
|
2001-07-31 19:05:34 +00:00
|
|
|
mCursor = offsetInBuffer;
|
2000-01-13 09:11:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-02-04 07:31:43 +00:00
|
|
|
|
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-21 20:51:34 +00:00
|
|
|
METER(bufstats.mSeeksOutsideBuffer++);
|
|
|
|
METER(bufstats.mBufferReadUponSeek += mCursor);
|
|
|
|
METER(bufstats.mBufferUnreadUponSeek += mFillPoint - mCursor);
|
2000-02-04 07:31:43 +00:00
|
|
|
rv = Flush();
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
NS_WARNING(
|
|
|
|
"(debug) Flush returned error within nsBufferedStream::Seek, so we "
|
|
|
|
"exit early.");
|
|
|
|
#endif
|
|
|
|
return rv;
|
|
|
|
}
|
2000-02-04 07:31:43 +00:00
|
|
|
|
|
|
|
rv = ras->Seek(whence, offset);
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
NS_WARNING(
|
|
|
|
"(debug) Error: ras->Seek() returned error within "
|
|
|
|
"nsBufferedStream::Seek, so we exit early.");
|
|
|
|
#endif
|
|
|
|
return rv;
|
|
|
|
}
|
2000-02-04 07:31:43 +00:00
|
|
|
|
2011-10-18 20:17:10 +00:00
|
|
|
mEOF = false;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2011-10-18 20:17:10 +00:00
|
|
|
// Recompute whether the offset we're seeking to is in our buffer.
|
|
|
|
// Note that we need to recompute because Flush() might have
|
|
|
|
// changed mBufferStartOffset.
|
2012-08-22 15:56:38 +00:00
|
|
|
offsetInBuffer = uint32_t(absPos - mBufferStartOffset);
|
2011-10-18 20:17:10 +00:00
|
|
|
if (offsetInBuffer <= mFillPoint) {
|
|
|
|
// It's safe to just set mCursor to offsetInBuffer. In particular, we
|
|
|
|
// want to avoid calling Fill() here since we already have the data that
|
|
|
|
// was seeked to and calling Fill() might auto-close our underlying
|
|
|
|
// stream in some cases.
|
|
|
|
mCursor = offsetInBuffer;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
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-21 20:51:34 +00:00
|
|
|
METER(if (bufstats.mBigSeekIndex < MAX_BIG_SEEKS)
|
|
|
|
bufstats.mBigSeek[bufstats.mBigSeekIndex]
|
2012-08-22 15:56:38 +00:00
|
|
|
.mOldOffset = mBufferStartOffset + int64_t(mCursor));
|
|
|
|
const int64_t minus1 = -1;
|
2004-04-13 14:37:53 +00:00
|
|
|
if (absPos == minus1) {
|
2000-02-04 07:31:43 +00:00
|
|
|
// then we had the SEEK_END case, above
|
2012-08-22 15:56:38 +00:00
|
|
|
int64_t tellPos;
|
2004-04-13 14:37:53 +00:00
|
|
|
rv = ras->Tell(&tellPos);
|
|
|
|
mBufferStartOffset = tellPos;
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
2000-02-04 07:31:43 +00:00
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
} else {
|
2000-02-04 07:31:43 +00:00
|
|
|
mBufferStartOffset = absPos;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
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-21 20:51:34 +00:00
|
|
|
METER(if (bufstats.mBigSeekIndex < MAX_BIG_SEEKS)
|
|
|
|
bufstats.mBigSeek[bufstats.mBigSeekIndex++]
|
2001-07-31 19:05:34 +00:00
|
|
|
.mNewOffset = mBufferStartOffset);
|
|
|
|
|
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-21 20:51:34 +00:00
|
|
|
mFillPoint = mCursor = 0;
|
2000-02-04 07:31:43 +00:00
|
|
|
return Fill();
|
2000-01-13 09:11:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBufferedStream::Tell(int64_t* result) {
|
2017-01-26 22:15:00 +00:00
|
|
|
if (mStream == nullptr) {
|
2000-01-13 09:11:01 +00:00
|
|
|
return NS_BASE_STREAM_CLOSED;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int64_t result64 = mBufferStartOffset;
|
2004-04-13 14:37:53 +00:00
|
|
|
result64 += mCursor;
|
|
|
|
*result = result64;
|
2000-02-04 07:31:43 +00:00
|
|
|
return NS_OK;
|
2000-01-13 09:11:01 +00:00
|
|
|
}
|
|
|
|
|
2001-07-25 00:40:42 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedStream::SetEOF() {
|
2017-01-26 22:15:00 +00:00
|
|
|
if (mStream == nullptr) {
|
2001-07-25 00:40:42 +00:00
|
|
|
return NS_BASE_STREAM_CLOSED;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
|
|
|
|
2001-07-25 00:40:42 +00:00
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsISeekableStream> ras = do_QueryInterface(mStream, &rv);
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2001-07-25 00:40:42 +00:00
|
|
|
|
2011-10-18 20:17:10 +00:00
|
|
|
rv = ras->SetEOF();
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-10-18 20:17:10 +00:00
|
|
|
mEOF = true;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
|
|
|
|
2011-10-18 20:17:10 +00:00
|
|
|
return rv;
|
2001-07-25 00:40:42 +00:00
|
|
|
}
|
|
|
|
|
2017-05-05 21:51:13 +00:00
|
|
|
nsresult nsBufferedStream::GetData(nsISupports** aResult) {
|
2019-03-05 18:43:02 +00:00
|
|
|
nsCOMPtr<nsISupports> stream(mStream);
|
|
|
|
stream.forget(aResult);
|
2017-05-05 21:51:13 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-13 09:11:01 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsBufferedInputStream
|
|
|
|
|
2010-10-21 18:36:13 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsBufferedInputStream, nsBufferedStream)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsBufferedInputStream, nsBufferedStream)
|
|
|
|
|
2013-09-19 19:28:26 +00:00
|
|
|
NS_IMPL_CLASSINFO(nsBufferedInputStream, nullptr, nsIClassInfo::THREADSAFE,
|
2010-10-21 18:36:13 +00:00
|
|
|
NS_BUFFEREDINPUTSTREAM_CID)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsBufferedInputStream)
|
2019-08-15 17:25:51 +00:00
|
|
|
// Unfortunately there isn't a macro that combines ambiguous and conditional,
|
|
|
|
// and as far as I can tell, no other class would need such a macro.
|
|
|
|
if (mIsAsyncInputStream && aIID.Equals(NS_GET_IID(nsIInputStream))) {
|
|
|
|
foundInterface =
|
|
|
|
static_cast<nsIInputStream*>(static_cast<nsIAsyncInputStream*>(this));
|
|
|
|
} else if (!mIsAsyncInputStream && aIID.Equals(NS_GET_IID(nsIInputStream))) {
|
|
|
|
foundInterface = static_cast<nsIInputStream*>(
|
|
|
|
static_cast<nsIBufferedInputStream*>(this));
|
|
|
|
} else
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIBufferedInputStream)
|
2010-10-21 18:36:13 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIBufferedInputStream)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStreamBufferAccess)
|
2018-02-28 06:14:41 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIIPCSerializableInputStream,
|
|
|
|
mIsIPCSerializable)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAsyncInputStream, mIsAsyncInputStream)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIInputStreamCallback,
|
|
|
|
mIsAsyncInputStream)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsICloneableInputStream,
|
|
|
|
mIsCloneableInputStream)
|
2018-05-23 05:12:35 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIInputStreamLength, mIsInputStreamLength)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAsyncInputStreamLength,
|
|
|
|
mIsAsyncInputStreamLength)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIInputStreamLengthCallback,
|
|
|
|
mIsAsyncInputStreamLength)
|
2010-10-21 18:36:13 +00:00
|
|
|
NS_IMPL_QUERY_CLASSINFO(nsBufferedInputStream)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsBufferedStream)
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_CI_INTERFACE_GETTER(nsBufferedInputStream, nsIInputStream,
|
|
|
|
nsIBufferedInputStream, nsISeekableStream,
|
|
|
|
nsITellableStream, nsIStreamBufferAccess)
|
2000-01-13 09:11:01 +00:00
|
|
|
|
2018-02-28 06:14:41 +00:00
|
|
|
nsBufferedInputStream::nsBufferedInputStream()
|
|
|
|
: nsBufferedStream(),
|
2018-04-10 15:33:08 +00:00
|
|
|
mMutex("nsBufferedInputStream::mMutex"),
|
2018-02-28 06:14:41 +00:00
|
|
|
mIsIPCSerializable(true),
|
|
|
|
mIsAsyncInputStream(false),
|
|
|
|
mIsCloneableInputStream(false),
|
2018-05-23 05:12:35 +00:00
|
|
|
mIsInputStreamLength(false),
|
|
|
|
mIsAsyncInputStreamLength(false) {}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2000-01-13 09:11:01 +00:00
|
|
|
nsresult nsBufferedInputStream::Create(nsISupports* aOuter, REFNSIID aIID,
|
|
|
|
void** aResult) {
|
|
|
|
NS_ENSURE_NO_AGGREGATION(aOuter);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2019-03-05 18:43:02 +00:00
|
|
|
RefPtr<nsBufferedInputStream> stream = new nsBufferedInputStream();
|
|
|
|
return stream->QueryInterface(aIID, aResult);
|
2000-01-13 09:11:01 +00:00
|
|
|
}
|
|
|
|
|
2000-02-04 07:31:43 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBufferedInputStream::Init(nsIInputStream* stream, uint32_t bufferSize) {
|
2018-02-28 06:14:41 +00:00
|
|
|
nsresult rv = nsBufferedStream::Init(stream, bufferSize);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIIPCSerializableInputStream> stream = do_QueryInterface(mStream);
|
|
|
|
mIsIPCSerializable = !!stream;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAsyncInputStream> stream = do_QueryInterface(mStream);
|
|
|
|
mIsAsyncInputStream = !!stream;
|
|
|
|
}
|
|
|
|
|
2018-05-23 05:12:35 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsICloneableInputStream> stream = do_QueryInterface(mStream);
|
|
|
|
mIsCloneableInputStream = !!stream;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIInputStreamLength> stream = do_QueryInterface(mStream);
|
|
|
|
mIsInputStreamLength = !!stream;
|
|
|
|
}
|
|
|
|
|
2018-11-30 10:46:48 +00:00
|
|
|
{
|
2018-05-23 05:12:35 +00:00
|
|
|
nsCOMPtr<nsIAsyncInputStreamLength> stream = do_QueryInterface(mStream);
|
|
|
|
mIsAsyncInputStreamLength = !!stream;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2018-02-28 06:14:41 +00:00
|
|
|
return NS_OK;
|
2000-02-04 07:31:43 +00:00
|
|
|
}
|
|
|
|
|
2019-08-15 17:25:51 +00:00
|
|
|
already_AddRefed<nsIInputStream> nsBufferedInputStream::GetInputStream() {
|
|
|
|
// A non-null mStream implies Init() has been called.
|
|
|
|
MOZ_ASSERT(mStream);
|
|
|
|
|
|
|
|
nsIInputStream* out = nullptr;
|
|
|
|
DebugOnly<nsresult> rv = QueryInterface(NS_GET_IID(nsIInputStream),
|
|
|
|
reinterpret_cast<void**>(&out));
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
MOZ_ASSERT(out);
|
|
|
|
|
|
|
|
return already_AddRefed<nsIInputStream>(out);
|
|
|
|
}
|
|
|
|
|
2000-01-13 09:11:01 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedInputStream::Close() {
|
2019-12-02 13:21:06 +00:00
|
|
|
nsresult rv = NS_OK;
|
2000-08-22 07:03:33 +00:00
|
|
|
if (mStream) {
|
2019-12-02 13:21:06 +00:00
|
|
|
rv = Source()->Close();
|
|
|
|
if (NS_FAILED(rv)) {
|
2017-01-26 22:15:00 +00:00
|
|
|
NS_WARNING(
|
2019-12-02 13:21:06 +00:00
|
|
|
"(debug) Error: Source()->Close() returned error in "
|
2017-01-26 22:15:00 +00:00
|
|
|
"bsBuffedInputStream::Close().");
|
2019-12-02 13:21:06 +00:00
|
|
|
}
|
2000-08-22 07:03:33 +00:00
|
|
|
}
|
2017-01-26 22:15:00 +00:00
|
|
|
|
2019-12-02 13:21:06 +00:00
|
|
|
nsBufferedStream::Close();
|
|
|
|
return rv;
|
2000-01-13 09:11:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBufferedInputStream::Available(uint64_t* result) {
|
2002-02-16 01:19:24 +00:00
|
|
|
*result = 0;
|
2018-04-12 05:27:54 +00:00
|
|
|
|
|
|
|
if (!mStream) {
|
|
|
|
return NS_OK;
|
2002-02-16 01:19:24 +00:00
|
|
|
}
|
2018-04-12 05:27:54 +00:00
|
|
|
|
|
|
|
uint64_t avail = mFillPoint - mCursor;
|
|
|
|
|
|
|
|
uint64_t tmp;
|
|
|
|
nsresult rv = Source()->Available(&tmp);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
avail += tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (avail) {
|
|
|
|
*result = avail;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-02-16 01:19:24 +00:00
|
|
|
return rv;
|
2000-01-13 09:11:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBufferedInputStream::Read(char* buf, uint32_t count, uint32_t* result) {
|
2001-07-31 19:05:34 +00:00
|
|
|
if (mBufferDisabled) {
|
2006-01-02 02:30:32 +00:00
|
|
|
if (!mStream) {
|
|
|
|
*result = 0;
|
|
|
|
return NS_OK;
|
2001-07-31 19:05:34 +00:00
|
|
|
}
|
2006-01-02 02:30:32 +00:00
|
|
|
nsresult rv = Source()->Read(buf, count, result);
|
2011-10-18 20:17:10 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2001-07-31 19:05:34 +00:00
|
|
|
mBufferStartOffset += *result; // so nsBufferedStream::Tell works
|
2011-10-18 20:17:10 +00:00
|
|
|
if (*result == 0) {
|
|
|
|
mEOF = true;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
}
|
2001-07-31 19:05:34 +00:00
|
|
|
return rv;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
2001-07-31 19:05:34 +00:00
|
|
|
|
2006-01-02 02:30:32 +00:00
|
|
|
return ReadSegments(NS_CopySegmentToBuffer, buf, count, result);
|
2000-02-04 07:31:43 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 07:03:33 +00:00
|
|
|
NS_IMETHODIMP
|
2006-01-02 02:30:32 +00:00
|
|
|
nsBufferedInputStream::ReadSegments(nsWriteSegmentFun writer, void* closure,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t count, uint32_t* result) {
|
2000-12-12 21:57:47 +00:00
|
|
|
*result = 0;
|
2006-01-02 02:30:32 +00:00
|
|
|
|
2017-01-26 22:15:00 +00:00
|
|
|
if (!mStream) {
|
2006-01-02 02:30:32 +00:00
|
|
|
return NS_OK;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
2006-01-02 02:30:32 +00:00
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
2000-12-12 21:57:47 +00:00
|
|
|
while (count > 0) {
|
2013-01-15 12:22:03 +00:00
|
|
|
uint32_t amt = std::min(count, mFillPoint - mCursor);
|
2000-12-12 21:57:47 +00:00
|
|
|
if (amt > 0) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t read = 0;
|
2017-05-02 17:32:42 +00:00
|
|
|
rv = writer(static_cast<nsIBufferedInputStream*>(this), closure,
|
|
|
|
mBuffer + mCursor, *result, amt, &read);
|
2003-01-31 02:00:45 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// errors returned from the writer end here!
|
|
|
|
rv = NS_OK;
|
|
|
|
break;
|
|
|
|
}
|
2000-12-12 21:57:47 +00:00
|
|
|
*result += read;
|
|
|
|
count -= read;
|
|
|
|
mCursor += read;
|
|
|
|
} else {
|
|
|
|
rv = Fill();
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_FAILED(rv) || mFillPoint == mCursor) {
|
2001-07-31 19:05:34 +00:00
|
|
|
break;
|
2000-12-12 21:57:47 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
2001-07-31 19:05:34 +00:00
|
|
|
return (*result > 0) ? NS_OK : rv;
|
2000-08-22 07:03:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
nsBufferedInputStream::IsNonBlocking(bool* aNonBlocking) {
|
2017-01-26 22:15:00 +00:00
|
|
|
if (mStream) {
|
2002-03-12 00:59:06 +00:00
|
|
|
return Source()->IsNonBlocking(aNonBlocking);
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
2002-03-12 00:59:06 +00:00
|
|
|
return NS_ERROR_NOT_INITIALIZED;
|
2000-08-22 07:03:33 +00:00
|
|
|
}
|
|
|
|
|
2000-02-04 07:31:43 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedInputStream::Fill() {
|
2017-01-26 22:15:00 +00:00
|
|
|
if (mBufferDisabled) {
|
2001-07-31 19:05:34 +00:00
|
|
|
return NS_OK;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
2002-01-12 03:18:55 +00:00
|
|
|
NS_ENSURE_TRUE(mStream, NS_ERROR_NOT_INITIALIZED);
|
2000-02-04 07:31:43 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult rv;
|
2000-02-04 07:31:43 +00:00
|
|
|
int32_t rem = int32_t(mFillPoint - mCursor);
|
|
|
|
if (rem > 0) {
|
|
|
|
// slide the remainder down to the start of the buffer
|
|
|
|
// |<------------->|<--rem-->|<--->|
|
|
|
|
// b c f s
|
|
|
|
memcpy(mBuffer, mBuffer + mCursor, rem);
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
2000-02-10 08:27:01 +00:00
|
|
|
mBufferStartOffset += mCursor;
|
2000-02-04 07:31:43 +00:00
|
|
|
mFillPoint = rem;
|
2017-01-26 22:15:00 +00:00
|
|
|
mCursor = 0;
|
2000-02-04 07:31:43 +00:00
|
|
|
|
2017-01-26 22:15:00 +00:00
|
|
|
uint32_t amt;
|
|
|
|
rv = Source()->Read(mBuffer + mFillPoint, mBufferSize - mFillPoint, &amt);
|
|
|
|
if (NS_FAILED(rv)) {
|
2011-10-18 20:17:10 +00:00
|
|
|
return rv;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
2017-07-06 12:00:35 +00:00
|
|
|
|
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-21 20:51:34 +00:00
|
|
|
if (amt == 0) {
|
2011-10-18 20:17:10 +00:00
|
|
|
mEOF = true;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2000-02-04 07:31:43 +00:00
|
|
|
mFillPoint += amt;
|
2001-07-31 19:05:34 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(char*)
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBufferedInputStream::GetBuffer(uint32_t aLength, uint32_t aAlignMask) {
|
2001-07-31 19:05:34 +00:00
|
|
|
NS_ASSERTION(mGetBufferCount == 0, "nested GetBuffer!");
|
2017-01-26 22:15:00 +00:00
|
|
|
if (mGetBufferCount != 0) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
2001-07-31 19:05:34 +00:00
|
|
|
|
2017-01-26 22:15:00 +00:00
|
|
|
if (mBufferDisabled) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
2001-07-31 19:05:34 +00:00
|
|
|
|
|
|
|
char* buf = mBuffer + mCursor;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t rem = mFillPoint - mCursor;
|
2001-07-31 19:05:34 +00:00
|
|
|
if (rem == 0) {
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_FAILED(Fill())) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2001-07-31 19:05:34 +00:00
|
|
|
}
|
|
|
|
buf = mBuffer + mCursor;
|
|
|
|
rem = mFillPoint - mCursor;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
2001-07-31 19:05:34 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mod = (NS_PTR_TO_INT32(buf) & aAlignMask);
|
2001-07-31 19:05:34 +00:00
|
|
|
if (mod) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t pad = aAlignMask + 1 - mod;
|
2017-01-26 22:15:00 +00:00
|
|
|
if (pad > rem) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2001-07-31 19:05:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(buf, 0, pad);
|
|
|
|
mCursor += pad;
|
|
|
|
buf += pad;
|
|
|
|
rem -= pad;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 22:15:00 +00:00
|
|
|
if (aLength > rem) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
2001-07-31 19:05:34 +00:00
|
|
|
mGetBufferCount++;
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(void)
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBufferedInputStream::PutBuffer(char* aBuffer, uint32_t aLength) {
|
2001-07-31 19:05:34 +00:00
|
|
|
NS_ASSERTION(mGetBufferCount == 1, "stray PutBuffer!");
|
2017-01-26 22:15:00 +00:00
|
|
|
if (--mGetBufferCount != 0) {
|
2001-07-31 19:05:34 +00:00
|
|
|
return;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
2001-07-31 19:05:34 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(mCursor + aLength <= mFillPoint, "PutBuffer botch");
|
|
|
|
mCursor += aLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedInputStream::DisableBuffering() {
|
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-21 20:51:34 +00:00
|
|
|
NS_ASSERTION(!mBufferDisabled, "redundant call to DisableBuffering!");
|
2001-07-31 19:05:34 +00:00
|
|
|
NS_ASSERTION(mGetBufferCount == 0,
|
|
|
|
"DisableBuffer call between GetBuffer and PutBuffer!");
|
2017-01-26 22:15:00 +00:00
|
|
|
if (mGetBufferCount != 0) {
|
2001-07-31 19:05:34 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
2001-07-31 19:05:34 +00:00
|
|
|
|
|
|
|
// Empty the buffer so nsBufferedStream::Tell works.
|
|
|
|
mBufferStartOffset += mCursor;
|
|
|
|
mFillPoint = mCursor = 0;
|
2011-10-17 14:59:28 +00:00
|
|
|
mBufferDisabled = true;
|
2001-07-31 19:05:34 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedInputStream::EnableBuffering() {
|
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-21 20:51:34 +00:00
|
|
|
NS_ASSERTION(mBufferDisabled, "gratuitous call to EnableBuffering!");
|
2011-10-17 14:59:28 +00:00
|
|
|
mBufferDisabled = false;
|
2001-07-31 19:05:34 +00:00
|
|
|
return NS_OK;
|
2000-01-13 09:11:01 +00:00
|
|
|
}
|
|
|
|
|
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-21 20:51:34 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedInputStream::GetUnbufferedStream(nsISupports** aStream) {
|
|
|
|
// Empty the buffer so subsequent i/o trumps any buffered data.
|
|
|
|
mBufferStartOffset += mCursor;
|
|
|
|
mFillPoint = mCursor = 0;
|
|
|
|
|
2019-03-05 18:43:02 +00:00
|
|
|
nsCOMPtr<nsISupports> stream = mStream;
|
|
|
|
stream.forget(aStream);
|
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-21 20:51:34 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-12-03 13:41:58 +00:00
|
|
|
void nsBufferedInputStream::Serialize(
|
|
|
|
InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
|
|
|
|
bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
|
|
|
|
mozilla::ipc::ParentToChildStreamActorManager* aManager) {
|
2019-02-04 22:50:51 +00:00
|
|
|
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
|
|
|
aSizeUsed, aManager);
|
2019-01-28 09:48:35 +00:00
|
|
|
}
|
|
|
|
|
2019-12-03 13:41:58 +00:00
|
|
|
void nsBufferedInputStream::Serialize(
|
|
|
|
InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
|
|
|
|
bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed,
|
|
|
|
mozilla::ipc::ChildToParentStreamActorManager* aManager) {
|
2019-02-04 22:50:51 +00:00
|
|
|
SerializeInternal(aParams, aFileDescriptors, aDelayedStart, aMaxSize,
|
|
|
|
aSizeUsed, aManager);
|
2019-01-28 09:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename M>
|
|
|
|
void nsBufferedInputStream::SerializeInternal(
|
|
|
|
InputStreamParams& aParams, FileDescriptorArray& aFileDescriptors,
|
2019-02-04 22:50:51 +00:00
|
|
|
bool aDelayedStart, uint32_t aMaxSize, uint32_t* aSizeUsed, M* aManager) {
|
|
|
|
MOZ_ASSERT(aSizeUsed);
|
|
|
|
*aSizeUsed = 0;
|
|
|
|
|
2012-08-23 02:13:54 +00:00
|
|
|
BufferedInputStreamParams params;
|
2012-08-22 19:19:29 +00:00
|
|
|
|
2012-08-23 02:13:54 +00:00
|
|
|
if (mStream) {
|
2014-03-25 18:37:13 +00:00
|
|
|
nsCOMPtr<nsIInputStream> stream = do_QueryInterface(mStream);
|
|
|
|
MOZ_ASSERT(stream);
|
2012-08-22 19:19:29 +00:00
|
|
|
|
2012-08-23 02:13:54 +00:00
|
|
|
InputStreamParams wrappedParams;
|
2019-02-04 22:50:51 +00:00
|
|
|
InputStreamHelper::SerializeInputStream(stream, wrappedParams,
|
|
|
|
aFileDescriptors, aDelayedStart,
|
|
|
|
aMaxSize, aSizeUsed, aManager);
|
2012-08-23 02:13:54 +00:00
|
|
|
|
2019-03-12 15:52:26 +00:00
|
|
|
params.optionalStream().emplace(wrappedParams);
|
2012-08-23 02:13:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
params.bufferSize() = mBufferSize;
|
|
|
|
|
|
|
|
aParams = params;
|
2010-10-21 18:36:13 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 18:37:13 +00:00
|
|
|
bool nsBufferedInputStream::Deserialize(
|
|
|
|
const InputStreamParams& aParams,
|
|
|
|
const FileDescriptorArray& aFileDescriptors) {
|
2012-08-23 02:13:54 +00:00
|
|
|
if (aParams.type() != InputStreamParams::TBufferedInputStreamParams) {
|
|
|
|
NS_ERROR("Received unknown parameters from the other process!");
|
|
|
|
return false;
|
|
|
|
}
|
2010-10-21 18:36:13 +00:00
|
|
|
|
2012-08-23 02:13:54 +00:00
|
|
|
const BufferedInputStreamParams& params =
|
|
|
|
aParams.get_BufferedInputStreamParams();
|
2019-03-12 15:52:26 +00:00
|
|
|
const Maybe<InputStreamParams>& wrappedParams = params.optionalStream();
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2012-08-23 02:13:54 +00:00
|
|
|
nsCOMPtr<nsIInputStream> stream;
|
2019-03-12 15:52:26 +00:00
|
|
|
if (wrappedParams.isSome()) {
|
|
|
|
stream = InputStreamHelper::DeserializeInputStream(wrappedParams.ref(),
|
|
|
|
aFileDescriptors);
|
2012-08-23 02:13:54 +00:00
|
|
|
if (!stream) {
|
|
|
|
NS_WARNING("Failed to deserialize wrapped stream!");
|
|
|
|
return false;
|
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
2012-08-23 02:13:54 +00:00
|
|
|
|
|
|
|
nsresult rv = Init(stream, params.bufferSize());
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
|
|
|
|
return true;
|
2010-10-21 18:36:13 +00:00
|
|
|
}
|
|
|
|
|
2017-05-02 17:32:42 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedInputStream::CloseWithStatus(nsresult aStatus) { return Close(); }
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedInputStream::AsyncWait(nsIInputStreamCallback* aCallback,
|
|
|
|
uint32_t aFlags, uint32_t aRequestedCount,
|
|
|
|
nsIEventTarget* aEventTarget) {
|
|
|
|
nsCOMPtr<nsIAsyncInputStream> stream = do_QueryInterface(mStream);
|
|
|
|
if (!stream) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2018-04-10 15:33:08 +00:00
|
|
|
nsCOMPtr<nsIInputStreamCallback> callback = aCallback ? this : nullptr;
|
|
|
|
{
|
|
|
|
MutexAutoLock lock(mMutex);
|
2017-05-02 17:32:42 +00:00
|
|
|
|
2018-04-10 15:33:08 +00:00
|
|
|
if (mAsyncWaitCallback && aCallback) {
|
|
|
|
return NS_ERROR_FAILURE;
|
2017-05-02 17:32:42 +00:00
|
|
|
}
|
|
|
|
|
2018-05-23 05:12:35 +00:00
|
|
|
mAsyncWaitCallback = aCallback;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2018-04-10 15:33:08 +00:00
|
|
|
return stream->AsyncWait(callback, aFlags, aRequestedCount, aEventTarget);
|
2017-05-02 17:32:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedInputStream::OnInputStreamReady(nsIAsyncInputStream* aStream) {
|
|
|
|
nsCOMPtr<nsIInputStreamCallback> callback;
|
2018-04-10 15:33:08 +00:00
|
|
|
{
|
|
|
|
MutexAutoLock lock(mMutex);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2018-04-10 15:33:08 +00:00
|
|
|
// We have been canceled in the meanwhile.
|
|
|
|
if (!mAsyncWaitCallback) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2017-05-02 17:32:42 +00:00
|
|
|
|
2018-04-10 15:33:08 +00:00
|
|
|
callback.swap(mAsyncWaitCallback);
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2018-04-10 15:33:08 +00:00
|
|
|
MOZ_ASSERT(callback);
|
2017-05-02 17:32:42 +00:00
|
|
|
return callback->OnInputStreamReady(this);
|
|
|
|
}
|
|
|
|
|
2017-05-05 21:51:13 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedInputStream::GetData(nsIInputStream** aResult) {
|
|
|
|
nsCOMPtr<nsISupports> stream;
|
|
|
|
nsBufferedStream::GetData(getter_AddRefs(stream));
|
|
|
|
nsCOMPtr<nsIInputStream> inputStream = do_QueryInterface(stream);
|
2019-03-05 18:43:02 +00:00
|
|
|
inputStream.forget(aResult);
|
2017-05-05 21:51:13 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-12-13 00:38:19 +00:00
|
|
|
// nsICloneableInputStream interface
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedInputStream::GetCloneable(bool* aCloneable) {
|
|
|
|
*aCloneable = false;
|
|
|
|
|
|
|
|
// If we don't have the buffer, the inputStream has been already closed.
|
|
|
|
// If mBufferStartOffset is not 0, the stream has been seeked or read.
|
|
|
|
// In both case the cloning is not supported.
|
|
|
|
if (!mBuffer || mBufferStartOffset) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsICloneableInputStream> stream = do_QueryInterface(mStream);
|
|
|
|
|
|
|
|
// GetCloneable is infallible.
|
|
|
|
NS_ENSURE_TRUE(stream, NS_OK);
|
|
|
|
|
|
|
|
return stream->GetCloneable(aCloneable);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedInputStream::Clone(nsIInputStream** aResult) {
|
|
|
|
if (!mBuffer || mBufferStartOffset) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsICloneableInputStream> stream = do_QueryInterface(mStream);
|
|
|
|
NS_ENSURE_TRUE(stream, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIInputStream> clonedStream;
|
|
|
|
nsresult rv = stream->Clone(getter_AddRefs(clonedStream));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIBufferedInputStream> bis = new nsBufferedInputStream();
|
|
|
|
rv = bis->Init(clonedStream, mBufferSize);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2019-08-15 17:25:51 +00:00
|
|
|
*aResult =
|
|
|
|
static_cast<nsBufferedInputStream*>(bis.get())->GetInputStream().take();
|
|
|
|
|
2017-12-13 00:38:19 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2018-05-23 05:12:35 +00:00
|
|
|
// nsIInputStreamLength
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedInputStream::Length(int64_t* aLength) {
|
|
|
|
nsCOMPtr<nsIInputStreamLength> stream = do_QueryInterface(mStream);
|
|
|
|
NS_ENSURE_TRUE(stream, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
return stream->Length(aLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIAsyncInputStreamLength
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedInputStream::AsyncLengthWait(nsIInputStreamLengthCallback* aCallback,
|
|
|
|
nsIEventTarget* aEventTarget) {
|
|
|
|
nsCOMPtr<nsIAsyncInputStreamLength> stream = do_QueryInterface(mStream);
|
|
|
|
if (!stream) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIInputStreamLengthCallback> callback = aCallback ? this : nullptr;
|
|
|
|
{
|
|
|
|
MutexAutoLock lock(mMutex);
|
|
|
|
mAsyncInputStreamLengthCallback = aCallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(stream);
|
|
|
|
return stream->AsyncLengthWait(callback, aEventTarget);
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIInputStreamLengthCallback
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedInputStream::OnInputStreamLengthReady(
|
|
|
|
nsIAsyncInputStreamLength* aStream, int64_t aLength) {
|
|
|
|
nsCOMPtr<nsIInputStreamLengthCallback> callback;
|
|
|
|
{
|
|
|
|
MutexAutoLock lock(mMutex);
|
|
|
|
// We have been canceled in the meanwhile.
|
|
|
|
if (!mAsyncInputStreamLengthCallback) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
callback.swap(mAsyncInputStreamLengthCallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(callback);
|
|
|
|
return callback->OnInputStreamLengthReady(this, aLength);
|
|
|
|
}
|
|
|
|
|
2000-01-13 09:11:01 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsBufferedOutputStream
|
|
|
|
|
2004-07-19 22:00:03 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsBufferedOutputStream, nsBufferedStream)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsBufferedOutputStream, nsBufferedStream)
|
|
|
|
// This QI uses NS_INTERFACE_MAP_ENTRY_CONDITIONAL to check for
|
|
|
|
// non-nullness of mSafeStream.
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsBufferedOutputStream)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIOutputStream)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsISafeOutputStream, mSafeStream)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIBufferedOutputStream)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStreamBufferAccess)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsBufferedStream)
|
|
|
|
|
2000-01-13 09:11:01 +00:00
|
|
|
nsresult nsBufferedOutputStream::Create(nsISupports* aOuter, REFNSIID aIID,
|
|
|
|
void** aResult) {
|
|
|
|
NS_ENSURE_NO_AGGREGATION(aOuter);
|
|
|
|
|
2019-03-05 18:43:02 +00:00
|
|
|
RefPtr<nsBufferedOutputStream> stream = new nsBufferedOutputStream();
|
|
|
|
return stream->QueryInterface(aIID, aResult);
|
2000-01-13 09:11:01 +00:00
|
|
|
}
|
|
|
|
|
2000-02-04 07:31:43 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBufferedOutputStream::Init(nsIOutputStream* stream, uint32_t bufferSize) {
|
2004-07-19 22:00:03 +00:00
|
|
|
// QI stream to an nsISafeOutputStream, to see if we should support it
|
|
|
|
mSafeStream = do_QueryInterface(stream);
|
|
|
|
|
2000-02-04 07:31:43 +00:00
|
|
|
return nsBufferedStream::Init(stream, bufferSize);
|
|
|
|
}
|
|
|
|
|
2000-01-13 09:11:01 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedOutputStream::Close() {
|
2019-12-02 13:21:06 +00:00
|
|
|
nsresult rv1, rv2 = NS_OK;
|
2017-01-26 22:15:00 +00:00
|
|
|
|
2000-02-04 07:31:43 +00:00
|
|
|
rv1 = Flush();
|
2017-01-26 22:15:00 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (NS_FAILED(rv1)) {
|
|
|
|
NS_WARNING(
|
|
|
|
"(debug) Flush() inside nsBufferedOutputStream::Close() returned error "
|
|
|
|
"(rv1).");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-02-04 07:31:43 +00:00
|
|
|
// If we fail to Flush all the data, then we close anyway and drop the
|
|
|
|
// remaining data in the buffer. We do this because it's what Unix does
|
|
|
|
// for fclose and close. However, we report the error from Flush anyway.
|
2000-08-22 07:03:33 +00:00
|
|
|
if (mStream) {
|
|
|
|
rv2 = Sink()->Close();
|
2017-01-26 22:15:00 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (NS_FAILED(rv2)) {
|
|
|
|
NS_WARNING(
|
|
|
|
"(debug) Sink->Close() inside nsBufferedOutputStream::Close() "
|
|
|
|
"returned error (rv2).");
|
2000-08-22 07:03:33 +00:00
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
#endif
|
|
|
|
}
|
2019-12-02 13:21:06 +00:00
|
|
|
nsBufferedStream::Close();
|
2017-01-26 22:15:00 +00:00
|
|
|
|
|
|
|
if (NS_FAILED(rv1)) {
|
|
|
|
return rv1;
|
|
|
|
}
|
|
|
|
if (NS_FAILED(rv2)) {
|
|
|
|
return rv2;
|
|
|
|
}
|
2019-12-02 13:21:06 +00:00
|
|
|
return NS_OK;
|
2000-01-13 09:11:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBufferedOutputStream::Write(const char* buf, uint32_t count,
|
|
|
|
uint32_t* result) {
|
2000-02-04 07:31:43 +00:00
|
|
|
nsresult rv = NS_OK;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t written = 0;
|
2017-01-26 22:15:00 +00:00
|
|
|
*result = 0;
|
|
|
|
if (!mStream) {
|
2019-11-17 16:59:28 +00:00
|
|
|
// We special case this situation.
|
2017-01-26 22:15:00 +00:00
|
|
|
// We should catch the failure, NS_BASE_STREAM_CLOSED ASAP, here.
|
|
|
|
// If we don't, eventually Flush() is called in the while loop below
|
|
|
|
// after so many writes.
|
|
|
|
// However, Flush() returns NS_OK when mStream is null (!!),
|
|
|
|
// and we don't get a meaningful error, NS_BASE_STREAM_CLOSED,
|
|
|
|
// soon enough when we use buffered output.
|
|
|
|
#ifdef DEBUG
|
|
|
|
NS_WARNING(
|
|
|
|
"(info) nsBufferedOutputStream::Write returns NS_BASE_STREAM_CLOSED "
|
|
|
|
"immediately (mStream==null).");
|
|
|
|
#endif
|
|
|
|
return NS_BASE_STREAM_CLOSED;
|
|
|
|
}
|
|
|
|
|
2000-02-04 07:31:43 +00:00
|
|
|
while (count > 0) {
|
2013-01-15 12:22:03 +00:00
|
|
|
uint32_t amt = std::min(count, mBufferSize - mCursor);
|
2000-02-04 07:31:43 +00:00
|
|
|
if (amt > 0) {
|
2002-01-12 03:18:55 +00:00
|
|
|
memcpy(mBuffer + mCursor, buf + written, amt);
|
2000-02-04 07:31:43 +00:00
|
|
|
written += amt;
|
|
|
|
count -= amt;
|
|
|
|
mCursor += amt;
|
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-21 20:51:34 +00:00
|
|
|
if (mFillPoint < mCursor) mFillPoint = mCursor;
|
2000-02-04 07:31:43 +00:00
|
|
|
} else {
|
2017-01-26 22:15:00 +00:00
|
|
|
NS_ASSERTION(mFillPoint, "loop in nsBufferedOutputStream::Write!");
|
2000-02-04 07:31:43 +00:00
|
|
|
rv = Flush();
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
NS_WARNING(
|
|
|
|
"(debug) Flush() returned error in nsBufferedOutputStream::Write.");
|
|
|
|
#endif
|
|
|
|
break;
|
2000-02-04 07:31:43 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
2000-02-04 07:31:43 +00:00
|
|
|
*result = written;
|
|
|
|
return (written > 0) ? NS_OK : rv;
|
2000-01-13 09:11:01 +00:00
|
|
|
}
|
|
|
|
|
2001-07-31 19:05:34 +00:00
|
|
|
NS_IMETHODIMP
|
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-21 20:51:34 +00:00
|
|
|
nsBufferedOutputStream::Flush() {
|
2000-02-04 07:31:43 +00:00
|
|
|
nsresult rv;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t amt;
|
2001-02-07 04:33:39 +00:00
|
|
|
if (!mStream) {
|
2013-11-19 14:13:44 +00:00
|
|
|
// Stream already cancelled/flushed; probably because of previous error.
|
2001-02-07 04:33:39 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2017-01-26 22:15:00 +00:00
|
|
|
// optimize : some code within C-C needs to call Seek -> Flush() often.
|
|
|
|
if (mFillPoint == 0) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
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-21 20:51:34 +00:00
|
|
|
rv = Sink()->Write(mBuffer, mFillPoint, &amt);
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2000-02-04 07:31:43 +00:00
|
|
|
mBufferStartOffset += amt;
|
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-21 20:51:34 +00:00
|
|
|
if (amt == mFillPoint) {
|
|
|
|
mFillPoint = mCursor = 0;
|
2000-02-04 07:31:43 +00:00
|
|
|
return NS_OK; // flushed everything
|
|
|
|
}
|
|
|
|
|
|
|
|
// slide the remainder down to the start of the buffer
|
|
|
|
// |<-------------->|<---|----->|
|
|
|
|
// b a c s
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t rem = mFillPoint - amt;
|
2014-05-02 18:32:23 +00:00
|
|
|
memmove(mBuffer, mBuffer + amt, rem);
|
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-21 20:51:34 +00:00
|
|
|
mFillPoint = mCursor = rem;
|
2000-02-04 07:31:43 +00:00
|
|
|
return NS_ERROR_FAILURE; // didn't flush all
|
2000-01-13 09:11:01 +00:00
|
|
|
}
|
2003-09-14 11:55:05 +00:00
|
|
|
|
2004-07-19 22:00:03 +00:00
|
|
|
// nsISafeOutputStream
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedOutputStream::Finish() {
|
|
|
|
// flush the stream, to write out any buffered data...
|
2017-01-26 22:15:00 +00:00
|
|
|
nsresult rv1 = nsBufferedOutputStream::Flush();
|
2019-12-02 13:21:06 +00:00
|
|
|
nsresult rv2 = NS_OK;
|
2004-07-19 22:00:03 +00:00
|
|
|
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_FAILED(rv1)) {
|
|
|
|
NS_WARNING(
|
|
|
|
"(debug) nsBufferedOutputStream::Flush() failed in "
|
|
|
|
"nsBufferedOutputStream::Finish()! Possible dataloss.");
|
|
|
|
|
|
|
|
rv2 = Sink()->Close();
|
|
|
|
if (NS_FAILED(rv2)) {
|
|
|
|
NS_WARNING(
|
|
|
|
"(debug) Sink()->Close() failed in nsBufferedOutputStream::Finish()! "
|
|
|
|
"Possible dataloss.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rv2 = mSafeStream->Finish();
|
|
|
|
if (NS_FAILED(rv2)) {
|
|
|
|
NS_WARNING(
|
|
|
|
"(debug) mSafeStream->Finish() failed within "
|
|
|
|
"nsBufferedOutputStream::Flush()! Possible dataloss.");
|
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
2004-07-19 22:00:03 +00:00
|
|
|
|
|
|
|
// ... and close the buffered stream, so any further attempts to flush/close
|
|
|
|
// the buffered stream won't cause errors.
|
2019-12-02 13:21:06 +00:00
|
|
|
nsBufferedStream::Close();
|
2004-07-19 22:00:03 +00:00
|
|
|
|
2017-01-26 22:15:00 +00:00
|
|
|
// We want to return the errors precisely from Finish()
|
|
|
|
// and mimick the existing error handling in
|
|
|
|
// nsBufferedOutputStream::Close() as reference.
|
|
|
|
|
|
|
|
if (NS_FAILED(rv1)) {
|
|
|
|
return rv1;
|
|
|
|
}
|
|
|
|
if (NS_FAILED(rv2)) {
|
|
|
|
return rv2;
|
|
|
|
}
|
2019-12-02 13:21:06 +00:00
|
|
|
return NS_OK;
|
2004-07-19 22:00:03 +00:00
|
|
|
}
|
|
|
|
|
2003-09-14 11:55:05 +00:00
|
|
|
static nsresult nsReadFromInputStream(nsIOutputStream* outStr, void* closure,
|
2017-07-06 12:00:35 +00:00
|
|
|
char* toRawSegment, uint32_t offset,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t count, uint32_t* readCount) {
|
2003-09-14 11:55:05 +00:00
|
|
|
nsIInputStream* fromStream = (nsIInputStream*)closure;
|
|
|
|
return fromStream->Read(toRawSegment, count, readCount);
|
|
|
|
}
|
|
|
|
|
2000-08-22 07:03:33 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBufferedOutputStream::WriteFrom(nsIInputStream* inStr, uint32_t count,
|
|
|
|
uint32_t* _retval) {
|
2003-09-14 11:55:05 +00:00
|
|
|
return WriteSegments(nsReadFromInputStream, inStr, count, _retval);
|
2000-08-22 07:03:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBufferedOutputStream::WriteSegments(nsReadSegmentFun reader, void* closure,
|
|
|
|
uint32_t count, uint32_t* _retval) {
|
2003-09-14 11:55:05 +00:00
|
|
|
*_retval = 0;
|
|
|
|
nsresult rv;
|
|
|
|
while (count > 0) {
|
2013-01-15 12:22:03 +00:00
|
|
|
uint32_t left = std::min(count, mBufferSize - mCursor);
|
2003-09-14 11:55:05 +00:00
|
|
|
if (left == 0) {
|
|
|
|
rv = Flush();
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2014-05-02 18:32:23 +00:00
|
|
|
return (*_retval > 0) ? NS_OK : rv;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2003-09-14 11:55:05 +00:00
|
|
|
continue;
|
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t read = 0;
|
2003-09-14 11:55:05 +00:00
|
|
|
rv = reader(this, closure, mBuffer + mCursor, *_retval, left, &read);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_FAILED(rv)) { // If we have read some data, return ok
|
2003-09-14 11:55:05 +00:00
|
|
|
return (*_retval > 0) ? NS_OK : rv;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
2003-09-14 11:55:05 +00:00
|
|
|
mCursor += read;
|
|
|
|
*_retval += read;
|
|
|
|
count -= read;
|
2013-01-15 12:22:03 +00:00
|
|
|
mFillPoint = std::max(mFillPoint, mCursor);
|
2003-09-14 11:55:05 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
2000-08-22 07:03:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
nsBufferedOutputStream::IsNonBlocking(bool* aNonBlocking) {
|
2017-01-26 22:15:00 +00:00
|
|
|
if (mStream) {
|
2002-03-12 00:59:06 +00:00
|
|
|
return Sink()->IsNonBlocking(aNonBlocking);
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
2002-03-12 00:59:06 +00:00
|
|
|
return NS_ERROR_NOT_INITIALIZED;
|
2000-08-22 07:03:33 +00:00
|
|
|
}
|
2000-01-13 09:11:01 +00:00
|
|
|
|
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-21 20:51:34 +00:00
|
|
|
NS_IMETHODIMP_(char*)
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBufferedOutputStream::GetBuffer(uint32_t aLength, uint32_t aAlignMask) {
|
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-21 20:51:34 +00:00
|
|
|
NS_ASSERTION(mGetBufferCount == 0, "nested GetBuffer!");
|
2017-01-26 22:15:00 +00:00
|
|
|
if (mGetBufferCount != 0) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
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-21 20:51:34 +00:00
|
|
|
|
2017-01-26 22:15:00 +00:00
|
|
|
if (mBufferDisabled) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
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-21 20:51:34 +00:00
|
|
|
|
|
|
|
char* buf = mBuffer + mCursor;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t rem = mBufferSize - mCursor;
|
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-21 20:51:34 +00:00
|
|
|
if (rem == 0) {
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_FAILED(Flush())) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
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-21 20:51:34 +00:00
|
|
|
}
|
|
|
|
buf = mBuffer + mCursor;
|
|
|
|
rem = mBufferSize - mCursor;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
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-21 20:51:34 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mod = (NS_PTR_TO_INT32(buf) & aAlignMask);
|
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-21 20:51:34 +00:00
|
|
|
if (mod) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t pad = aAlignMask + 1 - mod;
|
2017-01-26 22:15:00 +00:00
|
|
|
if (pad > rem) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
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-21 20:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(buf, 0, pad);
|
|
|
|
mCursor += pad;
|
|
|
|
buf += pad;
|
|
|
|
rem -= pad;
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 22:15:00 +00:00
|
|
|
if (aLength > rem) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
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-21 20:51:34 +00:00
|
|
|
mGetBufferCount++;
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(void)
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBufferedOutputStream::PutBuffer(char* aBuffer, uint32_t aLength) {
|
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-21 20:51:34 +00:00
|
|
|
NS_ASSERTION(mGetBufferCount == 1, "stray PutBuffer!");
|
2017-01-26 22:15:00 +00:00
|
|
|
if (--mGetBufferCount != 0) {
|
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-21 20:51:34 +00:00
|
|
|
return;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
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-21 20:51:34 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(mCursor + aLength <= mBufferSize, "PutBuffer botch");
|
|
|
|
mCursor += aLength;
|
2017-01-26 22:15:00 +00:00
|
|
|
if (mFillPoint < mCursor) {
|
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-21 20:51:34 +00:00
|
|
|
mFillPoint = mCursor;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
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-21 20:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedOutputStream::DisableBuffering() {
|
|
|
|
NS_ASSERTION(!mBufferDisabled, "redundant call to DisableBuffering!");
|
|
|
|
NS_ASSERTION(mGetBufferCount == 0,
|
|
|
|
"DisableBuffer call between GetBuffer and PutBuffer!");
|
2017-01-26 22:15:00 +00:00
|
|
|
if (mGetBufferCount != 0) {
|
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-21 20:51:34 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
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-21 20:51:34 +00:00
|
|
|
|
|
|
|
// Empty the buffer so nsBufferedStream::Tell works.
|
|
|
|
nsresult rv = Flush();
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
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-21 20:51:34 +00:00
|
|
|
return rv;
|
2017-01-26 22:15:00 +00:00
|
|
|
}
|
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-21 20:51:34 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
mBufferDisabled = true;
|
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-21 20:51:34 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedOutputStream::EnableBuffering() {
|
|
|
|
NS_ASSERTION(mBufferDisabled, "gratuitous call to EnableBuffering!");
|
2011-10-17 14:59:28 +00:00
|
|
|
mBufferDisabled = false;
|
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-21 20:51:34 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedOutputStream::GetUnbufferedStream(nsISupports** aStream) {
|
|
|
|
// Empty the buffer so subsequent i/o trumps any buffered data.
|
|
|
|
if (mFillPoint) {
|
|
|
|
nsresult rv = Flush();
|
2017-01-26 22:15:00 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
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-21 20:51:34 +00:00
|
|
|
return rv;
|
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
}
|
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-21 20:51:34 +00:00
|
|
|
|
2019-03-05 18:43:02 +00:00
|
|
|
nsCOMPtr<nsISupports> stream = mStream;
|
|
|
|
stream.forget(aStream);
|
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-21 20:51:34 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-05-05 21:51:13 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBufferedOutputStream::GetData(nsIOutputStream** aResult) {
|
|
|
|
nsCOMPtr<nsISupports> stream;
|
|
|
|
nsBufferedStream::GetData(getter_AddRefs(stream));
|
|
|
|
nsCOMPtr<nsIOutputStream> outputStream = do_QueryInterface(stream);
|
2019-03-05 18:43:02 +00:00
|
|
|
outputStream.forget(aResult);
|
2017-05-05 21:51:13 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-09-21 16:40:12 +00:00
|
|
|
#undef METER
|
|
|
|
|
2012-08-28 12:41:04 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|