2015-10-27 03:34:38 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-06-02 01:08:32 +04:00
|
|
|
#include <string.h>
|
2000-01-29 03:03:57 +03:00
|
|
|
#include "nsJARInputStream.h"
|
|
|
|
#include "nsJAR.h"
|
2012-06-06 06:08:30 +04:00
|
|
|
#include "nsIFile.h"
|
Bug 1600545 - Remove useless inclusions of header files generated from IDL files in modules/, netwerk/, parser/, security/, startupcache/, storage/, toolkit/, tools/, uriloader/, widget/, xpcom/ and xpfe/ r=Ehsan
The inclusions were removed with the following very crude script and the
resulting breakage was fixed up by hand. The manual fixups did either
revert the changes done by the script, replace a generic header with a more
specific one or replace a header with a forward declaration.
find . -name "*.idl" | grep -v web-platform | grep -v third_party | while read path; do
interfaces=$(grep "^\(class\|interface\).*:.*" "$path" | cut -d' ' -f2)
if [ -n "$interfaces" ]; then
if [[ "$interfaces" == *$'\n'* ]]; then
regexp="\("
for i in $interfaces; do regexp="$regexp$i\|"; done
regexp="${regexp%%\\\|}\)"
else
regexp="$interfaces"
fi
interface=$(basename "$path")
rg -l "#include.*${interface%%.idl}.h" . | while read path2; do
hits=$(grep -v "#include.*${interface%%.idl}.h" "$path2" | grep -c "$regexp" )
if [ $hits -eq 0 ]; then
echo "Removing ${interface} from ${path2}"
grep -v "#include.*${interface%%.idl}.h" "$path2" > "$path2".tmp
mv -f "$path2".tmp "$path2"
fi
done
fi
done
Differential Revision: https://phabricator.services.mozilla.com/D55444
--HG--
extra : moz-landing-system : lando
2019-12-06 12:17:57 +03:00
|
|
|
#include "nsIObserverService.h"
|
2018-02-20 20:28:12 +03:00
|
|
|
#include "mozilla/DebugOnly.h"
|
2022-03-24 16:55:26 +03:00
|
|
|
#include "mozilla/Logging.h"
|
2010-09-10 01:01:00 +04:00
|
|
|
#include "mozilla/Omnijar.h"
|
2016-11-18 07:00:30 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2000-03-21 07:21:28 +03:00
|
|
|
|
2000-02-21 23:19:16 +03:00
|
|
|
#ifdef XP_UNIX
|
|
|
|
# include <sys/stat.h>
|
2014-02-11 02:57:01 +04:00
|
|
|
#elif defined(XP_WIN)
|
2000-02-21 23:19:16 +03:00
|
|
|
# include <io.h>
|
|
|
|
#endif
|
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2022-03-24 16:55:26 +03:00
|
|
|
static LazyLogModule gJarLog("nsJAR");
|
|
|
|
|
|
|
|
#ifdef LOG
|
|
|
|
# undef LOG
|
|
|
|
#endif
|
|
|
|
#ifdef LOG_ENABLED
|
|
|
|
# undef LOG_ENABLED
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LOG(args) MOZ_LOG(gJarLog, mozilla::LogLevel::Debug, args)
|
|
|
|
#define LOG_ENABLED() MOZ_LOG_TEST(gJarLog, mozilla::LogLevel::Debug)
|
|
|
|
|
2000-02-14 04:57:01 +03:00
|
|
|
//----------------------------------------------
|
|
|
|
// nsJAR constructor/destructor
|
|
|
|
//----------------------------------------------
|
1999-06-02 01:08:32 +04:00
|
|
|
|
2000-04-26 07:50:07 +04:00
|
|
|
// The following initialization makes a guess of 10 entries per jarfile.
|
2010-09-10 01:01:00 +04:00
|
|
|
nsJAR::nsJAR()
|
2022-03-24 16:54:56 +03:00
|
|
|
: mReleaseTime(PR_INTERVAL_NO_TIMEOUT),
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
mLock("nsJAR::mLock"),
|
2022-03-24 16:54:56 +03:00
|
|
|
mCache(nullptr) {}
|
1999-06-02 01:08:32 +04:00
|
|
|
|
|
|
|
nsJAR::~nsJAR() { Close(); }
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_QUERY_INTERFACE(nsJAR, nsIZipReader)
|
2013-07-19 06:23:44 +04:00
|
|
|
NS_IMPL_ADDREF(nsJAR)
|
2000-08-23 07:18:53 +04:00
|
|
|
|
|
|
|
// Custom Release method works with nsZipReaderCache...
|
2017-10-20 05:29:41 +03:00
|
|
|
// Release might be called from multi-thread, we have to
|
|
|
|
// take this function carefully to avoid delete-after-use.
|
2014-03-28 00:38:33 +04:00
|
|
|
MozExternalRefCountType nsJAR::Release(void) {
|
2014-02-25 05:16:11 +04:00
|
|
|
nsrefcnt count;
|
2018-04-28 22:50:58 +03:00
|
|
|
MOZ_ASSERT(0 != mRefCnt, "dup release");
|
2017-10-20 05:29:41 +03:00
|
|
|
|
|
|
|
RefPtr<nsZipReaderCache> cache;
|
|
|
|
if (mRefCnt == 2) { // don't use a lock too frequently
|
|
|
|
// Use a mutex here to guarantee mCache is not racing and the target
|
|
|
|
// instance is still valid to increase ref-count.
|
2022-03-24 16:54:56 +03:00
|
|
|
RecursiveMutexAutoLock lock(mLock);
|
2017-10-20 05:29:41 +03:00
|
|
|
cache = mCache;
|
|
|
|
mCache = nullptr;
|
|
|
|
}
|
|
|
|
if (cache) {
|
|
|
|
DebugOnly<nsresult> rv = cache->ReleaseZip(this);
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv), "failed to release zip file");
|
|
|
|
}
|
|
|
|
|
|
|
|
count = --mRefCnt; // don't access any member variable after this line
|
2014-02-25 05:16:11 +04:00
|
|
|
NS_LOG_RELEASE(this, count, "nsJAR");
|
2000-08-23 07:18:53 +04:00
|
|
|
if (0 == count) {
|
2014-02-25 05:16:11 +04:00
|
|
|
mRefCnt = 1; /* stabilize */
|
|
|
|
/* enable this to find non-threadsafe destructors: */
|
|
|
|
/* NS_ASSERT_OWNINGTHREAD(nsJAR); */
|
2010-07-05 13:42:18 +04:00
|
|
|
delete this;
|
2014-02-25 05:16:11 +04:00
|
|
|
return 0;
|
2000-08-23 07:18:53 +04:00
|
|
|
}
|
2017-10-20 05:29:41 +03:00
|
|
|
|
2014-02-25 05:16:11 +04:00
|
|
|
return count;
|
|
|
|
}
|
1999-06-02 01:08:32 +04:00
|
|
|
|
2000-02-14 04:57:01 +03:00
|
|
|
//----------------------------------------------
|
2001-02-23 03:15:04 +03:00
|
|
|
// nsIZipReader implementation
|
2000-02-14 04:57:01 +03:00
|
|
|
//----------------------------------------------
|
2000-04-12 11:58:24 +04:00
|
|
|
|
1999-06-02 01:08:32 +04:00
|
|
|
NS_IMETHODIMP
|
2006-05-02 23:33:09 +04:00
|
|
|
nsJAR::Open(nsIFile* zipFile) {
|
2009-01-22 18:12:00 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(zipFile);
|
2022-03-24 16:54:56 +03:00
|
|
|
RecursiveMutexAutoLock lock(mLock);
|
2022-03-24 16:55:26 +03:00
|
|
|
LOG(("Open[%p] %s", this, zipFile->HumanReadablePath().get()));
|
2022-03-24 16:54:56 +03:00
|
|
|
if (mZip) return NS_ERROR_FAILURE; // Already open!
|
2006-05-02 23:33:09 +04:00
|
|
|
|
1999-11-12 09:13:13 +03:00
|
|
|
mZipFile = zipFile;
|
2011-03-31 23:01:12 +04:00
|
|
|
mOuterZipEntry.Truncate();
|
2014-02-25 05:16:11 +04:00
|
|
|
|
2010-09-10 01:01:00 +04:00
|
|
|
// The omnijar is special, it is opened early on and closed late
|
2020-09-14 20:00:53 +03:00
|
|
|
RefPtr<nsZipArchive> zip = mozilla::Omnijar::GetReader(zipFile);
|
2022-03-24 16:54:56 +03:00
|
|
|
if (!zip) {
|
|
|
|
zip = nsZipArchive::OpenArchive(zipFile);
|
2010-09-10 01:01:00 +04:00
|
|
|
}
|
2022-03-24 16:54:56 +03:00
|
|
|
mZip = zip;
|
|
|
|
return mZip ? NS_OK : NS_ERROR_FAILURE;
|
1999-06-02 01:08:32 +04:00
|
|
|
}
|
|
|
|
|
2010-09-09 07:38:34 +04:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 03:14:45 +04:00
|
|
|
nsJAR::OpenInner(nsIZipReader* aZipReader, const nsACString& aZipEntry) {
|
2022-03-24 16:54:56 +03:00
|
|
|
nsresult rv;
|
|
|
|
|
2022-03-24 16:55:26 +03:00
|
|
|
LOG(("OpenInner[%p] %s", this, PromiseFlatCString(aZipEntry).get()));
|
2010-09-09 07:38:34 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(aZipReader);
|
|
|
|
|
2022-03-24 16:54:56 +03:00
|
|
|
nsCOMPtr<nsIFile> zipFile;
|
|
|
|
rv = aZipReader->GetFile(getter_AddRefs(zipFile));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2020-09-14 20:00:53 +03:00
|
|
|
RefPtr<nsZipArchive> innerZip =
|
2022-03-24 16:54:56 +03:00
|
|
|
mozilla::Omnijar::GetInnerReader(zipFile, aZipEntry);
|
2020-03-06 23:35:53 +03:00
|
|
|
if (innerZip) {
|
2022-03-24 16:54:56 +03:00
|
|
|
RecursiveMutexAutoLock lock(mLock);
|
|
|
|
if (mZip) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2020-03-06 23:35:53 +03:00
|
|
|
mZip = innerZip;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool exist;
|
2022-03-24 16:54:56 +03:00
|
|
|
rv = aZipReader->HasEntry(aZipEntry, &exist);
|
2010-09-20 23:58:40 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
NS_ENSURE_TRUE(exist, NS_ERROR_FILE_NOT_FOUND);
|
|
|
|
|
2022-03-08 20:08:23 +03:00
|
|
|
RefPtr<nsZipHandle> handle;
|
2022-03-24 16:54:56 +03:00
|
|
|
{
|
|
|
|
nsJAR* outerJAR = static_cast<nsJAR*>(aZipReader);
|
|
|
|
RecursiveMutexAutoLock outerLock(outerJAR->mLock);
|
|
|
|
rv = nsZipHandle::Init(outerJAR->mZip.get(),
|
|
|
|
PromiseFlatCString(aZipEntry).get(),
|
|
|
|
getter_AddRefs(handle));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
2022-03-08 20:08:23 +03:00
|
|
|
|
2022-03-24 16:54:56 +03:00
|
|
|
RecursiveMutexAutoLock lock(mLock);
|
|
|
|
MOZ_ASSERT(!mZip, "Another thread tried to open this nsJAR racily!");
|
|
|
|
mZipFile = zipFile.forget();
|
|
|
|
mOuterZipEntry.Assign(aZipEntry);
|
|
|
|
mZip = nsZipArchive::OpenArchive(handle);
|
|
|
|
return mZip ? NS_OK : NS_ERROR_FAILURE;
|
2010-09-09 07:38:34 +04:00
|
|
|
}
|
|
|
|
|
2000-04-12 11:58:24 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJAR::GetFile(nsIFile** result) {
|
2022-03-24 16:54:56 +03:00
|
|
|
RecursiveMutexAutoLock lock(mLock);
|
2022-03-24 16:55:26 +03:00
|
|
|
LOG(("GetFile[%p]", this));
|
2000-04-12 11:58:24 +04:00
|
|
|
*result = mZipFile;
|
2003-09-24 05:48:09 +04:00
|
|
|
NS_IF_ADDREF(*result);
|
2000-04-12 11:58:24 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-02 01:08:32 +04:00
|
|
|
NS_IMETHODIMP
|
2006-05-02 23:33:09 +04:00
|
|
|
nsJAR::Close() {
|
2022-03-24 16:54:56 +03:00
|
|
|
RecursiveMutexAutoLock lock(mLock);
|
2022-03-24 16:55:26 +03:00
|
|
|
LOG(("Close[%p]", this));
|
2022-03-24 16:54:56 +03:00
|
|
|
if (!mZip) {
|
2016-04-28 23:07:02 +03:00
|
|
|
return NS_ERROR_FAILURE; // Never opened or already closed.
|
|
|
|
}
|
|
|
|
|
2022-03-24 16:54:56 +03:00
|
|
|
mZip = nullptr;
|
|
|
|
return NS_OK;
|
1999-11-12 09:13:13 +03:00
|
|
|
}
|
|
|
|
|
2000-12-27 10:05:55 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 03:14:45 +04:00
|
|
|
nsJAR::Test(const nsACString& aEntryName) {
|
2022-03-24 16:54:56 +03:00
|
|
|
RecursiveMutexAutoLock lock(mLock);
|
|
|
|
if (!mZip) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
return mZip->Test(
|
|
|
|
aEntryName.IsEmpty() ? nullptr : PromiseFlatCString(aEntryName).get());
|
2000-12-27 10:05:55 +03:00
|
|
|
}
|
|
|
|
|
1999-11-12 09:13:13 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 03:14:45 +04:00
|
|
|
nsJAR::Extract(const nsACString& aEntryName, nsIFile* outFile) {
|
2000-09-16 01:56:20 +04:00
|
|
|
// nsZipArchive and zlib are not thread safe
|
|
|
|
// we need to use a lock to prevent bug #51267
|
2022-03-24 16:54:56 +03:00
|
|
|
RecursiveMutexAutoLock lock(mLock);
|
|
|
|
if (!mZip) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2000-09-16 01:56:20 +04:00
|
|
|
|
2022-03-24 16:55:26 +03:00
|
|
|
LOG(("Extract[%p] %s", this, PromiseFlatCString(aEntryName).get()));
|
2011-09-29 03:14:45 +04:00
|
|
|
nsZipItem* item = mZip->GetItem(PromiseFlatCString(aEntryName).get());
|
2022-04-05 18:17:03 +03:00
|
|
|
NS_ENSURE_TRUE(item, NS_ERROR_FILE_NOT_FOUND);
|
2004-08-17 04:12:04 +04:00
|
|
|
|
2006-03-30 02:10:37 +04:00
|
|
|
// Remove existing file or directory so we set permissions correctly.
|
|
|
|
// If it's a directory that already exists and contains files, throw
|
|
|
|
// an exception and return.
|
|
|
|
|
2012-06-06 06:08:30 +04:00
|
|
|
nsresult rv = outFile->Remove(false);
|
2006-03-30 02:10:37 +04:00
|
|
|
if (rv == NS_ERROR_FILE_DIR_NOT_EMPTY || rv == NS_ERROR_FAILURE) return rv;
|
2004-08-17 04:12:04 +04:00
|
|
|
|
2009-10-17 19:54:54 +04:00
|
|
|
if (item->IsDirectory()) {
|
2012-06-06 06:08:30 +04:00
|
|
|
rv = outFile->Create(nsIFile::DIRECTORY_TYPE, item->Mode());
|
2006-03-30 02:10:37 +04:00
|
|
|
// XXX Do this in nsZipArchive? It would be nice to keep extraction
|
|
|
|
// XXX code completely there, but that would require a way to get a
|
2012-06-06 06:08:30 +04:00
|
|
|
// XXX PRDir from outFile.
|
2006-03-30 02:10:37 +04:00
|
|
|
} else {
|
|
|
|
PRFileDesc* fd;
|
2012-06-06 06:08:30 +04:00
|
|
|
rv = outFile->OpenNSPRFileDesc(PR_WRONLY | PR_CREATE_FILE, item->Mode(),
|
|
|
|
&fd);
|
2006-03-30 02:10:37 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-01-25 00:28:28 +03:00
|
|
|
|
2006-05-02 23:33:09 +04:00
|
|
|
// ExtractFile also closes the fd handle and resolves the symlink if needed
|
2017-12-15 14:58:51 +03:00
|
|
|
rv = mZip->ExtractFile(item, outFile, fd);
|
2000-03-28 07:38:06 +04:00
|
|
|
}
|
2006-05-02 23:33:09 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-03-28 07:38:06 +04:00
|
|
|
|
2006-05-02 23:33:09 +04:00
|
|
|
// nsIFile needs milliseconds, while prtime is in microseconds.
|
|
|
|
// non-fatal if this fails, ignore errors
|
2009-12-16 02:01:08 +03:00
|
|
|
outFile->SetLastModifiedTime(item->LastModTime() / PR_USEC_PER_MSEC);
|
2006-05-02 23:33:09 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
1999-11-12 09:13:13 +03:00
|
|
|
}
|
|
|
|
|
2014-02-25 05:16:11 +04:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 03:14:45 +04:00
|
|
|
nsJAR::GetEntry(const nsACString& aEntryName, nsIZipEntry** result) {
|
2022-03-24 16:54:56 +03:00
|
|
|
RecursiveMutexAutoLock lock(mLock);
|
2022-03-24 16:55:26 +03:00
|
|
|
LOG(("GetEntry[%p] %s", this, PromiseFlatCString(aEntryName).get()));
|
2022-03-24 16:54:56 +03:00
|
|
|
if (!mZip) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2011-09-29 03:14:45 +04:00
|
|
|
nsZipItem* zipItem = mZip->GetItem(PromiseFlatCString(aEntryName).get());
|
2022-04-05 18:17:03 +03:00
|
|
|
NS_ENSURE_TRUE(zipItem, NS_ERROR_FILE_NOT_FOUND);
|
1999-11-12 09:13:13 +03:00
|
|
|
|
2006-05-02 23:33:09 +04:00
|
|
|
nsJARItem* jarItem = new nsJARItem(zipItem);
|
|
|
|
|
|
|
|
NS_ADDREF(*result = jarItem);
|
1999-06-02 01:08:32 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-05-02 23:33:09 +04:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsJAR::HasEntry(const nsACString& aEntryName, bool* result) {
|
2022-03-24 16:54:56 +03:00
|
|
|
RecursiveMutexAutoLock lock(mLock);
|
2022-03-24 16:55:26 +03:00
|
|
|
LOG(("HasEntry[%p] %s", this, PromiseFlatCString(aEntryName).get()));
|
2022-03-24 16:54:56 +03:00
|
|
|
if (!mZip) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
*result = mZip->GetItem(PromiseFlatCString(aEntryName).get()) != nullptr;
|
2006-05-02 23:33:09 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 03:14:45 +04:00
|
|
|
nsJAR::FindEntries(const nsACString& aPattern,
|
|
|
|
nsIUTF8StringEnumerator** result) {
|
2006-05-02 23:33:09 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2022-03-24 16:54:56 +03:00
|
|
|
RecursiveMutexAutoLock lock(mLock);
|
2022-03-24 16:55:26 +03:00
|
|
|
LOG(("FindEntries[%p] %s", this, PromiseFlatCString(aPattern).get()));
|
2022-03-24 16:54:56 +03:00
|
|
|
if (!mZip) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2006-03-30 02:10:37 +04:00
|
|
|
|
|
|
|
nsZipFind* find;
|
2012-07-30 18:20:58 +04:00
|
|
|
nsresult rv = mZip->FindInit(
|
|
|
|
aPattern.IsEmpty() ? nullptr : PromiseFlatCString(aPattern).get(), &find);
|
2006-05-02 23:33:09 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1999-06-23 10:16:28 +04:00
|
|
|
|
2006-05-02 23:33:09 +04:00
|
|
|
nsIUTF8StringEnumerator* zipEnum = new nsJAREnumerator(find);
|
1999-06-23 10:16:28 +04:00
|
|
|
|
2006-05-02 23:33:09 +04:00
|
|
|
NS_ADDREF(*result = zipEnum);
|
1999-11-12 09:13:13 +03:00
|
|
|
return NS_OK;
|
1999-06-23 10:16:28 +04:00
|
|
|
}
|
|
|
|
|
1999-10-26 23:43:26 +04:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 03:14:45 +04:00
|
|
|
nsJAR::GetInputStream(const nsACString& aFilename, nsIInputStream** result) {
|
2020-09-23 18:17:15 +03:00
|
|
|
return GetInputStreamWithSpec(""_ns, aFilename, result);
|
2006-10-10 17:24:57 +04:00
|
|
|
}
|
2006-09-24 20:23:31 +04:00
|
|
|
|
2006-10-10 17:24:57 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-25 05:16:11 +04:00
|
|
|
nsJAR::GetInputStreamWithSpec(const nsACString& aJarDirSpec,
|
2011-09-29 03:14:45 +04:00
|
|
|
const nsACString& aEntryName,
|
|
|
|
nsIInputStream** result) {
|
2006-10-10 17:24:57 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2022-03-24 16:54:56 +03:00
|
|
|
RecursiveMutexAutoLock lock(mLock);
|
|
|
|
if (!mZip) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2006-09-24 20:23:31 +04:00
|
|
|
|
2022-03-24 16:55:26 +03:00
|
|
|
LOG(("GetInputStreamWithSpec[%p] %s %s", this,
|
|
|
|
PromiseFlatCString(aJarDirSpec).get(),
|
|
|
|
PromiseFlatCString(aEntryName).get()));
|
2006-10-10 17:24:57 +04:00
|
|
|
// Watch out for the jar:foo.zip!/ (aDir is empty) top-level special case!
|
2012-07-30 18:20:58 +04:00
|
|
|
nsZipItem* item = nullptr;
|
2017-07-21 16:12:55 +03:00
|
|
|
const nsCString& entry = PromiseFlatCString(aEntryName);
|
|
|
|
if (*entry.get()) {
|
2006-10-10 17:24:57 +04:00
|
|
|
// First check if item exists in jar
|
2017-07-21 16:12:55 +03:00
|
|
|
item = mZip->GetItem(entry.get());
|
2022-04-05 18:17:03 +03:00
|
|
|
if (!item) return NS_ERROR_FILE_NOT_FOUND;
|
2006-10-10 17:24:57 +04:00
|
|
|
}
|
2003-03-14 21:59:51 +03:00
|
|
|
nsJARInputStream* jis = new nsJARInputStream();
|
2006-10-10 17:24:57 +04:00
|
|
|
// addref now so we can call InitFile/InitDirectory()
|
|
|
|
NS_ADDREF(*result = jis);
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
2009-10-17 19:54:54 +04:00
|
|
|
if (!item || item->IsDirectory()) {
|
2017-07-21 16:12:55 +03:00
|
|
|
rv = jis->InitDirectory(this, aJarDirSpec, entry.get());
|
2006-10-10 17:24:57 +04:00
|
|
|
} else {
|
2022-03-24 16:54:56 +03:00
|
|
|
RefPtr<nsZipHandle> fd = mZip->GetFD();
|
|
|
|
rv = jis->InitFile(fd, mZip->GetData(item), item);
|
2006-10-10 17:24:57 +04:00
|
|
|
}
|
2003-03-14 21:59:51 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_RELEASE(*result);
|
|
|
|
}
|
2006-10-10 17:24:57 +04:00
|
|
|
return rv;
|
2000-01-29 03:03:57 +03:00
|
|
|
}
|
|
|
|
|
2022-03-24 16:54:56 +03:00
|
|
|
nsresult nsJAR::GetFullJarPath(nsACString& aResult) {
|
|
|
|
RecursiveMutexAutoLock lock(mLock);
|
2006-05-02 23:33:09 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(mZipFile);
|
|
|
|
|
2022-03-24 16:54:56 +03:00
|
|
|
nsresult rv = mZipFile->GetPersistentDescriptor(aResult);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mOuterZipEntry.IsEmpty()) {
|
|
|
|
aResult.InsertLiteral("file:", 0);
|
|
|
|
} else {
|
|
|
|
aResult.InsertLiteral("jar:", 0);
|
|
|
|
aResult.AppendLiteral("!/");
|
|
|
|
aResult.Append(mOuterZipEntry);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
2006-05-02 23:33:09 +04:00
|
|
|
}
|
|
|
|
|
2014-07-18 06:46:24 +04:00
|
|
|
nsresult nsJAR::GetNSPRFileDesc(PRFileDesc** aNSPRFileDesc) {
|
2022-03-24 16:54:56 +03:00
|
|
|
RecursiveMutexAutoLock lock(mLock);
|
2014-07-18 06:46:24 +04:00
|
|
|
if (!aNSPRFileDesc) {
|
|
|
|
return NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
}
|
|
|
|
*aNSPRFileDesc = nullptr;
|
|
|
|
|
|
|
|
if (!mZip) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2020-09-14 20:00:53 +03:00
|
|
|
RefPtr<nsZipHandle> handle = mZip->GetFD();
|
2014-07-18 06:46:24 +04:00
|
|
|
if (!handle) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return handle->GetNSPRFileDesc(aNSPRFileDesc);
|
|
|
|
}
|
|
|
|
|
2000-01-29 03:03:57 +03:00
|
|
|
//----------------------------------------------
|
|
|
|
// nsJAR private implementation
|
|
|
|
//----------------------------------------------
|
2017-02-26 15:36:40 +03:00
|
|
|
nsresult nsJAR::LoadEntry(const nsACString& aFilename, nsCString& aBuf) {
|
2000-07-12 07:10:33 +04:00
|
|
|
//-- Get a stream for reading the file
|
2000-01-29 03:03:57 +03:00
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIInputStream> manifestStream;
|
2000-07-12 07:10:33 +04:00
|
|
|
rv = GetInputStream(aFilename, getter_AddRefs(manifestStream));
|
2022-04-05 18:17:03 +03:00
|
|
|
if (NS_FAILED(rv)) return NS_ERROR_FILE_NOT_FOUND;
|
2014-02-25 05:16:11 +04:00
|
|
|
|
2000-01-29 03:03:57 +03:00
|
|
|
//-- Read the manifest file into memory
|
|
|
|
char* buf;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t len64;
|
2012-08-11 06:44:11 +04:00
|
|
|
rv = manifestStream->Available(&len64);
|
2000-01-29 03:03:57 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2018-12-15 03:02:56 +03:00
|
|
|
NS_ENSURE_TRUE(len64 < UINT32_MAX, NS_ERROR_FILE_CORRUPTED); // bug 164695
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t len = (uint32_t)len64;
|
2010-05-19 04:13:05 +04:00
|
|
|
buf = (char*)malloc(len + 1);
|
2000-01-29 03:03:57 +03:00
|
|
|
if (!buf) return NS_ERROR_OUT_OF_MEMORY;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t bytesRead;
|
2000-01-29 03:03:57 +03:00
|
|
|
rv = manifestStream->Read(buf, len, &bytesRead);
|
2015-11-16 11:18:45 +03:00
|
|
|
if (bytesRead != len) {
|
2000-01-29 03:03:57 +03:00
|
|
|
rv = NS_ERROR_FILE_CORRUPTED;
|
2015-11-16 11:18:45 +03:00
|
|
|
}
|
2002-10-31 09:23:52 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
2010-05-19 04:13:05 +04:00
|
|
|
free(buf);
|
2002-10-31 09:23:52 +03:00
|
|
|
return rv;
|
|
|
|
}
|
2000-02-14 04:57:01 +03:00
|
|
|
buf[len] = '\0'; // Null-terminate the buffer
|
2017-02-26 15:36:40 +03:00
|
|
|
aBuf.Adopt(buf, len);
|
2000-01-29 03:03:57 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-14 04:57:01 +03:00
|
|
|
int32_t nsJAR::ReadLine(const char** src) {
|
2013-12-24 06:12:52 +04:00
|
|
|
if (!*src) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-01-29 03:03:57 +03:00
|
|
|
//--Moves pointer to beginning of next line and returns line length
|
|
|
|
// not including CR/LF.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t length;
|
2021-08-10 14:30:39 +03:00
|
|
|
const char* eol = strpbrk(*src, "\r\n");
|
2000-01-29 03:03:57 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
if (eol == nullptr) // Probably reached end of file before newline
|
2000-01-29 03:03:57 +03:00
|
|
|
{
|
2013-05-08 07:40:12 +04:00
|
|
|
length = strlen(*src);
|
2000-01-29 03:03:57 +03:00
|
|
|
if (length == 0) // immediate end-of-file
|
2012-07-30 18:20:58 +04:00
|
|
|
*src = nullptr;
|
2000-01-29 03:03:57 +03:00
|
|
|
else // some data left on this line
|
|
|
|
*src += length;
|
|
|
|
} else {
|
|
|
|
length = eol - *src;
|
|
|
|
if (eol[0] == '\r' && eol[1] == '\n') // CR LF, so skip 2
|
|
|
|
*src = eol + 2;
|
|
|
|
else // Either CR or LF, so skip 1
|
|
|
|
*src = eol + 1;
|
|
|
|
}
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
2018-09-20 03:34:10 +03:00
|
|
|
NS_IMPL_ISUPPORTS(nsJAREnumerator, nsIUTF8StringEnumerator, nsIStringEnumerator)
|
2014-02-25 05:16:11 +04:00
|
|
|
|
2000-01-29 03:03:57 +03:00
|
|
|
//----------------------------------------------
|
2006-05-02 23:33:09 +04:00
|
|
|
// nsJAREnumerator::HasMore
|
1999-06-23 10:16:28 +04:00
|
|
|
//----------------------------------------------
|
1999-06-02 01:08:32 +04:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsJAREnumerator::HasMore(bool* aResult) {
|
1999-06-23 10:16:28 +04:00
|
|
|
// try to get the next element
|
2009-10-17 19:54:54 +04:00
|
|
|
if (!mName) {
|
2006-05-02 23:33:09 +04:00
|
|
|
NS_ASSERTION(mFind, "nsJAREnumerator: Missing zipFind.");
|
2009-10-17 19:54:54 +04:00
|
|
|
nsresult rv = mFind->FindNext(&mName, &mNameLen);
|
2022-04-05 18:17:03 +03:00
|
|
|
if (rv == NS_ERROR_FILE_NOT_FOUND) {
|
2011-10-17 18:59:28 +04:00
|
|
|
*aResult = false; // No more matches available
|
1999-06-23 10:16:28 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2006-05-02 23:33:09 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); // no error translation
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
1999-06-23 10:16:28 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
*aResult = true;
|
1999-06-23 10:16:28 +04:00
|
|
|
return NS_OK;
|
1999-06-02 01:08:32 +04:00
|
|
|
}
|
|
|
|
|
1999-06-23 10:16:28 +04:00
|
|
|
//----------------------------------------------
|
|
|
|
// nsJAREnumerator::GetNext
|
|
|
|
//----------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2006-05-02 23:33:09 +04:00
|
|
|
nsJAREnumerator::GetNext(nsACString& aResult) {
|
1999-06-23 10:16:28 +04:00
|
|
|
// check if the current item is "stale"
|
2009-10-17 19:54:54 +04:00
|
|
|
if (!mName) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool bMore;
|
2006-05-02 23:33:09 +04:00
|
|
|
nsresult rv = HasMore(&bMore);
|
|
|
|
if (NS_FAILED(rv) || !bMore)
|
|
|
|
return NS_ERROR_FAILURE; // no error translation
|
1999-07-16 03:06:52 +04:00
|
|
|
}
|
2009-10-17 19:54:54 +04:00
|
|
|
aResult.Assign(mName, mNameLen);
|
|
|
|
mName = 0; // we just gave this one away
|
2006-05-02 23:33:09 +04:00
|
|
|
return NS_OK;
|
1999-06-23 10:16:28 +04:00
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsJARItem, nsIZipEntry)
|
1999-06-23 10:16:28 +04:00
|
|
|
|
2006-05-02 23:33:09 +04:00
|
|
|
nsJARItem::nsJARItem(nsZipItem* aZipItem)
|
2009-10-17 19:54:54 +04:00
|
|
|
: mSize(aZipItem->Size()),
|
|
|
|
mRealsize(aZipItem->RealSize()),
|
|
|
|
mCrc32(aZipItem->CRC32()),
|
2009-12-16 02:01:08 +03:00
|
|
|
mLastModTime(aZipItem->LastModTime()),
|
2009-10-17 19:54:54 +04:00
|
|
|
mCompression(aZipItem->Compression()),
|
2013-10-11 20:47:15 +04:00
|
|
|
mPermissions(aZipItem->Mode()),
|
2009-10-17 19:54:54 +04:00
|
|
|
mIsDirectory(aZipItem->IsDirectory()),
|
2006-05-02 23:33:09 +04:00
|
|
|
mIsSynthetic(aZipItem->isSynthetic) {}
|
1999-06-23 10:16:28 +04:00
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// nsJARItem::GetCompression
|
|
|
|
//------------------------------------------
|
2006-03-30 02:10:37 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsJARItem::GetCompression(uint16_t* aCompression) {
|
2006-05-02 23:33:09 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(aCompression);
|
1999-06-23 10:16:28 +04:00
|
|
|
|
2006-05-02 23:33:09 +04:00
|
|
|
*aCompression = mCompression;
|
1999-06-23 10:16:28 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// nsJARItem::GetSize
|
|
|
|
//------------------------------------------
|
2006-03-30 02:10:37 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsJARItem::GetSize(uint32_t* aSize) {
|
2006-05-02 23:33:09 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(aSize);
|
1999-06-23 10:16:28 +04:00
|
|
|
|
2006-05-02 23:33:09 +04:00
|
|
|
*aSize = mSize;
|
1999-06-23 10:16:28 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// nsJARItem::GetRealSize
|
|
|
|
//------------------------------------------
|
2006-03-30 02:10:37 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsJARItem::GetRealSize(uint32_t* aRealsize) {
|
2006-05-02 23:33:09 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(aRealsize);
|
1999-06-23 10:16:28 +04:00
|
|
|
|
2006-05-02 23:33:09 +04:00
|
|
|
*aRealsize = mRealsize;
|
1999-06-23 10:16:28 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// nsJARItem::GetCrc32
|
|
|
|
//------------------------------------------
|
2006-03-30 02:10:37 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsJARItem::GetCRC32(uint32_t* aCrc32) {
|
2006-05-02 23:33:09 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(aCrc32);
|
1999-06-23 10:16:28 +04:00
|
|
|
|
2006-05-02 23:33:09 +04:00
|
|
|
*aCrc32 = mCrc32;
|
1999-06-23 10:16:28 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-01-29 03:03:57 +03:00
|
|
|
|
2006-03-30 02:10:37 +04:00
|
|
|
//------------------------------------------
|
|
|
|
// nsJARItem::GetIsDirectory
|
|
|
|
//------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsJARItem::GetIsDirectory(bool* aIsDirectory) {
|
2006-05-02 23:33:09 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(aIsDirectory);
|
2006-03-30 02:10:37 +04:00
|
|
|
|
2006-05-02 23:33:09 +04:00
|
|
|
*aIsDirectory = mIsDirectory;
|
2006-03-30 02:10:37 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// nsJARItem::GetIsSynthetic
|
|
|
|
//------------------------------------------
|
2006-05-02 23:33:09 +04:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsJARItem::GetIsSynthetic(bool* aIsSynthetic) {
|
2006-05-02 23:33:09 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(aIsSynthetic);
|
2006-03-30 02:10:37 +04:00
|
|
|
|
2006-05-02 23:33:09 +04:00
|
|
|
*aIsSynthetic = mIsSynthetic;
|
2006-03-30 02:10:37 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
// nsJARItem::GetLastModifiedTime
|
|
|
|
//------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARItem::GetLastModifiedTime(PRTime* aLastModTime) {
|
2006-05-02 23:33:09 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(aLastModTime);
|
2006-03-30 02:10:37 +04:00
|
|
|
|
2009-12-16 02:01:08 +03:00
|
|
|
*aLastModTime = mLastModTime;
|
2006-03-30 02:10:37 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-11 20:47:15 +04:00
|
|
|
//------------------------------------------
|
|
|
|
// nsJARItem::GetPermissions
|
|
|
|
//------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARItem::GetPermissions(uint32_t* aPermissions) {
|
|
|
|
NS_ENSURE_ARG_POINTER(aPermissions);
|
|
|
|
|
|
|
|
*aPermissions = mPermissions;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-12 11:58:24 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIZipReaderCache
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsZipReaderCache, nsIZipReaderCache, nsIObserver,
|
|
|
|
nsISupportsWeakReference)
|
2000-04-12 11:58:24 +04:00
|
|
|
|
|
|
|
nsZipReaderCache::nsZipReaderCache()
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
: mLock("nsZipReaderCache.mLock"),
|
2016-01-12 21:16:59 +03:00
|
|
|
mCacheSize(0),
|
2014-08-06 17:31:21 +04:00
|
|
|
mZips()
|
2000-08-24 11:38:41 +04:00
|
|
|
#ifdef ZIP_CACHE_HIT_RATE
|
2000-11-01 01:44:20 +03:00
|
|
|
,
|
2000-08-24 11:38:41 +04:00
|
|
|
mZipCacheLookups(0),
|
|
|
|
mZipCacheHits(0),
|
|
|
|
mZipCacheFlushes(0),
|
2000-11-01 01:44:20 +03:00
|
|
|
mZipSyncMisses(0)
|
2000-08-24 11:38:41 +04:00
|
|
|
#endif
|
2000-04-12 11:58:24 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsZipReaderCache::Init(uint32_t cacheSize) {
|
2022-03-24 16:54:56 +03:00
|
|
|
MutexAutoLock lock(mLock);
|
2014-02-25 05:16:11 +04:00
|
|
|
mCacheSize = cacheSize;
|
|
|
|
|
|
|
|
// Register as a memory pressure observer
|
|
|
|
nsCOMPtr<nsIObserverService> os =
|
2004-11-27 20:25:25 +03:00
|
|
|
do_GetService("@mozilla.org/observer-service;1");
|
|
|
|
if (os) {
|
2011-10-17 18:59:28 +04:00
|
|
|
os->AddObserver(this, "memory-pressure", true);
|
|
|
|
os->AddObserver(this, "chrome-flush-caches", true);
|
|
|
|
os->AddObserver(this, "flush-cache-entry", true);
|
2000-11-01 01:44:20 +03:00
|
|
|
}
|
|
|
|
// ignore failure of the observer registration.
|
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
return NS_OK;
|
2000-04-12 11:58:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsZipReaderCache::~nsZipReaderCache() {
|
2021-03-24 20:56:49 +03:00
|
|
|
for (const auto& zip : mZips.Values()) {
|
|
|
|
zip->SetZipReaderCache(nullptr);
|
2015-10-27 03:34:38 +03:00
|
|
|
}
|
2000-08-24 11:38:41 +04:00
|
|
|
|
|
|
|
#ifdef ZIP_CACHE_HIT_RATE
|
2000-11-01 01:44:20 +03:00
|
|
|
printf(
|
|
|
|
"nsZipReaderCache size=%d hits=%d lookups=%d rate=%f%% flushes=%d missed "
|
|
|
|
"%d\n",
|
2014-02-25 05:16:11 +04:00
|
|
|
mCacheSize, mZipCacheHits, mZipCacheLookups,
|
|
|
|
(float)mZipCacheHits / mZipCacheLookups, mZipCacheFlushes,
|
2000-11-01 01:44:20 +03:00
|
|
|
mZipSyncMisses);
|
2000-08-24 11:38:41 +04:00
|
|
|
#endif
|
2000-04-12 11:58:24 +04:00
|
|
|
}
|
|
|
|
|
2012-12-22 17:56:21 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsZipReaderCache::IsCached(nsIFile* zipFile, bool* aResult) {
|
|
|
|
NS_ENSURE_ARG_POINTER(zipFile);
|
|
|
|
nsresult rv;
|
|
|
|
MutexAutoLock lock(mLock);
|
|
|
|
|
|
|
|
nsAutoCString uri;
|
2017-12-15 14:58:51 +03:00
|
|
|
rv = zipFile->GetPersistentDescriptor(uri);
|
2012-12-22 17:56:21 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2017-09-08 04:15:42 +03:00
|
|
|
uri.InsertLiteral("file:", 0);
|
2012-12-22 17:56:21 +04:00
|
|
|
|
2014-02-25 05:16:11 +04:00
|
|
|
*aResult = mZips.Contains(uri);
|
2012-12-22 17:56:21 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-07-22 01:19:09 +03:00
|
|
|
nsresult nsZipReaderCache::GetZip(nsIFile* zipFile, nsIZipReader** result,
|
|
|
|
bool failOnMiss) {
|
2008-09-06 19:06:47 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(zipFile);
|
2000-04-12 11:58:24 +04:00
|
|
|
nsresult rv;
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(mLock);
|
2000-04-12 11:58:24 +04:00
|
|
|
|
2000-08-24 11:38:41 +04:00
|
|
|
#ifdef ZIP_CACHE_HIT_RATE
|
|
|
|
mZipCacheLookups++;
|
|
|
|
#endif
|
|
|
|
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString uri;
|
2017-12-15 14:58:51 +03:00
|
|
|
rv = zipFile->GetPersistentDescriptor(uri);
|
2000-05-25 12:30:29 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2017-09-08 04:15:42 +03:00
|
|
|
uri.InsertLiteral("file:", 0);
|
2010-09-09 07:38:34 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsJAR> zip;
|
2014-02-25 05:16:11 +04:00
|
|
|
mZips.Get(uri, getter_AddRefs(zip));
|
2009-08-13 00:50:12 +04:00
|
|
|
if (zip) {
|
2000-08-24 11:38:41 +04:00
|
|
|
#ifdef ZIP_CACHE_HIT_RATE
|
|
|
|
mZipCacheHits++;
|
|
|
|
#endif
|
2000-11-01 01:44:20 +03:00
|
|
|
zip->ClearReleaseTime();
|
2014-02-25 05:16:11 +04:00
|
|
|
} else {
|
2017-07-22 01:19:09 +03:00
|
|
|
if (failOnMiss) {
|
|
|
|
return NS_ERROR_CACHE_KEY_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2000-08-23 07:18:53 +04:00
|
|
|
zip = new nsJAR();
|
|
|
|
zip->SetZipReaderCache(this);
|
2006-05-02 23:33:09 +04:00
|
|
|
rv = zip->Open(zipFile);
|
2000-08-23 07:18:53 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2000-04-12 11:58:24 +04:00
|
|
|
|
2014-02-25 05:16:11 +04:00
|
|
|
MOZ_ASSERT(!mZips.Contains(uri));
|
2021-02-26 12:11:46 +03:00
|
|
|
mZips.InsertOrUpdate(uri, RefPtr{zip});
|
2000-04-12 11:58:24 +04:00
|
|
|
}
|
2014-02-25 05:16:11 +04:00
|
|
|
zip.forget(result);
|
2000-04-12 11:58:24 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2017-07-22 01:19:09 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsZipReaderCache::GetZipIfCached(nsIFile* zipFile, nsIZipReader** result) {
|
|
|
|
return GetZip(zipFile, result, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsZipReaderCache::GetZip(nsIFile* zipFile, nsIZipReader** result) {
|
|
|
|
return GetZip(zipFile, result, false);
|
|
|
|
}
|
|
|
|
|
2010-09-09 07:38:34 +04:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 03:14:45 +04:00
|
|
|
nsZipReaderCache::GetInnerZip(nsIFile* zipFile, const nsACString& entry,
|
2010-09-09 07:38:34 +04:00
|
|
|
nsIZipReader** result) {
|
|
|
|
NS_ENSURE_ARG_POINTER(zipFile);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIZipReader> outerZipReader;
|
|
|
|
nsresult rv = GetZip(zipFile, getter_AddRefs(outerZipReader));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2014-08-19 22:11:03 +04:00
|
|
|
MutexAutoLock lock(mLock);
|
|
|
|
|
2010-09-09 07:38:34 +04:00
|
|
|
#ifdef ZIP_CACHE_HIT_RATE
|
|
|
|
mZipCacheLookups++;
|
|
|
|
#endif
|
|
|
|
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString uri;
|
2017-12-15 14:58:51 +03:00
|
|
|
rv = zipFile->GetPersistentDescriptor(uri);
|
2010-09-09 07:38:34 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2017-09-08 04:15:42 +03:00
|
|
|
uri.InsertLiteral("jar:", 0);
|
2010-09-09 07:38:34 +04:00
|
|
|
uri.AppendLiteral("!/");
|
|
|
|
uri.Append(entry);
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsJAR> zip;
|
2014-02-25 05:16:11 +04:00
|
|
|
mZips.Get(uri, getter_AddRefs(zip));
|
2010-09-09 07:38:34 +04:00
|
|
|
if (zip) {
|
|
|
|
#ifdef ZIP_CACHE_HIT_RATE
|
|
|
|
mZipCacheHits++;
|
|
|
|
#endif
|
|
|
|
zip->ClearReleaseTime();
|
2014-02-25 05:16:11 +04:00
|
|
|
} else {
|
2010-09-09 07:38:34 +04:00
|
|
|
zip = new nsJAR();
|
|
|
|
zip->SetZipReaderCache(this);
|
|
|
|
|
|
|
|
rv = zip->OpenInner(outerZipReader, entry);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2014-02-25 05:16:11 +04:00
|
|
|
|
|
|
|
MOZ_ASSERT(!mZips.Contains(uri));
|
2021-02-26 12:11:46 +03:00
|
|
|
mZips.InsertOrUpdate(uri, RefPtr{zip});
|
2010-09-09 07:38:34 +04:00
|
|
|
}
|
2014-02-25 05:16:11 +04:00
|
|
|
zip.forget(result);
|
2010-09-09 07:38:34 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2014-07-18 06:46:24 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsZipReaderCache::GetFd(nsIFile* zipFile, PRFileDesc** aRetVal) {
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
MOZ_CRASH("Not implemented");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
#else
|
|
|
|
if (!zipFile) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsAutoCString uri;
|
2017-12-15 14:58:51 +03:00
|
|
|
rv = zipFile->GetPersistentDescriptor(uri);
|
2014-07-18 06:46:24 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2017-09-08 04:15:42 +03:00
|
|
|
uri.InsertLiteral("file:", 0);
|
2014-07-18 06:46:24 +04:00
|
|
|
|
|
|
|
MutexAutoLock lock(mLock);
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsJAR> zip;
|
2014-07-18 06:46:24 +04:00
|
|
|
mZips.Get(uri, getter_AddRefs(zip));
|
|
|
|
if (!zip) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
zip->ClearReleaseTime();
|
|
|
|
rv = zip->GetNSPRFileDesc(aRetVal);
|
|
|
|
// Do this to avoid possible deadlock on mLock with ReleaseZip().
|
2020-02-13 17:38:48 +03:00
|
|
|
{
|
|
|
|
MutexAutoUnlock unlock(mLock);
|
|
|
|
zip = nullptr;
|
|
|
|
}
|
2014-07-18 06:46:24 +04:00
|
|
|
return rv;
|
|
|
|
#endif /* XP_WIN */
|
|
|
|
}
|
|
|
|
|
2000-08-23 07:18:53 +04:00
|
|
|
nsresult nsZipReaderCache::ReleaseZip(nsJAR* zip) {
|
2000-04-12 11:58:24 +04:00
|
|
|
nsresult rv;
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(mLock);
|
2000-04-12 11:58:24 +04:00
|
|
|
|
2014-02-25 05:16:11 +04:00
|
|
|
// It is possible that two thread compete for this zip. The dangerous
|
2000-11-01 01:44:20 +03:00
|
|
|
// case is where one thread Releases the zip and discovers that the ref
|
|
|
|
// count has gone to one. Before it can call this ReleaseZip method
|
|
|
|
// another thread calls our GetZip method. The ref count goes to two. That
|
2006-03-30 02:10:37 +04:00
|
|
|
// second thread then Releases the zip and the ref count goes to one. It
|
|
|
|
// then tries to enter this ReleaseZip method and blocks while the first
|
2014-02-25 05:16:11 +04:00
|
|
|
// thread is still here. The first thread continues and remove the zip from
|
2000-11-01 01:44:20 +03:00
|
|
|
// the cache and calls its Release method sending the ref count to 0 and
|
|
|
|
// deleting the zip. However, the second thread is still blocked at the
|
|
|
|
// start of ReleaseZip, but the 'zip' param now hold a reference to a
|
|
|
|
// deleted zip!
|
2014-02-25 05:16:11 +04:00
|
|
|
//
|
2006-03-30 02:10:37 +04:00
|
|
|
// So, we are going to try safeguarding here by searching our hashtable while
|
2014-02-25 05:16:11 +04:00
|
|
|
// locked here for the zip. We return fast if it is not found.
|
2000-11-01 01:44:20 +03:00
|
|
|
|
2015-10-27 03:35:30 +03:00
|
|
|
bool found = false;
|
2021-03-24 20:56:49 +03:00
|
|
|
for (const auto& current : mZips.Values()) {
|
|
|
|
if (zip == current) {
|
2015-10-27 03:35:30 +03:00
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
2000-11-01 01:44:20 +03:00
|
|
|
#ifdef ZIP_CACHE_HIT_RATE
|
|
|
|
mZipSyncMisses++;
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-09-18 11:08:22 +04:00
|
|
|
zip->SetReleaseTime();
|
|
|
|
|
2000-08-23 07:18:53 +04:00
|
|
|
if (mZips.Count() <= mCacheSize) return NS_OK;
|
|
|
|
|
2015-10-27 03:35:30 +03:00
|
|
|
// Find the oldest zip.
|
2012-07-30 18:20:58 +04:00
|
|
|
nsJAR* oldest = nullptr;
|
2021-03-24 20:56:49 +03:00
|
|
|
for (const auto& current : mZips.Values()) {
|
2015-10-27 03:35:30 +03:00
|
|
|
PRIntervalTime currentReleaseTime = current->GetReleaseTime();
|
|
|
|
if (currentReleaseTime != PR_INTERVAL_NO_TIMEOUT) {
|
|
|
|
if (oldest == nullptr || currentReleaseTime < oldest->GetReleaseTime()) {
|
|
|
|
oldest = current;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-02-25 05:16:11 +04:00
|
|
|
|
2000-11-01 01:44:20 +03:00
|
|
|
// Because of the craziness above it is possible that there is no zip that
|
2014-02-25 05:16:11 +04:00
|
|
|
// needs removing.
|
2000-11-01 01:44:20 +03:00
|
|
|
if (!oldest) return NS_OK;
|
2000-08-23 07:18:53 +04:00
|
|
|
|
2000-08-24 11:38:41 +04:00
|
|
|
#ifdef ZIP_CACHE_HIT_RATE
|
|
|
|
mZipCacheFlushes++;
|
|
|
|
#endif
|
|
|
|
|
2000-08-23 07:18:53 +04:00
|
|
|
// remove from hashtable
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString uri;
|
2022-03-24 16:54:56 +03:00
|
|
|
rv = oldest->GetFullJarPath(uri);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
2010-09-09 07:38:34 +04:00
|
|
|
}
|
2000-05-25 12:30:29 +04:00
|
|
|
|
2022-03-24 16:54:56 +03:00
|
|
|
// Retrieving and removing the JAR should be done without an extra AddRef
|
2014-02-25 05:16:11 +04:00
|
|
|
// and Release, or we'll trigger nsJAR::Release's magic refcount 1 case
|
2022-03-24 16:54:56 +03:00
|
|
|
// an extra time.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsJAR> removed;
|
2014-02-25 05:16:11 +04:00
|
|
|
mZips.Remove(uri, getter_AddRefs(removed));
|
2000-08-23 07:18:53 +04:00
|
|
|
NS_ASSERTION(removed, "botched");
|
2011-03-31 23:01:12 +04:00
|
|
|
NS_ASSERTION(oldest == removed, "removed wrong entry");
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
if (removed) removed->SetZipReaderCache(nullptr);
|
2000-04-12 11:58:24 +04:00
|
|
|
|
2000-11-01 01:44:20 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsZipReaderCache::Observe(nsISupports* aSubject, const char* aTopic,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* aSomeData) {
|
2004-11-27 20:25:25 +03:00
|
|
|
if (strcmp(aTopic, "memory-pressure") == 0) {
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(mLock);
|
2015-11-23 05:52:40 +03:00
|
|
|
for (auto iter = mZips.Iter(); !iter.Done(); iter.Next()) {
|
|
|
|
RefPtr<nsJAR>& current = iter.Data();
|
|
|
|
if (current->GetReleaseTime() != PR_INTERVAL_NO_TIMEOUT) {
|
|
|
|
current->SetZipReaderCache(nullptr);
|
|
|
|
iter.Remove();
|
|
|
|
}
|
|
|
|
}
|
2004-11-27 20:25:25 +03:00
|
|
|
} else if (strcmp(aTopic, "chrome-flush-caches") == 0) {
|
2014-08-19 22:11:03 +04:00
|
|
|
MutexAutoLock lock(mLock);
|
2021-03-24 20:56:49 +03:00
|
|
|
for (const auto& current : mZips.Values()) {
|
|
|
|
current->SetZipReaderCache(nullptr);
|
2015-10-27 03:34:38 +03:00
|
|
|
}
|
2014-02-25 05:16:11 +04:00
|
|
|
mZips.Clear();
|
2010-09-09 07:39:19 +04:00
|
|
|
} else if (strcmp(aTopic, "flush-cache-entry") == 0) {
|
2016-11-18 07:00:30 +03:00
|
|
|
nsCOMPtr<nsIFile> file;
|
|
|
|
if (aSubject) {
|
|
|
|
file = do_QueryInterface(aSubject);
|
|
|
|
} else if (aSomeData) {
|
|
|
|
nsDependentString fileName(aSomeData);
|
|
|
|
Unused << NS_NewLocalFile(fileName, false, getter_AddRefs(file));
|
|
|
|
}
|
|
|
|
|
2010-09-09 07:39:19 +04:00
|
|
|
if (!file) return NS_OK;
|
|
|
|
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString uri;
|
2017-12-15 14:58:51 +03:00
|
|
|
if (NS_FAILED(file->GetPersistentDescriptor(uri))) return NS_OK;
|
2010-09-09 07:39:19 +04:00
|
|
|
|
2017-09-08 04:15:42 +03:00
|
|
|
uri.InsertLiteral("file:", 0);
|
2010-09-09 07:39:19 +04:00
|
|
|
|
2014-02-25 05:16:11 +04:00
|
|
|
MutexAutoLock lock(mLock);
|
2014-02-25 05:16:11 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsJAR> zip;
|
2014-02-25 05:16:11 +04:00
|
|
|
mZips.Get(uri, getter_AddRefs(zip));
|
2010-09-09 07:39:19 +04:00
|
|
|
if (!zip) return NS_OK;
|
|
|
|
|
|
|
|
#ifdef ZIP_CACHE_HIT_RATE
|
|
|
|
mZipCacheFlushes++;
|
|
|
|
#endif
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
zip->SetZipReaderCache(nullptr);
|
2010-09-09 07:39:19 +04:00
|
|
|
|
2014-02-25 05:16:11 +04:00
|
|
|
mZips.Remove(uri);
|
2010-09-09 07:39:19 +04:00
|
|
|
}
|
2000-04-12 11:58:24 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|