Make nsJARURI work usable in fastload. b=252703 r=darin sr=bzbarsky

This commit is contained in:
dbaron%dbaron.org 2004-12-02 07:00:25 +00:00
Родитель b9115b7644
Коммит d0cf51c72d
3 изменённых файлов: 115 добавлений и 7 удалений

Просмотреть файл

@ -56,6 +56,7 @@
#include "nsRecyclingAllocator.h"
#include "nsXPTZipLoader.h"
#include "nsJARProtocolHandler.h"
#include "nsJARURI.h"
extern nsRecyclingAllocator *gZlibAllocator;
@ -63,6 +64,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsXPTZipLoader)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsJAR)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsZipReaderCache)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsJARProtocolHandler, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsJARURI)
// The list of components we register
static const nsModuleComponentInfo components[] =
@ -86,6 +88,11 @@ static const nsModuleComponentInfo components[] =
NS_JARPROTOCOLHANDLER_CID,
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "jar",
nsJARProtocolHandlerConstructor
},
{ NS_JARURI_CLASSNAME, // needed only for fastload
NS_JARURI_CID,
nsnull,
nsJARURIConstructor
}
};

Просмотреть файл

@ -46,6 +46,11 @@
#include "nsIZipReader.h"
#include "nsReadableUtils.h"
#include "nsAutoPtr.h"
#include "nsNetCID.h"
#include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h"
static NS_DEFINE_CID(kJARURICID, NS_JARURI_CID);
static NS_DEFINE_CID(kThisImplCID, NS_THIS_JARURI_IMPL_CID);
@ -59,6 +64,7 @@ nsJARURI::~nsJARURI()
{
}
// XXX Why is this threadsafe?
NS_IMPL_THREADSAFE_ADDREF(nsJARURI)
NS_IMPL_THREADSAFE_RELEASE(nsJARURI)
NS_INTERFACE_MAP_BEGIN(nsJARURI)
@ -67,6 +73,7 @@ NS_INTERFACE_MAP_BEGIN(nsJARURI)
NS_INTERFACE_MAP_ENTRY(nsIURL)
NS_INTERFACE_MAP_ENTRY(nsIJARURI)
NS_INTERFACE_MAP_ENTRY(nsISerializable)
NS_INTERFACE_MAP_ENTRY(nsIClassInfo)
// see nsJARURI::Equals
if (aIID.Equals(kThisImplCID))
foundInterface = NS_STATIC_CAST(nsIJARURI *, this);
@ -135,17 +142,98 @@ nsJARURI::CreateEntryURL(const nsACString& entryFilename,
// nsISerializable methods:
NS_IMETHODIMP
nsJARURI::Read(nsIObjectInputStream* aStream)
nsJARURI::Read(nsIObjectInputStream* aInputStream)
{
NS_NOTREACHED("nsJARURI::Read");
return NS_ERROR_NOT_IMPLEMENTED;
nsresult rv;
rv = aInputStream->ReadObject(PR_TRUE, getter_AddRefs(mJARFile));
NS_ENSURE_SUCCESS(rv, rv);
rv = aInputStream->ReadObject(PR_TRUE, getter_AddRefs(mJAREntry));
NS_ENSURE_SUCCESS(rv, rv);
rv = aInputStream->ReadCString(mCharsetHint);
return rv;
}
NS_IMETHODIMP
nsJARURI::Write(nsIObjectOutputStream* aStream)
nsJARURI::Write(nsIObjectOutputStream* aOutputStream)
{
NS_NOTREACHED("nsJARURI::Write");
return NS_ERROR_NOT_IMPLEMENTED;
nsresult rv;
rv = aOutputStream->WriteCompoundObject(mJARFile, NS_GET_IID(nsIURI),
PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
rv = aOutputStream->WriteCompoundObject(mJAREntry, NS_GET_IID(nsIURL),
PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
rv = aOutputStream->WriteStringZ(mCharsetHint.get());
return rv;
}
////////////////////////////////////////////////////////////////////////////////
// nsIClassInfo methods:
NS_IMETHODIMP
nsJARURI::GetInterfaces(PRUint32 *count, nsIID * **array)
{
*count = 0;
*array = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsJARURI::GetHelperForLanguage(PRUint32 language, nsISupports **_retval)
{
*_retval = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsJARURI::GetContractID(char * *aContractID)
{
*aContractID = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsJARURI::GetClassDescription(char * *aClassDescription)
{
*aClassDescription = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsJARURI::GetClassID(nsCID * *aClassID)
{
*aClassID = (nsCID*) nsMemory::Alloc(sizeof(nsCID));
if (!*aClassID)
return NS_ERROR_OUT_OF_MEMORY;
return GetClassIDNoAlloc(*aClassID);
}
NS_IMETHODIMP
nsJARURI::GetImplementationLanguage(PRUint32 *aImplementationLanguage)
{
*aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS;
return NS_OK;
}
NS_IMETHODIMP
nsJARURI::GetFlags(PRUint32 *aFlags)
{
// XXX We implement THREADSAFE addref/release, but probably shouldn't.
*aFlags = nsIClassInfo::MAIN_THREAD_ONLY;
return NS_OK;
}
NS_IMETHODIMP
nsJARURI::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
{
*aClassIDNoAlloc = kJARURICID;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -41,6 +41,7 @@
#include "nsIJARURI.h"
#include "nsISerializable.h"
#include "nsIClassInfo.h"
#include "nsCOMPtr.h"
#include "nsString.h"
@ -52,7 +53,18 @@
{0xb7, 0x5b, 0xfa, 0x7d, 0x95, 0x70, 0xa6, 0x91} \
}
class nsJARURI : public nsIJARURI, nsISerializable
#define NS_JARURI_CLASSNAME \
"nsJARURI"
#define NS_JARURI_CID \
{ /* 245abae2-b947-4ded-a46d-9829d3cca462 */ \
0x245abae2, \
0xb947, \
0x4ded, \
{0xa4, 0x6d, 0x98, 0x29, 0xd3, 0xcc, 0xa4, 0x62} \
}
class nsJARURI : public nsIJARURI, nsISerializable, nsIClassInfo
{
public:
NS_DECL_ISUPPORTS
@ -60,6 +72,7 @@ public:
NS_DECL_NSIURL
NS_DECL_NSIJARURI
NS_DECL_NSISERIALIZABLE
NS_DECL_NSICLASSINFO
// nsJARURI
nsJARURI();