diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 469e2683e39..194a7716ba5 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -47,16 +47,13 @@ #include "nsIURL.h" #include "nsIChannel.h" #include "nsIHTTPChannel.h" -#include "nsIStreamAsFile.h" #include "nsIFileStream.h" // for nsIRandomAccessStore #include "nsNetUtil.h" #include "nsIProgressEventSink.h" #include "nsIDocument.h" #include "nsIScriptablePlugin.h" - -#if MOZ_NEW_CACHE #include "nsICachingChannel.h" -#endif + // Friggin' X11 has to "#define None". Lame! #ifdef None #undef None @@ -1329,7 +1326,6 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request, nsISupports* aCo if (!channel) return NS_ERROR_FAILURE; -#if MOZ_NEW_CACHE nsCOMPtr cacheChannel = do_QueryInterface(channel); if (cacheChannel) { rv = cacheChannel->SetCacheAsFile(PR_TRUE); @@ -1339,7 +1335,6 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request, nsISupports* aCo NS_ASSERTION(PR_FALSE, "No Disk Cache Aval. Some plugins wont work."); } } -#endif char* aContentType = nsnull; rv = channel->GetContentType(&aContentType); @@ -1498,15 +1493,9 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request, char* urlString; nsCOMPtr localFile; -#if MOZ_NEW_CACHE nsCOMPtr cacheChannel = do_QueryInterface(channel); if (cacheChannel) rv = cacheChannel->GetCacheFile(getter_AddRefs(localFile)); -#else - nsCOMPtr streamAsFile = do_QueryInterface(channel); - if (streamAsFile) - rv = streamAsFile->GetFile(getter_AddRefs(localFile)); -#endif if (NS_SUCCEEDED(rv) && localFile) { char* pathAndFilename; diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp index 469e2683e39..194a7716ba5 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -47,16 +47,13 @@ #include "nsIURL.h" #include "nsIChannel.h" #include "nsIHTTPChannel.h" -#include "nsIStreamAsFile.h" #include "nsIFileStream.h" // for nsIRandomAccessStore #include "nsNetUtil.h" #include "nsIProgressEventSink.h" #include "nsIDocument.h" #include "nsIScriptablePlugin.h" - -#if MOZ_NEW_CACHE #include "nsICachingChannel.h" -#endif + // Friggin' X11 has to "#define None". Lame! #ifdef None #undef None @@ -1329,7 +1326,6 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request, nsISupports* aCo if (!channel) return NS_ERROR_FAILURE; -#if MOZ_NEW_CACHE nsCOMPtr cacheChannel = do_QueryInterface(channel); if (cacheChannel) { rv = cacheChannel->SetCacheAsFile(PR_TRUE); @@ -1339,7 +1335,6 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request, nsISupports* aCo NS_ASSERTION(PR_FALSE, "No Disk Cache Aval. Some plugins wont work."); } } -#endif char* aContentType = nsnull; rv = channel->GetContentType(&aContentType); @@ -1498,15 +1493,9 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request, char* urlString; nsCOMPtr localFile; -#if MOZ_NEW_CACHE nsCOMPtr cacheChannel = do_QueryInterface(channel); if (cacheChannel) rv = cacheChannel->GetCacheFile(getter_AddRefs(localFile)); -#else - nsCOMPtr streamAsFile = do_QueryInterface(channel); - if (streamAsFile) - rv = streamAsFile->GetFile(getter_AddRefs(localFile)); -#endif if (NS_SUCCEEDED(rv) && localFile) { char* pathAndFilename; diff --git a/mozilla/netwerk/base/public/nsIDownloader.idl b/mozilla/netwerk/base/public/nsIDownloader.idl index 4698b872dec..95983409997 100644 --- a/mozilla/netwerk/base/public/nsIDownloader.idl +++ b/mozilla/netwerk/base/public/nsIDownloader.idl @@ -20,12 +20,10 @@ * Contributor(s): */ -#include "nsISupports.idl" -#include "nsIChannel.idl" +#include "nsIRequest.idl" interface nsIURI; interface nsILoadGroup; -interface nsIStreamLoader; interface nsIInterfaceRequestor; interface nsIFile; interface nsIDownloader; @@ -50,12 +48,3 @@ interface nsIDownloader : nsISupports in nsIInterfaceRequestor notificationCallbacks, in nsLoadFlags loadAttributes); }; - -%{C++ - -#define NS_DOWNLOADER_CID \ -{ /* 510a86bb-6019-4ed1-bb4f-965cffd23ece*/ \ - 0x510a86bb, 0x6019, 0x4ed1, { 0xbb, 0x4f, 0x96, 0x5c, 0xff, 0xd2, 0x3e, 0xce } \ -} - -%} diff --git a/mozilla/netwerk/base/src/nsDownloader.cpp b/mozilla/netwerk/base/src/nsDownloader.cpp index 18c6fb60422..77bfdd9a2c7 100644 --- a/mozilla/netwerk/base/src/nsDownloader.cpp +++ b/mozilla/netwerk/base/src/nsDownloader.cpp @@ -26,16 +26,12 @@ #include "nsNetUtil.h" #include "nsIChannel.h" #include "nsIFileChannel.h" +#include "nsICachingChannel.h" #include "nsProxiedService.h" #include "nsIFile.h" #include "nsXPIDLString.h" -#include "nsCacheManager.h" -#include "nsICachedNetData.h" -#include "nsIStreamAsFile.h" - static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID); -static NS_DEFINE_CID(kNetworkCacheManagerCID, NS_CACHE_MANAGER_CID); NS_IMETHODIMP nsDownloader::Init(nsIURI* aURL, @@ -52,7 +48,6 @@ nsDownloader::Init(nsIURI* aURL, nsCOMPtr localFile; nsCOMPtr channel; - aLoadAttributes |= nsIChannel::CACHE_AS_FILE; rv = NS_OpenURI(getter_AddRefs(channel), aURL, nsnull, aGroup, aNotificationCallbacks, aLoadAttributes); if (NS_SUCCEEDED(rv) && channel) @@ -106,7 +101,12 @@ NS_IMPL_ISUPPORTS3(nsDownloader, nsIDownloader, NS_IMETHODIMP nsDownloader::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { - return NS_OK; + nsresult rv; + nsCOMPtr caching = do_QueryInterface(request, &rv); + if (caching) + rv = caching->SetCacheAsFile(PR_TRUE); + // Returning failure from here will cancel the load + return rv; } NS_IMETHODIMP @@ -116,34 +116,9 @@ nsDownloader::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsCOMPtr file; if (NS_SUCCEEDED(aStatus)) { - nsresult rv; - nsCOMPtr uri; - - nsCOMPtr channel = do_QueryInterface(request, &rv); - if (NS_FAILED(rv)) return rv; - - rv = channel->GetURI(getter_AddRefs(uri)); - if (NS_FAILED(rv)) return rv; - nsXPIDLCString spec; - rv = uri->GetSpec(getter_Copies(spec)); - if (NS_FAILED(rv)) return rv; - - NS_WITH_SERVICE(nsINetDataCacheManager, cacheMgr, kNetworkCacheManagerCID, &rv); - if (NS_FAILED(rv)) return rv; - nsCOMPtr cachedData; - rv = cacheMgr->GetCachedNetData(spec, nsnull, 0, nsINetDataCacheManager::CACHE_AS_FILE, - getter_AddRefs(cachedData)); - - - if (NS_SUCCEEDED(rv)) - { - nsCOMPtr streamAsFile; - streamAsFile = do_QueryInterface(cachedData, &rv); - if (NS_FAILED(rv)) return rv; - - rv = streamAsFile->GetFile(getter_AddRefs(file)); - if (NS_FAILED(rv)) return rv; - } + nsCOMPtr caching = do_QueryInterface(request, &aStatus); + if (caching) + aStatus = caching->GetCacheFile(getter_AddRefs(file)); } return mObserver->OnDownloadComplete(this, mContext, aStatus, file); diff --git a/mozilla/netwerk/base/src/nsDownloader.h b/mozilla/netwerk/base/src/nsDownloader.h index c4f8acd3b1a..c0d04724985 100644 --- a/mozilla/netwerk/base/src/nsDownloader.h +++ b/mozilla/netwerk/base/src/nsDownloader.h @@ -47,7 +47,6 @@ public: protected: nsCOMPtr mObserver; nsCOMPtr mContext; // the observer's context -/// nsCOMPtr mLoadGroup; }; #endif // nsDownloader_h__ diff --git a/mozilla/netwerk/build/Makefile.in b/mozilla/netwerk/build/Makefile.in index aff4c9c993f..c7a6748c913 100644 --- a/mozilla/netwerk/build/Makefile.in +++ b/mozilla/netwerk/build/Makefile.in @@ -40,9 +40,6 @@ SHARED_LIBRARY_LIBS = \ $(DIST)/lib/libneckosocket_s.$(LIB_SUFFIX) \ $(DIST)/lib/libnkconv_s.$(LIB_SUFFIX) \ $(DIST)/lib/libnkcnvts_s.$(LIB_SUFFIX) \ - $(DIST)/lib/libnkcachemgr_s.$(LIB_SUFFIX) \ - $(DIST)/lib/libnkfilecache_s.$(LIB_SUFFIX) \ - $(DIST)/lib/libnkmemcache_s.$(LIB_SUFFIX) \ $(DIST)/lib/libnkmime_s.$(LIB_SUFFIX) \ $(DIST)/lib/libnkhttp_s.$(LIB_SUFFIX) \ $(DIST)/lib/libnkfile_s.$(LIB_SUFFIX) \ @@ -53,6 +50,14 @@ SHARED_LIBRARY_LIBS = \ $(DIST)/lib/libnkkwd_s.$(LIB_SUFFIX) \ $(NULL) +ifdef OLD_CACHE +SHARED_LIBRARY_LIBS += \ + $(DIST)/lib/libnkcachemgr_s.$(LIB_SUFFIX) \ + $(DIST)/lib/libnkfilecache_s.$(LIB_SUFFIX) \ + $(DIST)/lib/libnkmemcache_s.$(LIB_SUFFIX) \ + $(NULL) +endif + ifeq ($(MOZ_WIDGET_TOOLKIT),os2) SHARED_LIBRARY_LIBS += $(DIST)/lib/libmozdbm_s.$(LIB_SUFFIX) endif @@ -67,9 +72,6 @@ LOCAL_INCLUDES = \ -I$(srcdir)/../socket/base \ -I$(srcdir)/../streamconv/src \ -I$(srcdir)/../streamconv/converters \ - -I$(srcdir)/../cache/memcache \ - -I$(srcdir)/../cache/filecache \ - -I$(srcdir)/../cache/mgr \ -I$(srcdir)/../mime/src \ -I$(srcdir)/../protocol/http/src \ -I$(srcdir)/../protocol/file/src \ @@ -80,6 +82,15 @@ LOCAL_INCLUDES = \ -I$(srcdir)/../protocol/keyword/src \ $(NULL) +ifdef OLD_CACHE +LOCAL_INCLUDES += \ + -I$(srcdir)/../cache/memcache \ + -I$(srcdir)/../cache/filecache \ + -I$(srcdir)/../cache/mgr \ + $(NULL) +endif + + EXTRA_DSO_LDOPTS = \ $(MOZ_COMPONENT_LIBS) \ $(ZLIB_LIBS) \ diff --git a/mozilla/netwerk/build/makefile.win b/mozilla/netwerk/build/makefile.win index e3aa8864c56..466ad1ef90b 100644 --- a/mozilla/netwerk/build/makefile.win +++ b/mozilla/netwerk/build/makefile.win @@ -44,11 +44,13 @@ LLIBS= \ $(DIST)\lib\neckosocket_s.lib \ $(DIST)\lib\nkconv_s.lib \ $(DIST)\lib\nkcnvts_s.lib \ - $(DIST)\lib\xpcom.lib \ + $(DIST)\lib\xpcom.lib \ +!ifdef MOZ_OLD_CACHE $(DIST)\lib\nkcachemgr_s.lib \ $(DIST)\lib\nkfilecache_s.lib \ $(DIST)\lib\nkmemcache_s.lib \ - $(DIST)\lib\dbm32.lib \ + $(DIST)\lib\dbm32.lib \ +!endif $(DIST)\lib\nkmime_s.lib \ $(DIST)\lib\nkhttp_s.lib \ $(DIST)\lib\nkfile_s.lib \ @@ -69,10 +71,12 @@ INCS = $(INCS) \ -I$(DEPTH)\netwerk\dns\src \ -I$(DEPTH)\netwerk\socket\base \ -I$(DEPTH)\netwerk\streamconv\src \ - -I$(DEPTH)\netwerk\streamconv\converters \ + -I$(DEPTH)\netwerk\streamconv\converters \ +!ifdef MOZ_OLD_CACHE -I$(DEPTH)\netwerk\cache\memcache \ -I$(DEPTH)\netwerk\cache\filecache \ - -I$(DEPTH)\netwerk\cache\mgr \ + -I$(DEPTH)\netwerk\cache\mgr \ +!endif -I$(DEPTH)\netwerk\mime\src \ -I$(DEPTH)\netwerk\protocol\http\src \ -I$(DEPTH)\netwerk\protocol\file\src \ diff --git a/mozilla/netwerk/build/nsNetCID.h b/mozilla/netwerk/build/nsNetCID.h index acf9892f20b..bc25dba3ce3 100644 --- a/mozilla/netwerk/build/nsNetCID.h +++ b/mozilla/netwerk/build/nsNetCID.h @@ -185,6 +185,18 @@ {0x98, 0x6e, 0x00, 0xc0, 0x4f, 0xa0, 0xcf, 0x4a} \ } +#define NS_DOWNLOADER_CLASSNAME \ + "File Downloader" +#define NS_DOWNLOADER_CONTRACTID \ + "@mozilla.org/network/downloader;1" +#define NS_DOWNLOADER_CID \ +{ /* 510a86bb-6019-4ed1-bb4f-965cffd23ece */ \ + 0x510a86bb, \ + 0x6019, \ + 0x4ed1, \ + {0xbb, 0x4f, 0x96, 0x5c, 0xff, 0xd2, 0x3e, 0xce} \ +} + /****************************************************************************** * netwerk/cache/ classes diff --git a/mozilla/netwerk/build/nsNetModule.cpp b/mozilla/netwerk/build/nsNetModule.cpp index 4654fc609de..c2d36d7b560 100644 --- a/mozilla/netwerk/build/nsNetModule.cpp +++ b/mozilla/netwerk/build/nsNetModule.cpp @@ -56,6 +56,7 @@ /////////////////////////////////////////////////////////////////////////////// +#if defined(OLD_CACHE) #include "nsINetDataCache.h" #include "nsINetDataCacheManager.h" #include "nsMemCacheCID.h" @@ -69,6 +70,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMemCache, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNetDiskCache, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCacheManager, Init) +#endif /////////////////////////////////////////////////////////////////////////////// @@ -569,9 +571,9 @@ static nsModuleComponentInfo gNetModuleInfo[] = { NS_STREAMLOADER_CID, "@mozilla.org/network/stream-loader;1", nsStreamLoader::Create }, - { "Stream-As-File Downloader", + { NS_DOWNLOADER_CLASSNAME, NS_DOWNLOADER_CID, - "@mozilla.org/network/downloader;1", + NS_DOWNLOADER_CONTRACTID, nsDownloader::Create }, { NS_REQUESTOBSERVERPROXY_CLASSNAME, NS_REQUESTOBSERVERPROXY_CID, @@ -750,12 +752,12 @@ static nsModuleComponentInfo gNetModuleInfo[] = { NS_ISTREAMCONVERTER_KEY, CreateNewTXTToHTMLConvFactory }, - +#if defined(OLD_CACHE) // from netwerk/cache: { "Memory Cache", NS_MEM_CACHE_FACTORY_CID, NS_NETWORK_MEMORY_CACHE_CONTRACTID, nsMemCacheConstructor }, { "File Cache", NS_NETDISKCACHE_CID, NS_NETWORK_FILE_CACHE_CONTRACTID, nsNetDiskCacheConstructor }, { "Cache Manager",NS_CACHE_MANAGER_CID, NS_NETWORK_CACHE_MANAGER_CONTRACTID,nsCacheManagerConstructor }, - +#endif // from netwerk/mime: { "The MIME mapping service", NS_MIMESERVICE_CID, diff --git a/mozilla/netwerk/cache/Makefile.in b/mozilla/netwerk/cache/Makefile.in index 1a4ab99e820..4e3d6140d92 100644 --- a/mozilla/netwerk/cache/Makefile.in +++ b/mozilla/netwerk/cache/Makefile.in @@ -27,12 +27,17 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk DIRS = \ - public \ - memcache \ - filecache \ - mgr \ + public \ $(NULL) +ifdef OLD_CACHE +DIRS += \ + memcache \ + filecache \ + mgr \ + $(NULL) +endif + ifdef MOZ_NEW_CACHE DIRS += src endif diff --git a/mozilla/netwerk/cache/Makefile.win b/mozilla/netwerk/cache/Makefile.win index 4fa098374a7..7bb8739f999 100755 --- a/mozilla/netwerk/cache/Makefile.win +++ b/mozilla/netwerk/cache/Makefile.win @@ -24,10 +24,12 @@ DEPTH=..\.. include <$(DEPTH)/config/config.mak> DIRS= \ - public \ + public \ +!ifdef MOZ_OLD_CACHE mgr \ memcache \ filecache \ +!endif !ifdef MOZ_NEW_CACHE src \ !endif diff --git a/mozilla/netwerk/cache/public/Makefile.in b/mozilla/netwerk/cache/public/Makefile.in index 04aea67e379..cf711bc244c 100644 --- a/mozilla/netwerk/cache/public/Makefile.in +++ b/mozilla/netwerk/cache/public/Makefile.in @@ -29,7 +29,10 @@ XPIDL_MODULE = necko_cache include $(DEPTH)/config/autoconf.mk -XPIDLSRCS = \ +XPIDLSRCS = $(NULL) + +ifdef OLD_CACHE +XPIDLSRCS += \ nsICachedNetData.idl \ nsINetDataCacheManager.idl \ nsINetDataCache.idl \ @@ -37,6 +40,7 @@ XPIDLSRCS = \ nsINetDataDiskCache.idl \ nsIStreamAsFile.idl \ $(NULL) +endif ifdef MOZ_NEW_CACHE diff --git a/mozilla/netwerk/cache/public/Makefile.win b/mozilla/netwerk/cache/public/Makefile.win index 2d93f5e53fd..7264a99d55a 100755 --- a/mozilla/netwerk/cache/public/Makefile.win +++ b/mozilla/netwerk/cache/public/Makefile.win @@ -29,13 +29,15 @@ include <$(DEPTH)/config/config.mak> EXPORTS = \ $(NULL) -XPIDLSRCS = \ +XPIDLSRCS = \ +!ifdef MOZ_OLD_CACHE .\nsICachedNetData.idl \ .\nsINetDataCacheManager.idl \ .\nsINetDataCache.idl \ .\nsINetDataCacheRecord.idl \ .\nsINetDataDiskCache.idl \ - .\nsIStreamAsFile.idl \ + .\nsIStreamAsFile.idl \ +!endif !ifdef MOZ_NEW_CACHE .\nsICache.idl \ .\nsICacheEntryDescriptor.idl \ diff --git a/mozilla/netwerk/macbuild/netwerk.mcp b/mozilla/netwerk/macbuild/netwerk.mcp index 0ca124c9474..56d12bb7da5 100644 Binary files a/mozilla/netwerk/macbuild/netwerk.mcp and b/mozilla/netwerk/macbuild/netwerk.mcp differ diff --git a/mozilla/netwerk/macbuild/netwerkIDL.mcp b/mozilla/netwerk/macbuild/netwerkIDL.mcp index bf9015e1325..40c75ec8742 100644 Binary files a/mozilla/netwerk/macbuild/netwerkIDL.mcp and b/mozilla/netwerk/macbuild/netwerkIDL.mcp differ diff --git a/mozilla/netwerk/test/makefile.win b/mozilla/netwerk/test/makefile.win index e9adaf2e94e..ad1cd8e3d57 100644 --- a/mozilla/netwerk/test/makefile.win +++ b/mozilla/netwerk/test/makefile.win @@ -31,14 +31,12 @@ PROG6 = .\$(OBJDIR)\urltest.exe PROG7 = .\$(OBJDIR)\TestFileInput2.exe PROG8 = .\$(OBJDIR)\TestFileTransport.exe PROG9 = .\$(OBJDIR)\TestRes.exe -PROGA = .\$(OBJDIR)\TestRawCache.exe -PROGB = .\$(OBJDIR)\TestCacheMgr.exe PROGC = .\$(OBJDIR)\TestWriteStream.exe PROGD = .\$(OBJDIR)\TestWriteSpeed.exe PROGE = .\$(OBJDIR)\TestCallbacks.exe PROGRAMS = \ $(PROG1) $(PROG2) $(PROG3) $(PROG4) $(PROG5) $(PROG6) $(PROG7) $(PROG8) $(PROG9)\ - $(PROGA) $(PROGB) $(PROGC) $(PROGD) $(PROGE) + $(PROGC) $(PROGD) $(PROGE) LCFLAGS=-DUSE_NSREG -GX @@ -78,10 +76,6 @@ $(PROG8): $(OBJDIR) TestFileTransport.cpp $(PROG9): $(OBJDIR) TestRes.cpp -$(PROGA): $(OBJDIR) TestRawCache.cpp - -$(PROGB): $(OBJDIR) TestCacheMgr.cpp - $(PROGC): $(OBJDIR) TestWriteStream.cpp $(PROGD): $(OBJDIR) TestWriteSpeed.cpp