fixed bug 112345. JAR Channel does not cache mime service. r=neeti@netscape.com, sr=darin@netscape.com

This commit is contained in:
dougt%netscape.com 2001-11-29 22:29:00 +00:00
Родитель b59d15e912
Коммит 34620a6326
8 изменённых файлов: 46 добавлений и 10 удалений

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

@ -121,7 +121,7 @@ nsJARChannel::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
}
nsresult
nsJARChannel::Init(nsIJARProtocolHandler* aHandler, nsIURI* uri)
nsJARChannel::Init(nsJARProtocolHandler* aHandler, nsIURI* uri)
{
nsresult rv;
mURI = do_QueryInterface(uri, &rv);
@ -410,8 +410,8 @@ nsJARChannel::GetContentType(char* *aContentType)
}
if (ext) {
nsCOMPtr<nsIMIMEService> mimeServ (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv)) {
nsIMIMEService* mimeServ = mJARProtocolHandler->GetCachedMimeService();
if (mimeServ) {
rv = mimeServ->GetTypeFromExtension(ext, &mContentType);
}
}

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

@ -54,6 +54,7 @@
#include "prmon.h"
#include "nsIDownloader.h"
#include "nsIInputStream.h"
#include "nsJARProtocolHandler.h"
#ifdef DEBUG
#include "prthread.h"
@ -92,7 +93,7 @@ public:
static NS_METHOD
Create(nsISupports* aOuter, REFNSIID aIID, void **aResult);
nsresult Init(nsIJARProtocolHandler* aHandler, nsIURI* uri);
nsresult Init(nsJARProtocolHandler* aHandler, nsIURI* uri);
nsresult EnsureJARFileAvailable();
nsresult OpenJARElement();
nsresult AsyncReadJARElement();
@ -101,7 +102,7 @@ public:
friend class nsJARDownloadObserver;
protected:
nsCOMPtr<nsIJARProtocolHandler> mJARProtocolHandler;
nsCOMPtr<nsJARProtocolHandler> mJARProtocolHandler;
nsCOMPtr<nsIJARURI> mURI;
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;

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

@ -45,6 +45,9 @@
#include "nsJARChannel.h"
#include "nsXPIDLString.h"
#include "nsNetCID.h"
#include "nsCExternalHandlerService.h"
#include "nsIMIMEService.h"
#include "nsMimeTypes.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static NS_DEFINE_CID(kJARUriCID, NS_JARURI_CID);
@ -73,6 +76,15 @@ nsJARProtocolHandler::Init()
return rv;
}
nsIMIMEService*
nsJARProtocolHandler::GetCachedMimeService()
{
if (!mMimeService) {
mMimeService = do_GetService(NS_MIMESERVICE_CONTRACTID);
}
return mMimeService.get();
}
nsJARProtocolHandler::~nsJARProtocolHandler()
{
}

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

@ -42,6 +42,7 @@
#include "nsIProtocolHandler.h"
#include "nsIJARURI.h"
#include "nsIZipReader.h"
#include "nsIMIMEService.h"
#include "nsCOMPtr.h"
#define NS_JARPROTOCOLHANDLER_CID \
@ -69,8 +70,12 @@ public:
nsresult Init();
// returns non addref'ed pointer.
nsIMIMEService* GetCachedMimeService();
protected:
nsCOMPtr<nsIZipReaderCache> mJARCache;
nsCOMPtr<nsIMIMEService> mMimeService;
};
#endif /* nsJARProtocolHandler_h___ */

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

@ -121,7 +121,7 @@ nsJARChannel::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
}
nsresult
nsJARChannel::Init(nsIJARProtocolHandler* aHandler, nsIURI* uri)
nsJARChannel::Init(nsJARProtocolHandler* aHandler, nsIURI* uri)
{
nsresult rv;
mURI = do_QueryInterface(uri, &rv);
@ -410,8 +410,8 @@ nsJARChannel::GetContentType(char* *aContentType)
}
if (ext) {
nsCOMPtr<nsIMIMEService> mimeServ (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv)) {
nsIMIMEService* mimeServ = mJARProtocolHandler->GetCachedMimeService();
if (mimeServ) {
rv = mimeServ->GetTypeFromExtension(ext, &mContentType);
}
}

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

@ -54,6 +54,7 @@
#include "prmon.h"
#include "nsIDownloader.h"
#include "nsIInputStream.h"
#include "nsJARProtocolHandler.h"
#ifdef DEBUG
#include "prthread.h"
@ -92,7 +93,7 @@ public:
static NS_METHOD
Create(nsISupports* aOuter, REFNSIID aIID, void **aResult);
nsresult Init(nsIJARProtocolHandler* aHandler, nsIURI* uri);
nsresult Init(nsJARProtocolHandler* aHandler, nsIURI* uri);
nsresult EnsureJARFileAvailable();
nsresult OpenJARElement();
nsresult AsyncReadJARElement();
@ -101,7 +102,7 @@ public:
friend class nsJARDownloadObserver;
protected:
nsCOMPtr<nsIJARProtocolHandler> mJARProtocolHandler;
nsCOMPtr<nsJARProtocolHandler> mJARProtocolHandler;
nsCOMPtr<nsIJARURI> mURI;
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;

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

@ -45,6 +45,9 @@
#include "nsJARChannel.h"
#include "nsXPIDLString.h"
#include "nsNetCID.h"
#include "nsCExternalHandlerService.h"
#include "nsIMIMEService.h"
#include "nsMimeTypes.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static NS_DEFINE_CID(kJARUriCID, NS_JARURI_CID);
@ -73,6 +76,15 @@ nsJARProtocolHandler::Init()
return rv;
}
nsIMIMEService*
nsJARProtocolHandler::GetCachedMimeService()
{
if (!mMimeService) {
mMimeService = do_GetService(NS_MIMESERVICE_CONTRACTID);
}
return mMimeService.get();
}
nsJARProtocolHandler::~nsJARProtocolHandler()
{
}

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

@ -42,6 +42,7 @@
#include "nsIProtocolHandler.h"
#include "nsIJARURI.h"
#include "nsIZipReader.h"
#include "nsIMIMEService.h"
#include "nsCOMPtr.h"
#define NS_JARPROTOCOLHANDLER_CID \
@ -69,8 +70,12 @@ public:
nsresult Init();
// returns non addref'ed pointer.
nsIMIMEService* GetCachedMimeService();
protected:
nsCOMPtr<nsIZipReaderCache> mJARCache;
nsCOMPtr<nsIMIMEService> mMimeService;
};
#endif /* nsJARProtocolHandler_h___ */