Commit d89fa6a2 authored by dougt%netscape.com's avatar dougt%netscape.com
Browse files

fixed bug 112345. JAR Channel does not cache mime service....

fixed bug 112345.  JAR Channel does not cache mime service. r=neeti@netscape.com, sr=darin@netscape.com
parent d1ee5ffd
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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);
                }
            }
+3 −2
Original line number Diff line number Diff line
@@ -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;
+12 −0
Original line number Diff line number Diff line
@@ -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()
{
}
+5 −0
Original line number Diff line number Diff line
@@ -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___ */
+3 −3
Original line number Diff line number Diff line
@@ -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);
                }
            }
Loading