nsFastLoadService.cpp revision a454c61bfed7c56463d3bf58db2a432b31239f23
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla FastLoad code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brendan Eich <brendan@mozilla.org> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "prtypes.h"
#include "prio.h"
#include "prtime.h"
#include "pldhash.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsAutoLock.h"
#include "nsCOMPtr.h"
#include "nsFastLoadFile.h"
#include "nsFastLoadPtr.h"
#include "nsFastLoadService.h"
#include "nsString.h"
#include "nsIComponentManager.h"
#include "nsIEnumerator.h"
#include "nsIFastLoadFileControl.h"
#include "nsIFile.h"
#include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h"
#include "nsISeekableStream.h"
#include "nsISupports.h"
mDirection(0)
{
gFastLoadService_ = this;
}
{
if (mInputStream)
mInputStream->Close();
if (mOutputStream)
mOutputStream->Close();
if (mFastLoadPtrMap)
if (mLock)
}
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
if (!fastLoadService)
return NS_ERROR_OUT_OF_MEMORY;
if (!fastLoadService->mLock) {
delete fastLoadService;
return NS_ERROR_OUT_OF_MEMORY;
}
return rv;
}
#if defined XP_MAC
// Mac format: "<Basename> FastLoad File" with <basename> capitalized.
# include "nsCRT.h"
# define PLATFORM_FASL_SUFFIX " FastLoad File"
// Unix format: "<basename>.mfasl".
# define PLATFORM_FASL_SUFFIX ".mfasl"
// Windows format: "<basename>.mfl".
# define PLATFORM_FASL_SUFFIX ".mfl"
#endif
{
return rv;
return rv;
return NS_OK;
}
{
return rv;
return NS_OK;
}
{
}
{
return NS_OK;
}
{
return NS_OK;
}
{
return NS_OK;
}
{
return NS_OK;
}
{
return NS_OK;
}
{
return NS_OK;
}
{
*aResult = mDirection;
return NS_OK;
}
{
if (mInputStream) {
if (control)
}
if (! *aResult && mOutputStream) {
if (control)
}
return rv;
}
{
// Try for an input stream first, in case aURISpec's data is multiplexed
// in the current FastLoad file.
if (control) {
// If aURISpec is not in the multiplex, control->StartMuxedDocument
// will return NS_ERROR_NOT_AVAILABLE.
return rv;
// Ok, aURISpec is not in the existing mux. If we have no output
// stream yet, wrap the reader with a FastLoad file updater.
if (!mOutputStream && mFileIO) {
return rv;
// NB: mInputStream must be an nsFastLoadFileReader!
return rv;
}
if (aDirectionFlags == NS_FASTLOAD_READ) {
// Tell our caller to re-start multiplexing, rather than attempt
// to select and deserialize now.
return NS_ERROR_NOT_AVAILABLE;
}
}
}
if (control)
}
return rv;
}
{
// Try to select the reader, if any; then only if the URI was not in the
if (mInputStream) {
if (control) {
if (NS_SUCCEEDED(rv))
}
}
if (control) {
if (NS_SUCCEEDED(rv))
}
}
return rv;
}
{
// Try to end the document identified by aURI in the reader, if any; then
if (mInputStream) {
if (control)
}
if (control)
}
mDirection = 0;
return rv;
}
{
if (!control)
return NS_ERROR_NOT_AVAILABLE;
}
{
return rv;
if (checksum) {
return NS_OK;
}
return rv;
#ifndef VBOX
#else /* VBOX */
#endif /* VBOX */
return NS_OK;
}
{
if (!control)
return NS_ERROR_FAILURE;
return rv;
return rv;
#ifndef VBOX
#else /* VBOX */
#endif /* VBOX */
return NS_OK;
}
struct nsFastLoadPtrEntry : public PLDHashEntryHdr {
};
{
"aPtrAddr doesn't point to null nsFastLoadPtr<T>::mRawAddr?");
if (!mFastLoadPtrMap || !mInputStream)
return NS_OK;
if (PL_DHASH_ENTRY_IS_FREE(entry))
return NS_OK;
return rv;
return rv;
// Shrink the table if half the entries are removed sentinels.
else
return NS_OK;
}
{
// nsFastLoadPtrs self-construct to null, so if we have a non-null value
// in our inout parameter, we must have been read already, alright!
if (*aPtrAddr)
return NS_OK;
return rv;
if (!seekable)
return NS_ERROR_FAILURE;
return rv;
return rv;
if (!mFastLoadPtrMap) {
sizeof(nsFastLoadPtrEntry),
if (!mFastLoadPtrMap)
return NS_ERROR_OUT_OF_MEMORY;
}
PL_DHASH_ADD));
return NS_OK;
}
{
if (!aObject)
return NS_ERROR_UNEXPECTED;
if (!seekable)
return NS_ERROR_FAILURE;
return rv;
return rv;
return rv;
return rv;
return rv;
return rv;
return rv;
return NS_OK;
}