Make nsResURL work correctly with fastload and make nsResURL::Clone work correctly. b=252703 r=darin sr=bzbarsky

This commit is contained in:
dbaron%dbaron.org 2004-12-02 06:59:34 +00:00
parent 888fe0c640
commit b9115b7644
6 changed files with 57 additions and 11 deletions

View File

@ -1511,11 +1511,18 @@ nsStandardURL::SchemeIs(const char *scheme, PRBool *result)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP /* virtual */ nsStandardURL*
nsStandardURL::Clone(nsIURI **result) nsStandardURL::StartClone()
{ {
nsStandardURL *clone; nsStandardURL *clone;
NS_NEWXPCOM(clone, nsStandardURL); NS_NEWXPCOM(clone, nsStandardURL);
return clone;
}
NS_IMETHODIMP
nsStandardURL::Clone(nsIURI **result)
{
nsStandardURL *clone = StartClone();
if (!clone) if (!clone)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;

View File

@ -140,6 +140,9 @@ public: /* internal -- HPUX compiler can't handle this being private */
}; };
friend class nsSegmentEncoder; friend class nsSegmentEncoder;
protected:
virtual nsStandardURL* StartClone();
private: private:
PRInt32 Port() { return mPort == -1 ? mDefaultPort : mPort; } PRInt32 Port() { return mPort == -1 ? mDefaultPort : mPort; }

View File

@ -537,6 +537,17 @@
{0x8c, 0xda, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \ {0x8c, 0xda, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
} }
#define NS_RESURL_CLASSNAME \
"nsResURL"
#define NS_RESURL_CID \
{ /* ff8fe7ec-2f74-4408-b742-6b7a546029a8 */ \
0xff8fe7ec, \
0x2f74, \
0x4408, \
{0xb7, 0x42, 0x6b, 0x7a, 0x54, 0x60, 0x29, 0xa8} \
}
/****************************************************************************** /******************************************************************************
* netwerk/protocol/file/ classes * netwerk/protocol/file/ classes
*/ */

View File

@ -195,6 +195,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsHttpDigestAuth)
// resource // resource
#include "nsResProtocolHandler.h" #include "nsResProtocolHandler.h"
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsResProtocolHandler, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsResProtocolHandler, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsResURL)
#endif #endif
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -927,6 +928,11 @@ static const nsModuleComponentInfo gNetModuleInfo[] = {
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "resource", NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "resource",
nsResProtocolHandlerConstructor nsResProtocolHandlerConstructor
}, },
{ NS_RESURL_CLASSNAME, // needed only for fastload
NS_RESURL_CID,
nsnull,
nsResURLConstructor
},
#endif #endif
// from netwerk/protocol/about (about:blank is mandatory): // from netwerk/protocol/about (about:blank is mandatory):

View File

@ -52,6 +52,8 @@
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsURLHelper.h" #include "nsURLHelper.h"
static NS_DEFINE_CID(kResURLCID, NS_RESURL_CID);
static nsResProtocolHandler *gResHandler = nsnull; static nsResProtocolHandler *gResHandler = nsnull;
#if defined(PR_LOGGING) #if defined(PR_LOGGING)
@ -74,15 +76,6 @@ static PRLogModuleInfo *gResLog;
// nsResURL : overrides nsStandardURL::GetFile to provide nsIFile resolution // nsResURL : overrides nsStandardURL::GetFile to provide nsIFile resolution
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#include "nsStandardURL.h"
class nsResURL : public nsStandardURL
{
public:
nsResURL() : nsStandardURL(PR_TRUE) {}
NS_IMETHOD GetFile(nsIFile **);
};
NS_IMETHODIMP NS_IMETHODIMP
nsResURL::GetFile(nsIFile **result) nsResURL::GetFile(nsIFile **result)
{ {
@ -108,6 +101,21 @@ nsResURL::GetFile(nsIFile **result)
return rv; return rv;
} }
/* virtual */ nsStandardURL*
nsResURL::StartClone()
{
nsResURL *clone;
NS_NEWXPCOM(clone, nsResURL);
return clone;
}
NS_IMETHODIMP
nsResURL::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
{
*aClassIDNoAlloc = kResURLCID;
return NS_OK;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// nsResProtocolHandler <public> // nsResProtocolHandler <public>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -45,6 +45,17 @@
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsIIOService.h" #include "nsIIOService.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
#include "nsStandardURL.h"
// nsResURL : overrides nsStandardURL::GetFile to provide nsIFile resolution
class nsResURL : public nsStandardURL
{
public:
nsResURL() : nsStandardURL(PR_TRUE) {}
NS_IMETHOD GetFile(nsIFile **);
virtual nsStandardURL* StartClone();
NS_IMETHOD GetClassIDNoAlloc(nsCID *aCID);
};
class nsResProtocolHandler : public nsIResProtocolHandler, public nsSupportsWeakReference class nsResProtocolHandler : public nsIResProtocolHandler, public nsSupportsWeakReference
{ {