forked from mirrors/gecko-dev
Bug 1875001 - Remove unused features from nsDirIndexParser. r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D198797
This commit is contained in:
parent
fa09c95758
commit
2f27be1956
10 changed files with 20 additions and 126 deletions
|
|
@ -177,19 +177,11 @@ interface nsIZipReader : nsISupports
|
|||
|
||||
/**
|
||||
* Returns an input stream containing the contents of the specified zip
|
||||
* entry.
|
||||
* entry. If the entry refers to a directory (ends with '/'), a directory stream
|
||||
* is opened, otherwise the contents of the file entry is returned.
|
||||
* @param zipEntry the name of the entry to open the stream from
|
||||
*/
|
||||
nsIInputStream getInputStream(in AUTF8String zipEntry);
|
||||
|
||||
/**
|
||||
* Returns an input stream containing the contents of the specified zip
|
||||
* entry. If the entry refers to a directory (ends with '/'), a directory stream
|
||||
* is opened, otherwise the contents of the file entry is returned.
|
||||
* @param aJarSpec the Spec of the URI for the JAR (only used for directory streams)
|
||||
* @param zipEntry the name of the entry to open the stream from
|
||||
*/
|
||||
nsIInputStream getInputStreamWithSpec(in AUTF8String aJarSpec, in AUTF8String zipEntry);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -287,23 +287,14 @@ nsJAR::FindEntries(const nsACString& aPattern,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJAR::GetInputStream(const nsACString& aFilename, nsIInputStream** result) {
|
||||
return GetInputStreamWithSpec(""_ns, aFilename, result);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJAR::GetInputStreamWithSpec(const nsACString& aJarDirSpec,
|
||||
const nsACString& aEntryName,
|
||||
nsIInputStream** result) {
|
||||
nsJAR::GetInputStream(const nsACString& aEntryName, nsIInputStream** result) {
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
RecursiveMutexAutoLock lock(mLock);
|
||||
if (!mZip) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
LOG(("GetInputStreamWithSpec[%p] %s %s", this,
|
||||
PromiseFlatCString(aJarDirSpec).get(),
|
||||
PromiseFlatCString(aEntryName).get()));
|
||||
LOG(("GetInputStream[%p] %s", this, PromiseFlatCString(aEntryName).get()));
|
||||
// Watch out for the jar:foo.zip!/ (aDir is empty) top-level special case!
|
||||
nsZipItem* item = nullptr;
|
||||
const nsCString& entry = PromiseFlatCString(aEntryName);
|
||||
|
|
@ -318,7 +309,7 @@ nsJAR::GetInputStreamWithSpec(const nsACString& aJarDirSpec,
|
|||
|
||||
nsresult rv = NS_OK;
|
||||
if (!item || item->IsDirectory()) {
|
||||
rv = jis->InitDirectory(this, aJarDirSpec, entry.get());
|
||||
rv = jis->InitDirectory(this, entry.get());
|
||||
} else {
|
||||
RefPtr<nsZipHandle> fd = mZip->GetFD();
|
||||
rv = jis->InitFile(fd, mZip->GetData(item), item);
|
||||
|
|
|
|||
|
|
@ -71,26 +71,13 @@ class nsJARInputThunk : public nsIInputStream {
|
|||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIINPUTSTREAM
|
||||
|
||||
nsJARInputThunk(nsIZipReader* zipReader, nsIURI* fullJarURI,
|
||||
const nsACString& jarEntry, bool usingJarCache)
|
||||
nsJARInputThunk(nsIZipReader* zipReader, const nsACString& jarEntry,
|
||||
bool usingJarCache)
|
||||
: mUsingJarCache(usingJarCache),
|
||||
mJarReader(zipReader),
|
||||
mJarEntry(jarEntry),
|
||||
mContentLength(-1) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(zipReader, "zipReader must not be null");
|
||||
if (ENTRY_IS_DIRECTORY(mJarEntry) && fullJarURI) {
|
||||
nsCOMPtr<nsIURI> urlWithoutQueryRef;
|
||||
nsresult rv = NS_MutateURI(fullJarURI)
|
||||
.SetQuery(""_ns)
|
||||
.SetRef(""_ns)
|
||||
.Finalize(urlWithoutQueryRef);
|
||||
if (NS_SUCCEEDED(rv) && urlWithoutQueryRef) {
|
||||
rv = urlWithoutQueryRef->GetAsciiSpec(mJarDirSpec);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv), "Finding a jar dir spec shouldn't fail.");
|
||||
} else {
|
||||
MOZ_CRASH("Shouldn't fail to strip query and ref off jar URI.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int64_t GetContentLength() { return mContentLength; }
|
||||
|
|
@ -102,7 +89,6 @@ class nsJARInputThunk : public nsIInputStream {
|
|||
|
||||
bool mUsingJarCache;
|
||||
nsCOMPtr<nsIZipReader> mJarReader;
|
||||
nsCString mJarDirSpec;
|
||||
nsCOMPtr<nsIInputStream> mJarStream;
|
||||
nsCString mJarEntry;
|
||||
int64_t mContentLength;
|
||||
|
|
@ -114,18 +100,8 @@ nsresult nsJARInputThunk::Init() {
|
|||
if (!mJarReader) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
nsresult rv;
|
||||
if (ENTRY_IS_DIRECTORY(mJarEntry)) {
|
||||
// A directory stream also needs the Spec of the FullJarURI
|
||||
// because is included in the stream data itself.
|
||||
|
||||
NS_ENSURE_STATE(!mJarDirSpec.IsEmpty());
|
||||
|
||||
rv = mJarReader->GetInputStreamWithSpec(mJarDirSpec, mJarEntry,
|
||||
getter_AddRefs(mJarStream));
|
||||
} else {
|
||||
rv = mJarReader->GetInputStream(mJarEntry, getter_AddRefs(mJarStream));
|
||||
}
|
||||
nsresult rv =
|
||||
mJarReader->GetInputStream(mJarEntry, getter_AddRefs(mJarStream));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
|
@ -290,7 +266,7 @@ nsresult nsJARChannel::CreateJarInput(nsIZipReaderCache* jarCache,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
RefPtr<nsJARInputThunk> input =
|
||||
new nsJARInputThunk(reader, mJarURI, mJarEntry, jarCache != nullptr);
|
||||
new nsJARInputThunk(reader, mJarEntry, jarCache != nullptr);
|
||||
rv = input->Init();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
|
|
@ -354,7 +330,7 @@ nsresult nsJARChannel::LookupFile() {
|
|||
|
||||
nsresult CreateLocalJarInput(nsIZipReaderCache* aJarCache, nsIFile* aFile,
|
||||
const nsACString& aInnerJarEntry,
|
||||
nsIJARURI* aJarURI, const nsACString& aJarEntry,
|
||||
const nsACString& aJarEntry,
|
||||
nsJARInputThunk** aResultInput) {
|
||||
LOG(("nsJARChannel::CreateLocalJarInput [aJarCache=%p, %s, %s]\n", aJarCache,
|
||||
PromiseFlatCString(aInnerJarEntry).get(),
|
||||
|
|
@ -377,7 +353,7 @@ nsresult CreateLocalJarInput(nsIZipReaderCache* aJarCache, nsIFile* aFile,
|
|||
}
|
||||
|
||||
RefPtr<nsJARInputThunk> input =
|
||||
new nsJARInputThunk(reader, aJarURI, aJarEntry, aJarCache != nullptr);
|
||||
new nsJARInputThunk(reader, aJarEntry, aJarCache != nullptr);
|
||||
rv = input->Init();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
|
|
@ -425,19 +401,16 @@ nsresult nsJARChannel::OpenLocalFile() {
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIJARURI> localJARURI = mJarURI;
|
||||
|
||||
nsAutoCString jarEntry(mJarEntry);
|
||||
nsAutoCString innerJarEntry(mInnerJarEntry);
|
||||
|
||||
RefPtr<nsJARChannel> self = this;
|
||||
return mWorker->Dispatch(NS_NewRunnableFunction(
|
||||
"nsJARChannel::OpenLocalFile", [self, jarCache, clonedFile, localJARURI,
|
||||
jarEntry, innerJarEntry]() mutable {
|
||||
"nsJARChannel::OpenLocalFile",
|
||||
[self, jarCache, clonedFile, jarEntry, innerJarEntry]() mutable {
|
||||
RefPtr<nsJARInputThunk> input;
|
||||
nsresult rv =
|
||||
CreateLocalJarInput(jarCache, clonedFile, innerJarEntry,
|
||||
localJARURI, jarEntry, getter_AddRefs(input));
|
||||
nsresult rv = CreateLocalJarInput(jarCache, clonedFile, innerJarEntry,
|
||||
jarEntry, getter_AddRefs(input));
|
||||
|
||||
nsCOMPtr<nsIRunnable> target;
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
|
|
|||
|
|
@ -76,9 +76,7 @@ nsresult nsJARInputStream::InitFile(nsZipHandle* aFd, const uint8_t* aData,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsJARInputStream::InitDirectory(nsJAR* aJar,
|
||||
const nsACString& aJarDirSpec,
|
||||
const char* aDir) {
|
||||
nsresult nsJARInputStream::InitDirectory(nsJAR* aJar, const char* aDir) {
|
||||
MOZ_ASSERT(aJar, "Argument may not be null");
|
||||
MOZ_ASSERT(aDir, "Argument may not be null");
|
||||
|
||||
|
|
@ -141,10 +139,8 @@ nsresult nsJARInputStream::InitDirectory(nsJAR* aJar,
|
|||
// Sort it
|
||||
mArray.Sort();
|
||||
|
||||
mBuffer.AssignLiteral("300: ");
|
||||
mBuffer.Append(aJarDirSpec);
|
||||
mBuffer.AppendLiteral(
|
||||
"\n200: filename content-length last-modified file-type\n");
|
||||
"200: filename content-length last-modified file-type\n");
|
||||
|
||||
// Open for reading
|
||||
mMode = MODE_DIRECTORY;
|
||||
|
|
|
|||
|
|
@ -36,8 +36,7 @@ class nsJARInputStream final : public nsIInputStream {
|
|||
// takes ownership of |fd|, even on failure
|
||||
nsresult InitFile(nsZipHandle* aFd, const uint8_t* aData, nsZipItem* item);
|
||||
|
||||
nsresult InitDirectory(nsJAR* aJar, const nsACString& aJarDirSpec,
|
||||
const char* aDir);
|
||||
nsresult InitDirectory(nsJAR* aJar, const char* aDir);
|
||||
|
||||
private:
|
||||
~nsJARInputStream() { Close(); }
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
#include "mozilla/Logging.h"
|
||||
#include "prtime.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsURLHelper.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
|
||||
// NOTE: This runs on the _file transport_ thread.
|
||||
|
|
@ -95,13 +94,6 @@ nsresult nsDirectoryIndexStream::Init(nsIFile* aDir) {
|
|||
|
||||
mArray.Sort(compare);
|
||||
|
||||
mBuf.AppendLiteral("300: ");
|
||||
nsAutoCString url;
|
||||
rv = net_GetURLSpecFromFile(aDir, url);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mBuf.Append(url);
|
||||
mBuf.Append('\n');
|
||||
|
||||
mBuf.AppendLiteral("200: filename content-length last-modified file-type\n");
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
|||
|
|
@ -286,21 +286,10 @@ nsresult nsGIOInputStream::DoOpenDirectory() {
|
|||
mDirList = g_list_sort(mDirList, FileInfoComparator);
|
||||
mDirListPtr = mDirList;
|
||||
|
||||
// Write base URL (make sure it ends with a '/')
|
||||
mDirBuf.AppendLiteral("300: ");
|
||||
mDirBuf.Append(mSpec);
|
||||
if (mSpec.get()[mSpec.Length() - 1] != '/') {
|
||||
mDirBuf.Append('/');
|
||||
}
|
||||
mDirBuf.Append('\n');
|
||||
|
||||
// Write column names
|
||||
mDirBuf.AppendLiteral(
|
||||
"200: filename content-length last-modified file-type\n");
|
||||
|
||||
// Write charset (assume UTF-8)
|
||||
// XXX is this correct?
|
||||
mDirBuf.AppendLiteral("301: UTF-8\n");
|
||||
SetContentTypeOfChannel(APPLICATION_HTTP_INDEX_FORMAT);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -245,19 +245,7 @@ nsresult nsDirIndexParser::ProcessData(nsIRequest* aRequest) {
|
|||
if (lineLen >= 4) {
|
||||
const char* buf = line;
|
||||
|
||||
if (buf[0] == '1') {
|
||||
if (buf[1] == '0') {
|
||||
if (buf[2] == '0' && buf[3] == ':') {
|
||||
// 100. Human-readable comment line. Ignore
|
||||
} else if (buf[2] == '1' && buf[3] == ':') {
|
||||
// 101. Human-readable information line.
|
||||
char* value = ((char*)buf) + 4;
|
||||
nsUnescape(value);
|
||||
mListener->OnInformationAvailable(aRequest,
|
||||
NS_ConvertUTF8toUTF16(value));
|
||||
}
|
||||
}
|
||||
} else if (buf[0] == '2') {
|
||||
if (buf[0] == '2') {
|
||||
if (buf[1] == '0') {
|
||||
if (buf[2] == '0' && buf[3] == ':') {
|
||||
// 200. Define field names
|
||||
|
|
|
|||
|
|
@ -813,22 +813,6 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest* aRequest, nsIDirIndex* aIndex) {
|
|||
return SendToListener(aRequest, pushBuffer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIndexedToHTML::OnInformationAvailable(nsIRequest* aRequest,
|
||||
const nsAString& aInfo) {
|
||||
nsAutoCString pushBuffer;
|
||||
nsAutoCString escapedUtf8;
|
||||
nsAppendEscapedHTML(NS_ConvertUTF16toUTF8(aInfo), escapedUtf8);
|
||||
pushBuffer.AppendLiteral("<tr>\n <td>");
|
||||
// escaped is provided in Unicode, so write hex NCRs as necessary
|
||||
// to prevent the HTML parser from applying a character set.
|
||||
AppendNonAsciiToNCR(NS_ConvertUTF8toUTF16(escapedUtf8), pushBuffer);
|
||||
pushBuffer.AppendLiteral(
|
||||
"</td>\n <td></td>\n <td></td>\n <td></td>\n</tr>\n");
|
||||
|
||||
return SendToListener(aRequest, pushBuffer);
|
||||
}
|
||||
|
||||
void nsIndexedToHTML::FormatSizeString(int64_t inSize,
|
||||
nsCString& outSizeString) {
|
||||
outSizeString.Truncate();
|
||||
|
|
|
|||
|
|
@ -22,16 +22,6 @@ interface nsIDirIndexListener : nsISupports {
|
|||
*/
|
||||
void onIndexAvailable(in nsIRequest aRequest,
|
||||
in nsIDirIndex aIndex);
|
||||
|
||||
/**
|
||||
* Called for each information line
|
||||
*
|
||||
* @param request - the request
|
||||
* @param info - new info to add
|
||||
*/
|
||||
void onInformationAvailable(in nsIRequest aRequest,
|
||||
in AString aInfo);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue