зеркало из https://github.com/mozilla/pjs.git
backing out patch for bug 97528 due to regression/smoketest-blocker bug 98838.
This commit is contained in:
Родитель
9035927484
Коммит
b964e56f7e
|
@ -34,7 +34,6 @@
|
|||
#include "nsIProgressEventSink.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIJAR.h"
|
||||
#include "nsIResProtocolHandler.h"
|
||||
|
||||
static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
|
||||
|
@ -287,7 +286,6 @@ nsresult
|
|||
nsJARChannel::EnsureJARFileAvailable()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFileURL> fileURL;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
nsXPIDLCString jarURLStr;
|
||||
|
@ -302,28 +300,13 @@ nsJARChannel::EnsureJARFileAvailable()
|
|||
rv = mURI->GetJAREntry(&mJAREntry);
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
|
||||
// try to get a nsIFile directly from the url, which will often succeed.
|
||||
fileURL = do_QueryInterface(mJARBaseURI);
|
||||
if (fileURL)
|
||||
fileURL->GetFile(getter_AddRefs(mDownloadedJARFile));
|
||||
rv = NS_NewDownloader(getter_AddRefs(mDownloader),
|
||||
mJARBaseURI, this, nsnull, mSynchronousRead,
|
||||
mLoadGroup, mCallbacks, mLoadFlags);
|
||||
|
||||
if (mDownloadedJARFile) {
|
||||
// after successfully downloading the jar file to the cache,
|
||||
// start the extraction process:
|
||||
if (mSynchronousRead)
|
||||
rv = OpenJARElement();
|
||||
else
|
||||
rv = AsyncReadJARElement();
|
||||
}
|
||||
else {
|
||||
rv = NS_NewDownloader(getter_AddRefs(mDownloader),
|
||||
mJARBaseURI, this, nsnull, mSynchronousRead,
|
||||
mLoadGroup, mCallbacks, mLoadFlags);
|
||||
|
||||
// if DownloadComplete() was called early, need to release the reference.
|
||||
if (mSynchronousRead && mSynchronousInputStream)
|
||||
mDownloader = 0;
|
||||
}
|
||||
// if DownloadComplete() was called early, need to release the reference.
|
||||
if (mSynchronousRead && mSynchronousInputStream)
|
||||
mDownloader = null_nsCOMPtr();
|
||||
|
||||
error:
|
||||
if (NS_FAILED(rv) && mLoadGroup) {
|
||||
|
|
Двоичные данные
netwerk/macbuild/netwerk.mcp
Двоичные данные
netwerk/macbuild/netwerk.mcp
Двоичный файл не отображается.
|
@ -34,7 +34,6 @@
|
|||
#include "nsIProgressEventSink.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIJAR.h"
|
||||
#include "nsIResProtocolHandler.h"
|
||||
|
||||
static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
|
||||
|
@ -287,7 +286,6 @@ nsresult
|
|||
nsJARChannel::EnsureJARFileAvailable()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFileURL> fileURL;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
nsXPIDLCString jarURLStr;
|
||||
|
@ -302,28 +300,13 @@ nsJARChannel::EnsureJARFileAvailable()
|
|||
rv = mURI->GetJAREntry(&mJAREntry);
|
||||
if (NS_FAILED(rv)) goto error;
|
||||
|
||||
// try to get a nsIFile directly from the url, which will often succeed.
|
||||
fileURL = do_QueryInterface(mJARBaseURI);
|
||||
if (fileURL)
|
||||
fileURL->GetFile(getter_AddRefs(mDownloadedJARFile));
|
||||
rv = NS_NewDownloader(getter_AddRefs(mDownloader),
|
||||
mJARBaseURI, this, nsnull, mSynchronousRead,
|
||||
mLoadGroup, mCallbacks, mLoadFlags);
|
||||
|
||||
if (mDownloadedJARFile) {
|
||||
// after successfully downloading the jar file to the cache,
|
||||
// start the extraction process:
|
||||
if (mSynchronousRead)
|
||||
rv = OpenJARElement();
|
||||
else
|
||||
rv = AsyncReadJARElement();
|
||||
}
|
||||
else {
|
||||
rv = NS_NewDownloader(getter_AddRefs(mDownloader),
|
||||
mJARBaseURI, this, nsnull, mSynchronousRead,
|
||||
mLoadGroup, mCallbacks, mLoadFlags);
|
||||
|
||||
// if DownloadComplete() was called early, need to release the reference.
|
||||
if (mSynchronousRead && mSynchronousInputStream)
|
||||
mDownloader = 0;
|
||||
}
|
||||
// if DownloadComplete() was called early, need to release the reference.
|
||||
if (mSynchronousRead && mSynchronousInputStream)
|
||||
mDownloader = null_nsCOMPtr();
|
||||
|
||||
error:
|
||||
if (NS_FAILED(rv) && mLoadGroup) {
|
||||
|
|
|
@ -75,9 +75,4 @@ interface nsIResProtocolHandler : nsIProtocolHandler
|
|||
* Returns true if substitutions are already defined for the specified root.
|
||||
*/
|
||||
boolean hasSubstitutions(in string root);
|
||||
|
||||
/**
|
||||
* Resolution utility function.
|
||||
*/
|
||||
string resolveURI(in nsIURI resourceURI);
|
||||
};
|
||||
|
|
|
@ -31,7 +31,7 @@ LIBRARY_NAME = nkres_s
|
|||
REQUIRES = xpcom string
|
||||
|
||||
CPPSRCS = \
|
||||
nsResURL.cpp \
|
||||
nsResChannel.cpp \
|
||||
nsResProtocolHandler.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ LIBRARY_NAME=nkres_s
|
|||
LCFLAGS = -DWIN32_LEAN_AND_MEAN -D_IMPL_NS_NET
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsResURL.obj \
|
||||
.\$(OBJDIR)\nsResChannel.obj \
|
||||
.\$(OBJDIR)\nsResProtocolHandler.obj \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "nsIURL.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsResChannel.h"
|
||||
#include "nsIFileChannel.h"
|
||||
#include "prenv.h"
|
||||
#include "prmem.h"
|
||||
#include "prprf.h"
|
||||
|
@ -33,30 +35,16 @@
|
|||
#include "nsIFile.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsResURL.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsResProtocolHandler *nsResProtocolHandler::mGlobalInstance = nsnull;
|
||||
|
||||
nsResProtocolHandler::nsResProtocolHandler()
|
||||
: mLock(nsnull), mSubstitutions(32)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
NS_ASSERTION(!mGlobalInstance, "res handler already created!");
|
||||
mGlobalInstance = this;
|
||||
}
|
||||
|
||||
nsResProtocolHandler::~nsResProtocolHandler()
|
||||
{
|
||||
if (mLock)
|
||||
PR_DestroyLock(mLock);
|
||||
|
||||
mGlobalInstance = nsnull;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -67,8 +55,14 @@ nsResProtocolHandler::SetSpecialDir(const char* rootName, const char* sysDir)
|
|||
rv = NS_GetSpecialDirectory(sysDir, getter_AddRefs(file));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIFileURL> fileURL(do_CreateInstance(kStandardURLCID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = fileURL->SetFile(file);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString spec;
|
||||
rv = file->GetURL(getter_Copies(spec));
|
||||
rv = fileURL->GetSpec(getter_Copies(spec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return AppendSubstitution(rootName, spec);
|
||||
|
@ -79,9 +73,6 @@ nsResProtocolHandler::Init()
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
mIOService = do_GetService(kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mLock = PR_NewLock();
|
||||
if (mLock == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -130,6 +121,12 @@ nsResProtocolHandler::Init()
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsResProtocolHandler::~nsResProtocolHandler()
|
||||
{
|
||||
if (mLock)
|
||||
PR_DestroyLock(mLock);
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS3(nsResProtocolHandler, nsIResProtocolHandler, nsIProtocolHandler, nsISupportsWeakReference)
|
||||
|
||||
NS_METHOD
|
||||
|
@ -182,31 +179,23 @@ nsResProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIURI> uri(do_CreateInstance(kStandardURLCID, &rv));
|
||||
nsCOMPtr<nsIURI> url(do_CreateInstance(kStandardURLCID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (aBaseURI) {
|
||||
nsXPIDLCString aResolvedURI;
|
||||
rv = aBaseURI->Resolve(aSpec, getter_Copies(aResolvedURI));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = uri->SetSpec(aResolvedURI);
|
||||
rv = url->SetSpec(aResolvedURI);
|
||||
} else {
|
||||
rv = uri->SetSpec((char*)aSpec);
|
||||
rv = url->SetSpec((char*)aSpec);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsResURL *resURL;
|
||||
NS_NEWXPCOM(resURL, nsResURL);
|
||||
if (!resURL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(resURL);
|
||||
|
||||
rv = resURL->Init(uri);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = CallQueryInterface(resURL, result);
|
||||
NS_RELEASE(resURL);
|
||||
*result = url;
|
||||
NS_ADDREF(*result);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -214,15 +203,19 @@ NS_IMETHODIMP
|
|||
nsResProtocolHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsXPIDLCString spec;
|
||||
|
||||
rv = ResolveURI(uri, getter_Copies(spec));
|
||||
nsResChannel* channel;
|
||||
rv = nsResChannel::Create(nsnull, NS_GET_IID(nsIResChannel), (void**)&channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mIOService->NewChannel(spec, nsnull, result);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = channel->Init(this, uri);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
}
|
||||
|
||||
return (*result)->SetOriginalURI(uri);
|
||||
*result = (nsIChannel*)(nsIResChannel*)channel;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -240,8 +233,10 @@ nsResProtocolHandler::PrependSubstitution(const char *root, const char *urlStr)
|
|||
nsresult rv;
|
||||
nsAutoLock lock(mLock);
|
||||
|
||||
nsCOMPtr<nsIIOService> ioServ = do_GetIOService(&rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIURI> url;
|
||||
rv = mIOService->NewURI(urlStr, nsnull, getter_AddRefs(url));
|
||||
rv = ioServ->NewURI(urlStr, nsnull, getter_AddRefs(url));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCStringKey key(root);
|
||||
|
@ -275,8 +270,10 @@ nsResProtocolHandler::AppendSubstitution(const char *root, const char *urlStr)
|
|||
nsresult rv;
|
||||
nsAutoLock lock(mLock);
|
||||
|
||||
nsCOMPtr<nsIIOService> ioServ = do_GetIOService(&rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIURI> url;
|
||||
rv = mIOService->NewURI(urlStr, nsnull, getter_AddRefs(url));
|
||||
rv = ioServ->NewURI(urlStr, nsnull, getter_AddRefs(url));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCStringKey key(root);
|
||||
|
@ -329,8 +326,10 @@ nsResProtocolHandler::RemoveSubstitution(const char *root, const char *urlStr)
|
|||
nsresult rv;
|
||||
nsAutoLock lock(mLock);
|
||||
|
||||
nsCOMPtr<nsIIOService> ioServ = do_GetIOService(&rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIURI> url;
|
||||
rv = mIOService->NewURI(urlStr, nsnull, getter_AddRefs(url));
|
||||
rv = ioServ->NewURI(urlStr, nsnull, getter_AddRefs(url));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCStringKey key(root);
|
||||
|
@ -383,29 +382,4 @@ nsResProtocolHandler::HasSubstitutions(const char *root, PRBool *result)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsResProtocolHandler::ResolveURI(nsIURI *uri, char **result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsXPIDLCString host, path;
|
||||
|
||||
rv = uri->GetHost(getter_Copies(host));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = uri->GetPath(getter_Copies(path));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> substitutions;
|
||||
rv = GetSubstitutions(host.get() ?
|
||||
host.get() : "", getter_AddRefs(substitutions));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// always use the first substitution
|
||||
nsCOMPtr<nsIURI> substURI;
|
||||
rv = substitutions->GetElementAt(0, getter_AddRefs(substURI));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return substURI->Resolve(path[0] == '/' ? path.get()+1 : path.get(), result);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "nsIResProtocolHandler.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
class nsResProtocolHandler : public nsIResProtocolHandler, public nsSupportsWeakReference
|
||||
|
@ -46,14 +45,9 @@ public:
|
|||
nsresult Init();
|
||||
nsresult SetSpecialDir(const char* rootName, const char* specialDir);
|
||||
|
||||
static nsResProtocolHandler *get() { return mGlobalInstance; }
|
||||
|
||||
private:
|
||||
static nsResProtocolHandler *mGlobalInstance;
|
||||
|
||||
PRLock* mLock;
|
||||
nsSupportsHashtable mSubstitutions;
|
||||
nsCOMPtr<nsIIOService> mIOService;
|
||||
protected:
|
||||
PRLock* mLock;
|
||||
nsSupportsHashtable mSubstitutions;
|
||||
};
|
||||
|
||||
#endif /* nsResProtocolHandler_h___ */
|
||||
|
|
|
@ -1,84 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications. Portions created by Netscape Communications are
|
||||
* Copyright (C) 2001 by Netscape Communications. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Darin Fisher <darin@netscape.com> (original author)
|
||||
*/
|
||||
|
||||
#include "nsResURL.h"
|
||||
#include "nsResProtocolHandler.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsResURL <public>
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
nsresult
|
||||
nsResURL::Init(nsIURI *uri)
|
||||
{
|
||||
nsresult rv;
|
||||
mStdURL = do_QueryInterface(uri, &rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsResURL::nsISupports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_ISUPPORTS3(nsResURL,
|
||||
nsIURI,
|
||||
nsIURL,
|
||||
nsIFileURL)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsResURL::nsIFileURL
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsResURL::GetFile(nsIFile **result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_ENSURE_TRUE(nsResProtocolHandler::get(), NS_ERROR_NOT_AVAILABLE);
|
||||
NS_ENSURE_TRUE(mStdURL, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsXPIDLCString spec;
|
||||
rv = nsResProtocolHandler::get()->ResolveURI(mStdURL, getter_Copies(spec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsILocalFile> localFile =
|
||||
do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = localFile->SetURL(spec);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return CallQueryInterface(localFile, result);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsResURL::SetFile(nsIFile *file)
|
||||
{
|
||||
NS_NOTREACHED("nsResURL::SetFile not implemented\n");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications. Portions created by Netscape Communications are
|
||||
* Copyright (C) 2001 by Netscape Communications. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Darin Fisher <darin@netscape.com> (original author)
|
||||
*/
|
||||
|
||||
#ifndef nsResURL_h__
|
||||
#define nsResURL_h__
|
||||
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsResURL : overrides nsStdURL::nsIFileURL to provide nsIFile resolution
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class nsResURL : nsIFileURL
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_FORWARD_SAFE_NSIURI(mStdURL)
|
||||
NS_FORWARD_SAFE_NSIURL(mStdURL)
|
||||
NS_DECL_NSIFILEURL
|
||||
|
||||
nsResURL() { NS_INIT_ISUPPORTS(); }
|
||||
virtual ~nsResURL() {}
|
||||
|
||||
nsresult Init(nsIURI *);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIURL> mStdURL;
|
||||
};
|
||||
|
||||
#endif // nsResURL_h__
|
Загрузка…
Ссылка в новой задаче